1

I tried to execute a simple browser test

require 'rubygems'
require 'watir-webdriver'
b = Watir::Browser.new :firefox
b.goto 'http://www.google.com/'

The browser launched and closed immediately throwing the following error

c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:25:in `initialize': HTTP request path is empty (ArgumentError)
    from c:/ruby22/lib/ruby/2.2.0/net/http/request.rb:14:in `initialize'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:95:in `new'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:95:in `new_request_for'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:57:in `request'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/default.rb:88:in `request'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/http/common.rb:59:in `call'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:649:in `raw_execute'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:123:in `create_session'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/remote/bridge.rb:87:in `initialize'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/bridge.rb:55:in `initialize'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `new'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `for'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver.rb:84:in `for'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
    from test.rb:3:in `new'
    from test.rb:3:in `<main>'

HTTP request path is empty means what? is the calling parameters changed in new versions of watir?

Anyone faced similar problem?

My System is Windows 7 64 bit, I am running behind a proxy, the browser already configured with a proxy

---EDIT---

I have introduced a trailing slash, but I am getting a new error now and also getting the previous error, every time I have to change the code and save it to get this error

c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:90:in `connect_until_stable': unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:55:in `block in launch'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/socket_lock.rb:43:in `locked'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/launcher.rb:51:in `launch'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/firefox/bridge.rb:43:in `initialize'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `new'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver/common/driver.rb:53:in `for'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/selenium-webdriver-2.53.4/lib/selenium/webdriver.rb:84:in `for'
    from c:/ruby22/lib/ruby/gems/2.2.0/gems/watir-webdriver-0.9.1/lib/watir-webdriver/browser.rb:46:in `initialize'
    from test.rb:8:in `new'
    from test.rb:8:in `<main>'

---EDIT---

I have downloaded the geckodriver v0.10.0 from https://github.com/mozilla/geckodriver/releases and copy pasted the geckodriver.exe in to the firefox folder and also added the firefox folder to the PATH

I installed the selenium-webdriver beta version 3.0.0.beta2.1

But still I am getting the same error

c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:25:in `initialize': HTTP request path is empty (ArgumentError)

I have also tried installing the Firefox ESR version and added to PATH which is also not working

---EDIT---

I opened the file c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb

and introduced print statement as follows

print "\n"
print uri_or_path

if URI === uri_or_path then
  print "\ncoming to if part\n"
  @uri = uri_or_path.dup
  host = @uri.hostname.dup
  host << ":".freeze << @uri.port.to_s if @uri.port != @uri.default_port
  @path = uri_or_path.request_uri
  raise ArgumentError, "no HTTP request path given" unless @path
else
  print "\ncoming to else part\n"
  @uri = nil
  host = nil
  raise ArgumentError, "no HTTP request path given" unless uri_or_path
  raise ArgumentError, "HTTP request path is empty" if uri_or_path.empty?
  @path = uri_or_path.dup
end

And I got the below output

/session
coming to else part


coming to else part

/shutdown
coming to else part
c:/ruby22/lib/ruby/2.2.0/net/http/generic_request.rb:29:in `initialize': HTTP request path is empty (ArgumentError)
Dickens A S
  • 3,824
  • 2
  • 22
  • 45
  • Try `http://www.google.com/` (include trailing slash). – Casper Jul 26 '16 at 12:40
  • http://stackoverflow.com/a/17709024/823617 – Casper Jul 26 '16 at 12:40
  • getting a new error now – Dickens A S Jul 27 '16 at 04:32
  • again I am getting the previous error :( – Dickens A S Jul 27 '16 at 04:44
  • 1
    See here: http://stackoverflow.com/questions/14303161/unable-to-obtain-stable-firefox-connection-in-60-seconds-127-0-0-17055 – Casper Jul 27 '16 at 08:54
  • 1
    When you get a strange error that you don't understand just google it. In many cases someone else will have had the problem already. Google is your secret bug hunting weapon. – Casper Jul 27 '16 at 08:55
  • It seems all the responses and posts given are 3 years older around 2013, that is why asked this again, so that if anyone faced this issue with latest firefox and latest ruby and latest watir-webdriver – Dickens A S Jul 28 '16 at 04:33
  • You can still find more recent information on it here: https://github.com/Galooshi/happo/issues/27 and here https://github.com/SeleniumHQ/selenium/issues/835 . The proposed solution seems to be to downgrade Firefox. If you can't get it to work then open an issue on Github. – Casper Jul 28 '16 at 06:45
  • What version of firefox? if it's one that has been very recently released, it might be that webdriver is having an issue connecting to the browser. In your initial code the error was on line 3, where it tries to create the browser object, which is what is failing, all the way down in the guts of webdriver. – Chuck van der Linden Jul 28 '16 at 22:46

2 Answers2

1

Try entering those commands in IRB, a line at a time. that will make it clearer where the failure is occuring

Your initial error indicated it was failing on line 3,which in your code above is where it tries to create a new instance of a browser object (which also launches firefox, and then tries to connect the browser object to the actual browser). If that's not working it's usually because you are not using a version of webdriver that supports your browser. Perhaps you have a brand new firefox, and need to update webdriver.

Sometimes there is a brief window after a new FF comes out (every 6 weeks) that introduced a breaking change, where we don't have an updated webdriver gem that supports that version.

Chuck van der Linden
  • 6,660
  • 2
  • 28
  • 43
0

Most likely you were seeing this due to a bug in Firefox 47.0. You need to update to Firefox 47.0.1 for it to work with Selenium 2.53.4.

titusfortner
  • 4,099
  • 2
  • 15
  • 29
  • I tried upgrading the firefox but, I think there is something else happening – Dickens A S Aug 08 '16 at 07:52
  • Yes, Firefox 48+ requires geckodriver to work. You can downgrade to 47.0.1 or use Firefox ESR - https://www.mozilla.org/en-US/firefox/organizations/ – titusfortner Aug 08 '16 at 14:48
  • I am not using 48+ I am only using 47.0.1 – Dickens A S Aug 09 '16 at 08:16
  • I also tried installing ESR version and also copy pasted `geckodriver.exe` in the firefox folder and added firefox folder to path, But again I am getting the `path is empty (ArgumentError)` – Dickens A S Aug 09 '16 at 08:20
  • Geckodriver is needed for 48+. If you are using 47.0.1, Watir 0.9.3 and Selenium 2.53.4 will work on Windows. If that combination isn't working, don't monkey with `net/http` just set `$DEBUG = true` and copy your output. – titusfortner Aug 09 '16 at 18:19