问题描述
注意:
提到这个重复的评论是为了当你维护自己的 chromedriver 和 selenium 安装时,但如果你使用 wdio-selenium-standalone-service
那些重复"的问题/解决方案不要没有帮助.希望这提供了上下文
The comments mentioning this as a duplicate are for when you're maintaining your own chromedriver and selenium installation, but if you use wdio-selenium-standalone-service
those "duplicate" questions/solutions don't help. Hopefully this gives context
截至今天,我们在运行自动化 UI 测试时遇到了一个主要问题:
We have a major problem running automated UI tests as of today:
[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 中使用这一行:
We use this line in our wdio.conf.js:
services: ['selenium-standalone']
这是我们的packages.json:
And this is our 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 测试(摩卡和黄瓜,我们目前都使用),它始终失败.我们还没有尝试降级 Chrome,但可能很快就会有必要.
Got the latest npm modules for wdio-related pieces. It fails consistently for any UI tests (mocha and cucumber and we use both at the moment). We have not tried downgrading Chrome but it might be a necessity soon.
注意
- 感谢 github 上的用户
miroslawmajka
- 我有类似的问题,所以我正在使用他们的错误描述和解决方案
推荐答案
解决方案:通过将此 JSON 添加到配置文件来更新 chromedriver
1.以下是仅 chromedriver 的配置
对于那些有兴趣通过 WebdriverIO 使用 selenium-standalone 服务的人,我们已经修改了我们的 wdio.conf.js 以使用以下陈述:
Solution: update chromedriver by adding this JSON to config file
1. The following is the configuration for just chromedriver
For those who are interested in using the selenium-standalone service with WebdriverIO we have modified our wdio.conf.js to use the following statements:
{
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,因此我们不得不以不同的方式进行处理.
And that works with our setup with the latest version of Chrome. Thank you for the tip but we had to go about it a different way as we are using wdio-selenium-standalone-service for managing Selenium.
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'
}
}
},
这篇关于WebdriverIO:如何修复错误“未知错误:无法获得自动化扩展"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!