2

I'm writing my test cases in Windows7 with Ruby (v1.9.3-p194).

Please, note that I want to specify Firefox binary path when using RemoteWebDriver, not FirefoxDriver.

Here is the command line I used to start Selenium server 2.25.0:

"%JAVA_HOME%\bin\java" -jar selenium-server-standalone.jar

And here is the Ruby code I used to initialize webdriver in my test suite:

@capa = Selenium::WebDriver::Remote::Capabilities.firefox
@capa[:firefox_binary] = "D:\FirefoxStuff\FF13.0.1\firefox.exe"
@remote_server_url = "http://127.0.0.1:4444/wd/hub"
@driver = Selenium::WebDriver.for(:remote, {:url => @remote_server_url, :desired_capabilities => @capa})

However when I execute the test case, an error says Selenium::WebDriver::Error::UnknownError: Cannot find firefox binary in PATH. So, it's obvious my binary path specification is not working.

Does anybody know how to achieve that besides setting my PATH?

1 Answer 1

1

I'm looking at this too. Seems there is a bit of problem in as_json in Selenium::WebDriver::Remote::Capabilities

firefox_binary get's re-written to firefoxBinary in the json call to webdriver grid, this means that the binary you have supplied does not register as it's assigned to the wrong key.

Chaning:

def as_json(opts = nil)
      hash = {}

      @capabilities.each do |key, value|
        case key
        when :platform
          hash['platform'] = value.to_s.upcase
        when :firefox_profile
          hash['firefox_profile'] = value.as_json['zip'] if value
        when :proxy
          hash['proxy'] = value.as_json if value
        when String
          hash[key] = value
        when Symbol
          hash[camel_case(key.to_s)] = value
        else
          raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class} / #{value.inspect}"
        end
      end

      hash
    end

to

def as_json(opts = nil)
      hash = {}

      @capabilities.each do |key, value|
        case key
        when :platform
          hash['platform'] = value.to_s.upcase
        when :firefox_profile
          hash['firefox_profile'] = value.as_json['zip'] if value
        when :proxy
          hash['proxy'] = value.as_json if value
        when :firefox_binary
          hash['firefox_binary'] = value
        when String
          hash[key] = value
        when Symbol
          hash[camel_case(key.to_s)] = value
        else
          raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class} / #{value.inspect}"
        end
      end

      hash
    end

Seems to work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.