Nis*_*sal 5 ruby watir selenium-chromedriver centos7
我对 Centos7 相当陌生,并尝试在以下环境中开发浏览器自动化的解决方案:
操作系统:Centos7 Ruby:2.6 Watir 浏览器: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
Run Code Online (Sandbox Code Playgroud)
出现错误:
`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)
Run Code Online (Sandbox Code Playgroud)
我在网上找到了多个建议修改 chrome 选项的解决方案,例如:
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
Run Code Online (Sandbox Code Playgroud)
但我不知道在哪里设置这些。我能找到的最近的答案是这里提供的答案:How do I pass options to the Selenium Chrome driver using Python?
谁能帮我一步步解决这个问题吗?
也面临类似的问题,但使用 npm 和量角器配置,但我想解决方案会类似。您必须在 Linux 系统中安装 chrome 浏览器。
chromedriver 只是一个为使用 chromebrowser 运行测试用例而编写的包装器。
另外,如果安装了 google-chrome,您可能需要检查它安装在基于 Linux 的操作系统中的路径,预期路径位于 /usr/bin/google-chrome 下。该文件通常是 chrome 实际二进制文件的链接。
希望这有帮助
| 归档时间: |
|
| 查看次数: |
6032 次 |
| 最近记录: |