简体   繁体   English

无法将远程调试器连接到Selenium WebDriver中无头的Chrome

[英]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 : 您需要考虑以下某些事项:

  • Within the desiredCapabilities you have passed the arguments disable-gpu but as per Getting Started with Headless Chrome this option is for Windows platform only. desirableCapabilities中,您已经传递了参数disable-gpu,但是根据Headless Chrome入门,此选项仅适用于Windows平台。
  • 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版本

  • Your ChromeDriver version is 2.36 which supports Chrome v63-65 consider upgrading to version is v2.37 您的ChromeDriver版本是2.36 ,它支持Chrome v63-65,请考虑升级到v2.37
  • Your ChromeBrowser version is unknown to us consider upgrading to version is v65.0 . 我们未知您的ChromeBrowser版本,因此考虑将其升级为v65.0版本。
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only. 通过IDE 清理 项目工作区 ,并仅使用必需的依赖项重建项目。
  • Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite . 在执行测试套件之前和之后,使用CCleaner工具清除所有操作系统琐事。
  • If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client . 如果您的基本Web客户端版本太旧,请通过Revo Uninstaller卸载它,并安装最新的GA和Web Client的发行版本。
  • Execute your @Test . 执行您的@Test

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Selenium webdriver 无法在 Chrome 无头模式下定位元素 - Selenium webdriver is unable to locate element in chrome headless mode 无法通过 Heroku 中的 Selenium webdriver(Java) 调用无头 chrome 驱动程序 - Unable to invoke headless chrome driver through Selenium webdriver(Java) in Heroku 使用 Headless Chrome Webdriver 运行 Selenium - Running Selenium with Headless Chrome Webdriver --headless 不是 selenium python chrome webdriver 中的一个选项 - --headless is not an option in chrome webdriver for selenium python 如何在Chrome扩展程序中将调试器与硒连接在一起? - How to attach debugger in chrome extension along with selenium? 无法使用 Selenium Webdriver java 在 Linux 机器上运行 Headless Chrome 浏览器 - Unable to run Headless Chrome Browser on Linux Machine using Selenium Webdriver java 由于“无法连接到渲染器”错误,Selenium Webdriver测试无法在Chrome上无头运行 - Selenium Webdriver tests not running on Chrome headless due to “unable to connect to renderer” error 如何使用硒在无头铬中取消设置navigator.webdriver? - How to unset navigator.webdriver in headless chrome using selenium? 使用带有Headless Chrome和Selenium Webdriver,macOS,Rails,Capybara的acceptInsecureCerts - Using acceptInsecureCerts with Headless Chrome and Selenium Webdriver, macOS, Rails, Capybara 在Selenium WebDriver中启动Chrome Headless仍会导致浏览器窗口空白 - Launching Chrome Headless in Selenium WebDriver still results in a blank browser window
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM