[英]Unable to Attach remote debugger to Chrome headless in Selenium WebDriver
I'm running my E2E test cases using Selenium WebDriver with Chrome headless. 我正在使用Selenium WebDriver和无头的Chrome运行E2E测试用例。 this configuration working fine and able run test case.
此配置工作正常,并且能够运行测试用例。
My code looks like this: 我的代码如下所示:
const options = {
desiredCapabilities: {
port: PORT,
browserName: 'chrome',
chromeOptions: {
args: ['disable-infobars'
,'headless',
'disable-gpu',
],
//binary: '/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome'
binary: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
}
},
host: envConfig.seleniumUrl,
deprecationWarnings: false
};
this.browser = webdriverio
.remote(options)
.init()
.url(envConfig.appUrl)
.timeouts('script', 35000)
.timeouts('implicit', 35000);
Some of my test case failing so i am trying to attach chrome debugger using chrome launch option 我的一些测试用例失败,因此我尝试使用chrome启动选项附加chrome调试器
--remote-debugging-port=9222
--remote-debugging-port = 9222
https://developers.google.com/web/updates/2017/04/headless-chrome https://developers.google.com/web/updates/2017/04/headless-chrome
After adding remote debugging port flag My E2E failing and unable to start 添加远程调试端口标志后,我的E2E失败并且无法启动
const options = {
desiredCapabilities: {
port: PORT,
browserName: 'chrome',
chromeOptions: {
args: ['disable-infobars'
,'headless',
'disable-gpu',
'--remote-debugging-port=5552'
],
//binary: '/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome'
binary: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
}
},
host: envConfig.seleniumUrl,
deprecationWarnings: false
};
Error is 错误是
chrome not reachable
(Driver info: chromedriver=2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8),platform=Mac OS X 10.12.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 60.09 seconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:32.194Z'
System info: host: 'xxxxxx', ip: 'xxxxxx', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_161'
Driver info: driver.version: unknownError: An unknown server-side error occurred while processing the command.
at end() - hooks.js:47:25
how to fix this initialization issue and how to attach chrome dev tools with headless browser. 如何解决此初始化问题以及如何使用无头浏览器附加chrome开发工具。
There are a certain things which you need to consider as follows : 您需要考虑以下某些事项:
The chromeOptions passed as an argument should be uniform : 作为参数传递的chromeOptions应该统一:
Either they shouldn't include the --
as follows : 它们都不应该包含
--
,如下所示:
chromeOptions: { args: ['disable-infobars', 'headless', 'remote-debugging-port=9222' ]
Or all of them should include the --
as follows : 或所有这些都应包括
--
,如下所示:
chromeOptions: { args: ['--disable-infobars', '--headless', 'remote-debugging-port=9222' ]
As per the documentation remote-debugging-port should be configured to 9222 but not 5552
根据文档说明, remote-debugging-port应该配置为9222,而不是
5552
Try to keep off the unwanted lines of code by removing the commented lines : 尝试通过删除注释行来避免不必要的代码行:
//binary: '/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome'
Your Selenium Client version is 3.8.1 consider upgrading to version is v3.11.0 您的Selenium Client版本是3.8.1,请考虑升级到v3.11.0版本
@Test
. @Test
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.