2

I'm having troubles with using PhantomJS with Watir-Webdriver. I have URLs with "http" scheme that return HTTP 301 Moved Permanently and redirect to a new "https" location. Two examples:

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

I wrote a script:

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

The output is:

(empty line)
about:blank

The versions are: Ruby 2.1.0, watir-webdriver 0.6.11, phantomjs 1.9.7.

I wonder why is it happening. Any advice is much appreciated.

Andrey Esperanza
  • 625
  • 1
  • 6
  • 11
  • I suspect that the argument I supply to PhantomJS is superfluous, because there's no problems with the certificates, but anyway the code doesn't work. – Andrey Esperanza Oct 27 '14 at 08:20

1 Answers1

7

The reason is very likely the POODLE vulnerability which forced websites to remove SSLv3 support. Since PhantomJS < v1.9.8 uses SSLv3 by default, the ssl handshake fails and the page doesn't load. You should set ssl-protocol either to tlsv1 or any:

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 uses TLSv1 by default. See this answer for more up-to-date information. Note that there is a bug in 1.9.8 which might impact functionality. It is best to stick to 1.9.7 until 2.0 comes out.

Community
  • 1
  • 1
Artjom B.
  • 61,146
  • 24
  • 125
  • 222
  • Some time later I faced the same problem again. I've installed the latest version of PhantomJS, but now it doesn't navigate to https links via watir-webdriver. Any advice would be much appreciated. – Andrey Esperanza Nov 23 '14 at 13:57
  • Only https or also other pages? It might be related to a [bug in 1.9.8](https://github.com/ariya/phantomjs/issues/12697), it might be a million other things. The easiest is probably stick to 1.9.7 until 2.0 comes out. – Artjom B. Nov 23 '14 at 14:01
  • Apologies, that was my fault. The method I wrote omitted the PhantomJS arguments. When I had rewritten it, everything worked. Thanks again. – Andrey Esperanza Nov 24 '14 at 14:18