我是Centos7的新手,正在尝试开发一个在以下环境中实现浏览器自动化的解决方案:
操作系统: Centos7 Ruby: 2.6Watir浏览器:Google Chrome72.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?
有没有人能帮我一步一步解决这个问题?
发布于 2019-05-19 18:00:06
也面临着类似的问题,但与npm和量角器配置,但我猜解决方案将是相似的。您必须在您的linux系统中安装chrome浏览器。
chromedriver只是一个包装器,用来使用chromebrowser来运行测试用例。
此外,如果安装了google-chrome,您可能需要检查路径,因为它安装在基于linux的操作系统中,预期的路径在/usr/bin/google-chrome下。这个文件通常是指向chrome的实际二进制文件的链接。
希望如此,这会有所帮助
https://stackoverflow.com/questions/54760863
复制相似问题