添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

ReferenceError: browser is not defined when i run first test #3439

Closed
@augustminhvo

Description

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

    Activity

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions