我对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
出现错误:
`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')
但我不知道在哪里设置它们。我能找到的最近的解决方法是这里提供的答案:如何使用Python向Selenium Chrome驱动程序传递选项?
有人能否请以逐步方式帮助我解决这个问题?