【问题标题】:Error: unknown error: DevToolsActivePort file doesn't exist, when executing ruby script with watir错误:未知错误:使用 watir 执行 ruby​​ 脚本时,DevToolsActivePort 文件不存在
【发布时间】:2019-07-12 15:20:09
【问题描述】:

我对 Centos7 还很陌生,正在尝试在以下环境中开发浏览器自动化解决方案:

操作系统:Centos7 红宝石:2.6 瓦提尔 浏览器:谷歌浏览器 72.0.3626.109 驱动:ChromeDriver 2.46.628388

我的脚本:

require 'watir'

# Initialize the browser with the driver path
site="https://google.com"
browser = Watir::Browser.new :chrome
browser.goto site

得到错误:

`assert_ok': unknown error: Chrome failed to start: exited abnormally (Selenium::WebDriver::Error::UnknownError)
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.46.628388 (4a34a70827ac54148e092aafb70504c4ea7ae926),platform=Linux 3.10.0-957.5.1.el7.x86_64 x86_64)

我在网上找到了多个建议修改 chrome 选项的解决方案,例如:

chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')

但我不知道在哪里设置这些。我能到达的最近的答案是这里提供的答案:How do I pass options to the Selenium Chrome driver using Python?

谁能帮我逐步解决这个问题?

【问题讨论】:

  • chromedriver.chromium.org/capabilities 将为您提供有关 chrome 功能的背景知识。查看watir.com/watir-6-6,了解如何在watir 中使用它们。实例化浏览器时尝试Watir::Browser.new :chrome, :args => [ "--no-sandbox" ]...
  • 我尝试按照您的解释传递参数。但是,错误仍然相同:/usr/local/rvm/gems/ruby-2.6.0/gems/selenium-webdriver-3.141.0/lib/selenium/webdriver/remote/response.rb:69:in `assert_ok ': 未知错误: Chrome 无法启动: 异常退出 (Selenium::WebDriver::Error::UnknownError) (未知错误: DevToolsActivePort 文件不存在) (进程从 chrome 位置 /usr/bin/google-chrome不再运行,因此 ChromeDriver 假设 Chrome 已崩溃。)
  • 嗯...可能想尝试最新的 chrome + chromedriver。或者查看 chromedriver 日志:chromedriver.chromium.org/logging。祝你好运。

标签: ruby selenium-chromedriver centos7 watir


【解决方案1】:

也面临类似的问题,但使用 npm 和量角器配置,但我想解决方案会相似。您必须在您的 linux 系统中安装 chrome 浏览器。

chromedriver 只是一个为使用 chromebrowser 运行测试用例而编写的包装器。

此外,如果安装了 google-chrome,您可能需要检查路径是否安装在基于 linux 的操作系统中,预期路径位于 /usr/bin/google-chrome 下。该文件通常是 chrome 的实际二进制文件的链接。

希望对你有帮助

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-08-01
    • 2018-11-20
    • 1970-01-01
    • 2019-05-15
    • 1970-01-01
    • 2020-05-03
    • 2022-09-30
    相关资源
    最近更新 更多