webdriverio: ReferenceError: $$ is not defined

It states on the first page in webdriverio page:

With the $ and $$ functions WebdriverIO provides useful shortcuts which can also be chained in order to move deeper in the DOM tree without using complex xPath selectors.

It even states an example:

var expect = require('chai').expect;
describe('webdriver.io api page', function() {
    it('should be able to filter for commands', function () {
        browser.url('http://webdriver.io/api.html');

        // filtering property commands
        $('.searchbar input').setValue('getT');

        // get all results that are displayed
        var results = $$('.commands.property a').filter(function (link) {
            return link.isVisible();
        });

        // assert number of results
        expect(results.length).to.be.equal(3);

        // check out second result
        results[1].click();
        expect($('.doc h1').getText()).to.be.equal('GETTEXT');
    });
});

I however get the error when running tests via mocha with nodejs locally:

ReferenceError: $$ is not defined

All my other tests are working and webdriverio seems to be working as intended.

Using webdriverio 4.12.0 with nodejs.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (14 by maintainers)

Most upvoted comments

Anyway the problem is not with this service or any other. I’d like to make some changes to getting started so that there is no need to google for any additional documentation on the first steps

Another webdriverio issue discussion that disappears into ether …

@mgrybyk I like to disagree and say that the documentation clearly states how it should be configured and what it falls back to when possible. Reference: https://github.com/atti187/wdio-chromedriver-service#readme

KEEP IN MIND: this service is not created nor maintained by us, if we want to be more clear and upfront about things like this we should add a service that is maintained by us instead of the community.

If you’re going to be expecting people to refer to the GitHub immediately then I suggest referencing it immediately also.

Also a suggest to maybe add a date to the Getting Started incase it has gone untouched for say e.g. 12 months and new versions have come up that way someone would be able to identify it - just a suggestiveness.

@mgrybyk Thanks for hearing out my feedback! Keep up the great work team!

we should add a service that is maintained by us instead of the community.

I disagree on that. We don’t need to own a plugin just to make changes. We can propose PRs for that project like on any other project too.