首页 > 解决方案 > Watir 的 browser.refresh 给出“拒绝访问”

问题描述

我正在我的项目中探索 Watir。它在第一次尝试 URL 时工作得很好,但是当我导航到另一个 URL 或者我只是刷新现有的 Watir 的浏览器(通过命令和手动刷新)时,它会显示ACCESS DENIED Please verify you are a human

我已经用谷歌搜索了这个并在我的代码中添加了无头,但这没有用。

这就是我在 Rails 控制台中尝试的内容:

# Headless initialized and started
> headless = Headless.new
> headless.start

# Watir object initialized and navigated
> browser = Watir::Browser.new
> browser.goto 'https://www.pepboys.com/'

# Typed `browser` in console, got the output
> browser

`WARN Selenium [DEPRECATION] Selenium::WebDriver::Error::NoAlertPresentError is deprecated. Use Selenium::WebDriver::Error::NoSuchAlertError (ensure the driver supports W3C WebDriver specification) instead.
 => #<Watir::Browser:0x..f80f33b9a75f7d034 url="https://www.pepboys.com/" title="**Pep Boys Tires, Auto Parts, Auto Repair & Service and Car Accessories**">`

# Now when refreshing `browser`

> browser.refresh

# Typed `browser` in console, got the output

> browser

`WARN Selenium [DEPRECATION] Selenium::WebDriver::Error::NoAlertPresentError is deprecated. Use Selenium::WebDriver::Error::NoSuchAlertError (ensure the driver supports W3C WebDriver specification) instead.
 => #<Watir::Browser:0x..f80f33b9a75f7d034 url="https://www.pepboys.com/" title="**Access to this page has been denied.**">`

两者browser都有不同的标题,其中一个给出站点的标题,另一个给出拒绝访问的消息。

拜托,谁能帮我解决我在这里做错了什么或遗漏了什么?

标签: rubyruby-on-rails-5selenium-chromedriverwatir

解决方案


推荐阅读