Webdriverio: ReferenceError: browser is not defined when i run first test

Created on 27 Jan 2019  路  1Comment  路  Source: webdriverio/webdriverio

I have create a sample script, but it can't open chrome browser, so confusing about this issue, i stuck in 7 days, i was try a lot of solution in github or stackoverflow but i cant help so much

  • Node.js version: 10.15.0
  • Browser name and version: Chrome 71
  • Platform name and version: Windows 8.1

Here is my file
package.json

{
  "name": "api_test",
  "version": "1.0.0",
  "main": "index.js",
  "directories": {
    "test": "wdio"
  },
  "dependencies": {
    "selenium-webdriver": "^4.0.0-alpha.1"
  },
  "devDependencies": {
    "@types/node": "^10.12.18",
    "@types/webdriverio": "^5.0.0",
    "wdio-mocha-framework": "^0.6.4",
    "wdio-selenium-standalone-service": "0.0.12",
    "webdriverio": "^5.4.7"
  },
  "scripts": {
    "test": "mocha"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": ""
}

test.conf.js

exports.config = {
    specs: ['./test/openPage.js'],
    hots: 'localhost',
    port: 9515,
    path: '/',
    capabilities: [
        {
            browserName: 'chrome'
        }
    ],
    framework: 'mocha',
    mochaOpts:{
        ui: 'bdd',
        timeout: 600000
    },
    logLevel: 'verybose',
}

openPage.js

describe('api command', function(){
    it('open page', function (){
        browser.url('https://www.google.com');
        browser.pause(600000);
    });
});

When i run: npm test test.conf.js
-> 0 passing (5ms) -> no open chrome no error

When i run: npm test ./test/openPage.js

 api command
    1) open page
  0 passing (15ms)
  1 failing

  1) api command
       open page:
     ReferenceError: browser is not defined
      at Context.<anonymous> (test\openPage.js:3:9)
npm ERR! Test failed.  See above for more details.

I really need help with this, thank you for any infomations

>All comments

You are mixing webdriverio v5 with non compatible plugins (v4). This is not an issue with webdriverio.

Was this page helpful?
0 / 5 - 0 ratings