【问题标题】:Watir-Webdriver, PhantomJS and URLs that redirect to httpsWatir-Webdriver、PhantomJS 和重定向到 https 的 URL
【发布时间】:2014-11-23 22:02:38
【问题描述】:

我在使用带有 Watir-Webdriver 的 PhantomJS 时遇到了麻烦。我有带有“http”方案的 URL,它返回 HTTP 301 Moved Permanently 并重定向到新的“https”位置。两个例子:

  1. http://make.crowdflower.com
  2. http://click.alfabank.ru

我写了一个脚本:

require 'watir-webdriver'
b = Watir::Browser.new :phantomjs, :args => ['--ignore-ssl-errors=true']
b.goto 'http://make.crowdflower.com'
puts b.title
puts b.url
b.close

输出是:

(empty line)
about:blank

版本是:Ruby 2.1.0、watir-webdriver 0.6.11、phantomjs 1.9.7。

我想知道为什么会这样。非常感谢任何建议。

【问题讨论】:

  • 我怀疑我提供给 PhantomJS 的参数是多余的,因为证书没有问题,但无论如何代码都不起作用。

标签: ruby ssl phantomjs watir-webdriver


【解决方案1】:

原因很可能是 POODLE 漏洞迫使网站删除 SSLv3 支持。由于 PhantomJS ssl-protocol 设置为tlsv1any

require 'watir-webdriver'
b = Watir::Browser.new :phantomjs, :args => ['--ssl-protocol=tlsv1']
b.goto 'http://make.crowdflower.com'
puts b.title
puts b.url
b.close

PhantomJS 1.9.8 默认使用 TLSv1。有关更多最新信息,请参阅this answer。请注意,bug in 1.9.8 可能会影响功能。最好坚持1.9.7直到2.0出来。

【讨论】:

  • 一段时间后我又遇到了同样的问题。我已经安装了最新版本的 PhantomJS,但现在它不能通过 watir-webdriver 导航到 https 链接。任何建议将不胜感激。
  • 只有 https 还是其他页面?它可能与bug in 1.9.8 相关,也可能与其他一百万件事有关。最简单的可能是坚持 1.9.7 直到 2.0 出来。
  • 抱歉,那是我的错。我写的方法省略了 PhantomJS 参数。当我重写它时,一切正常。再次感谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-12-15
  • 2016-03-12
  • 2014-01-01
  • 1970-01-01
  • 2011-12-11
  • 2017-07-15
相关资源
最近更新 更多