首页 > 解决方案 > 打开新标签后,ruby watir 中的无头 chrome 浏览器没有响应

问题描述

我在我的 linux 服务器上使用 chrome headless 进行网页抓取。我收到Selenium::WebDriver::Error::TimeOutError: timeout错误

这是我的代码:

Selenium::WebDriver::Chrome.driver_path = "/usr/local/bin/chromedriver"
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--ignore-certificate-errors')
options.add_argument('--disable-popup-blocking')
options.add_argument('--disable-translate')
options.add_argument('--headless')
browser =  Watir::Browser.new :chrome, options: options

browser.goto 'www.abc.com'
browser.link(text: 'hello').click!  # opens in new window
browser.windows.last.use
browser.url  # FAILING AT THIS POINT

错误

Selenium::WebDriver::Error::TimeOutError: timeout
  (Session info: headless chrome=84.0.4147.105)
  (Driver info: chromedriver=2.41.578700 

标签: rubyseleniumwatirgoogle-chrome-headless

解决方案


推荐阅读