首页 > 解决方案 > Selenium 在 chrome 84 中打开一个空白页,在 83 中工作正常

问题描述

我有以下代码在 chrome 83 中运行良好:

options = Selenium::WebDriver::Chrome::Options.new
options.add_argument("--disable-dev-shm-usage")

@invitation = Invitation.last

driver = Selenium::WebDriver.for :chrome, options: options
driver.manage.window.resize_to(*@invitation.dimensions)
driver.manage.timeouts.page_load = 10
driver.manage.timeouts.implicit_wait = 10 
driver.navigate.to invitation_image_url(@invitation.id, auth_token: @invitation.signed_id)

puts driver.page_source

现在,当我更新到 chrome 84 时,puts 返回一个空白页面而不是正确的页面:

"<html><head></head><body></body></html>"

为什么会发生,我如何让它在 chrome 84 中工作?

标签: rubyseleniumgoogle-chromeselenium-webdriverwatir

解决方案


当您更新 chrome 浏览器版本时,您应该根据该浏览器版本 https://chromedriver.chromium.org/downloads使用确切的 chromedriver 版本。在此链接中,您可以根据浏览器版本下载 chromdwriver exe(更改驱动程序后请刷新项目并运行它)


推荐阅读