错误:未知错误:使用watir执行ruby脚本时,DevToolsActivePort文件不存在

问题描述 投票:1回答:1

我是Centos7的新手,并尝试在以下环境中开发浏览器自动化解决方案:

操作系统:Centos7 Ruby:2.6 Watir浏览器:谷歌浏览器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?

任何人都可以帮助我逐步解决它吗?

ruby selenium-chromedriver centos7 watir
1个回答
1
投票

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

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

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

希望如此有帮助

© www.soinside.com 2019 - 2024. All rights reserved.