WebdriverIO:如何修复错误“未知错误:无法获得自动化扩展”?

时间:2017-10-31 16:53:04

标签: node.js selenium-webdriver selenium-chromedriver webdriver-io

当前设置:

  

注意:

     

提及这个副本的评论是为了维护自己的chromedriver和selenium安装,但是如果你使用wdio-selenium-standalone-service那些“重复”的问题/解决方案没有帮助。希望这给出了上下文

截至今天,我们在运行自动化UI测试时遇到了一个主要问题:

[13:35:36]      Failed to take screenshot on reject:     {"message":"unknown error: cannot get automation extension\nfrom unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html","type":"RuntimeError","seleniumStack":{"status":13,"type":"UnknownError","message":"An unknown server-side error occurred while processing the command.","orgStatusMessage":"unknown error: cannot get automation extension\nfrom unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html\n  (Session info: chrome= ... (1233 more bytes)"}}
F..------------------------------------------------------------------
[chrome #0-0] Session ID: c58395b3-9e09-4d67-987d-f385bca117cc
[chrome #0-0] Spec: C:\Development\step_definitionswebsite-logo.feature
[chrome #0-0] Running: chrome
[chrome #0-0]
[chrome #0-0]   As a tester I need to verify some home page elements
[chrome #0-0]
[chrome #0-0]   Company logo has a valid alternative text
[chrome #0-0]       1) I open the homepage
[chrome #0-0]       - I check the logo text
[chrome #0-0]       - I get a logo text matching "Logo"
[chrome #0-0]
[chrome #0-0]
[chrome #0-0] 2 pending (30s)
[chrome #0-0] 1 failing
[chrome #0-0]
[chrome #0-0] 1) Company logo has a valid alternative text9 I open the homepage:
[chrome #0-0] unknown error: cannot get automation extension
from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
[chrome #0-0] Error: unknown error: cannot get automation extension
[chrome #0-0]     at Object.setViewportSize (C:\Development\node_modules\wdio-sync\build\index.js:330:27)
[chrome #0-0]     at Page.open (C:\Development\lib\page-objects\page.js:26:21)
[chrome #0-0]     at customWorld.<anonymous> (C:\Development\ui-tests\cucumber\step_definitions\ui-given.js:11:14)
[chrome #0-0]     at C:\Development\node_modules\wdio-sync\build\index.js:578:26
[chrome #0-0]     at Promise.F (C:\Development\node_modules\core-js\library\modules\_export.js:35:28)
[chrome #0-0]     at customWorld.executeSync (C:\Development\node_modules\wdio-sync\build\index.js:576:12)
[chrome #0-0]     at C:\Development\node_modules\wdio-sync\build\index.js:191:29
[chrome #0-0]     from unknown error: page could not be found: chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html
[chrome #0-0]     at windowHandleSize([object Object]) - C:\Development\node_modules\webdriverio\build\lib\commands\setViewportSize.js:60:68
[chrome #0-0]     at setViewportSize([object Object], false) -     at C:\Development\\node_modules\wdio-sync\build\at Object.wait (C:\Development\\node_modules\fibers\future.js:449:15)

我们在wdio.conf.js中使用这一行:

services: ['selenium-standalone']

这是我们的packages.json:

"dependencies": {
    "assign-deep": "^0.4.5",
    "chai": "^3.5.0",
    "eslint": "^3.17.1",
    "eslint-config-airbnb-base": "^11.1.1",
    "fs-extra": "^2.0.0",
    "graceful": "^1.0.1",
    "gulp": "^3.9.1",
    "gulp-cucumber": "0.0.22",
    "gulp-mocha": "^3.0.1",
    "gulp-webdriver": "^2.0.3",
    "minimatch": "^3.0.3",
    "minimist": "^1.2.0",
    "mocha-each": "^1.0.3",
    "mocha-teamcity-reporter": "^1.1.1",
    "moment": "^2.17.1",
    "request": "^2.81.0",
    "request-promise": "^4.1.1",
    "teamcity-properties": "^1.1.0",
    "url-join": "^1.1.0",
    "uuid": "^3.0.1",
    "wdio-cucumber-framework": "^0.2.16",
    "wdio-mocha-framework": "^0.5.9",
    "wdio-selenium-standalone-service": "0.0.8",
    "wdio-spec-reporter": "0.0.5",
    "wdio-teamcity-reporter": "^1.1.1",
    "webdriverio": "^4.6.2",
    "winston": "^2.3.1"
  },
  "devDependencies": {
    "eslint": "^3.16.1",
    "eslint-config-airbnb-base": "^11.1.0",
    "eslint-plugin-import": "^2.2.0"
  }

获得与wdio相关的最新npm模块。它对于任何UI测试都是一致的(mocha和黄瓜,我们现在都使用它们)。我们还没有尝试降级Chrome,但很快就可能需要降级。

  

注意

     
      
  1. 在github上向用户miroslawmajka提供信用
  2.   
  3. 我有类似的问题,所以我正在使用他们的错误描述和解决方案
  4.   

1 个答案:

答案 0 :(得分:1)

解决方案:通过将此JSON添加到配置文件

来更新chromedriver

1。以下是chromedriver

的配置

对于那些有兴趣将 selenium-standalone 服务与 WebdriverIO 一起使用的人,我们修改了 wdio.conf.js 以使用以下陈述:

{
    services: ['selenium-standalone'],
    seleniumLogs: './context/selenium-logs',
    seleniumArgs: {
        drivers: {
            chrome: {
                version: 2.28,
                baseURL: 'https://chromedriver.storage.googleapis.com'
            }
        }
    },
    seleniumInstallArgs: {
        drivers: {
            chrome: {
                version: 2.28,
                baseURL: 'https://chromedriver.storage.googleapis.com'
            }
        }
    }
}

这适用于我们使用最新版Chrome的设置。感谢您的提示,但我们不得不采用不同的方式,因为我们使用 wdio-selenium-standalone-service 来管理Selenium。

2。这是所有浏览器的配置

services: ['selenium-standalone'],
seleniumLogs: './context/selenium-logs',
seleniumArgs: {
    drivers: {
        // chrome: {
        //     version: 2.28,
        //     baseURL: 'https://chromedriver.storage.googleapis.com'
        // },
        chrome: {
            // check for more recent versions of chrome driver here:
            // http://chromedriver.storage.googleapis.com/index.html
            version: '2.33',
            //arch: process.arch,
            baseURL: 'https://chromedriver.storage.googleapis.com'
        },
        ie: {
            // check for more recent versions of internet explorer driver here:
            // http://selenium-release.storage.googleapis.com/index.html
            version: '3.6.0',
            //arch: 'ia32',
            baseURL: 'https://selenium-release.storage.googleapis.com'
        },
        firefox: {
            // check for more recent versions of gecko  driver here:
            // https://github.com/mozilla/geckodriver/releases
            version: '0.19.0',
            //arch: process.arch,
            baseURL: 'https://github.com/mozilla/geckodriver/releases/download'
        }
    }
},
seleniumInstallArgs: {
    drivers: {
        // chrome: {
        //     version: 2.28,
        //     baseURL: 'https://chromedriver.storage.googleapis.com'
        // },
        chrome: {
            // check for more recent versions of chrome driver here:
            // http://chromedriver.storage.googleapis.com/index.html
            version: '2.33',
            //arch: process.arch,
            baseURL: 'https://chromedriver.storage.googleapis.com'
        },
        ie: {
            // check for more recent versions of internet explorer driver here:
            // http://selenium-release.storage.googleapis.com/index.html
            version: '3.6.0',
            //arch: 'ia32',
            baseURL: 'https://selenium-release.storage.googleapis.com'
        },
        firefox: {
            // check for more recent versions of gecko  driver here:
            // https://github.com/mozilla/geckodriver/releases
            version: '0.19.0',
            //arch: process.arch,
            baseURL: 'https://github.com/mozilla/geckodriver/releases/download'
        }
    }
},