Search code examples
node.jswebdriverselenium-chromedriverwebdriver-io

webdriverio 5.16 browser.element is not a function


i have a problem after i upgraded webdriver from 4.8 to 5.16:

My package.json

    "@wdio/cli": "^5.16.15",
    "@wdio/local-runner": "^5.16.15",
    "@wdio/mocha-framework": "^5.16.15",
    "@wdio/spec-reporter": "^5.16.11",
    "@wdio/sync": "^5.16.15",
    ...
    "chromedriver": "^79.0.0",
    ...
    "selenium-webdriver": "3.0.0-beta-2",
    ....
    "wdio-chromedriver-service": "^5.0.2",
    "webdriverio": "^5.16.15",

then in my test i call:

browser.element('body')

result error:

browser.element is not a function

Was this function replaced (didn't find any notes about that)? and if so, whats the function to use now? Or is there another problem? Help pls.


Solution

  • if I understand your question correctly, browser.element() is no longer available in v5.

    As per their official changelog, it is changed to browser.findElement in v5.

    You can also use browser.$() in place of browser.element().

    Here is the complete list of changes in v5 if you have not figured it out yet.

    https://github.com/webdriverio/webdriverio/blob/master/CHANGELOG.md#v500-2018-12-20