我对Centos7还是陌生的,并尝试在以下环境中开发用于浏览器自动化的解决方案:
操作系统:Centos7 红宝石:2.6 瓦蒂尔 浏览器:Google Chrome 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?
有人可以帮助我逐步解决此问题吗?
答案 0 :(得分:1)
也面临类似的问题,但是使用npm和量角器配置,但是我猜解决方案将是相似的。您必须在Linux系统中安装chrome浏览器。
chromedriver只是一个包装,用于使用chromebrowser运行测试用例。
此外,如果安装了google-chrome,则可能要检查其路径是否已安装在基于linux的操作系统中,预期路径在/ usr / bin / google-chrome下。该文件通常是chrome实际二进制文件的链接。
希望如此有帮助