augustminhvo / mocha_jv_testing

JavaScript in Node.js with Mocha framework
0 stars 0 forks source link

It seem Chome can't open when run npm test #1

Open augustminhvo opened 5 years ago

augustminhvo commented 5 years ago

Hi, I have package.json like this

{
  "name": "study",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "node_modules/.bin/mocha ./phan_04/openPage.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@types/node": "^10.12.18",
    "@types/webdriverio": "^4.13.2",
    "mocha": "^5.2.0",
    "wdio-mocha-framework": "^0.6.4",
    "wdio-selenium-standalone-service": "0.0.12",
    "webdriverio": "^5.3.5"
  },
}

and test.config.js

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

and openPage.js like

    it('open page', function(){
        browser.url('https://genk.com');
        browser.pause(7200);
    });
});```

when i run with npm test i got a error

API command 1) open page 0 passing (16ms) 1 failing 1) API command open page: ReferenceError: browser is not defined at Context. (phan_04\openPage.js:17:9)

Monideepa23 commented 4 years ago

Hi.. I am facing same issue. Can you please let me know how did you solve this error.

Thank you, Monideepa