Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to connect to Geckodriver

I'm trying to run the example scirpt of Selenium with Ruby on Rails. I've to run it with a proxy. Here's my code:

require 'rubygems'
require 'bundler/setup'

# require your gems as usual
require "selenium-webdriver"

Selenium::WebDriver::Firefox.path = "/home/marc/Documents/firefox/firefox"
profile = Selenium::WebDriver::Firefox::Profile.new
proxy = Selenium::WebDriver::Proxy.new(:http => nil)
profile.proxy = proxy
driver = Selenium::WebDriver.for :firefox, :profile => profile
driver.navigate.to "http://google.com"

element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit

puts driver.title

driver.quit

I got the following error:

/home/marc/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.0.0.beta3.1/lib/selenium/webdriver/common/service.rb:115:in `connect_until_stable': unable to connect to Mozilla geckodriver 127.0.0.1:4445 (Selenium::WebDriver::Error::WebDriverError)

Can someone help me...? I'm trying since hours and can't find the problem... Really don't know what to do.

Environment:

Ubuntu 16.04 LTS, Firefox 45.0, rbenv 2.3.1

Other question: Someone knows some example for Selenium + Ruby on Rails? I can't find really good stuff... the documentation is really poor :(

like image 406
Twinfriends Avatar asked Sep 26 '16 09:09

Twinfriends


People also ask

What is the minimum Firefox version needed for GeckoDriver?

Clients. Selenium users must update to version 3.11 or later to use geckodriver.

What is the difference between GeckoDriver and Firefox driver?

GeckoDriver is the link between Selenium tests and the Firefox browser. In other words, GeckoDriver is a proxy that interacts between W3C WebDriver-compatible clients and Gecko-based browsers like Firefox. Therefore, sometimes people often refer to it as Firefox driver when they mean it is the GeckoDriver.

Do you need Firefox and GeckoDriver?

The Firefox driver used in earlier versions of Mozilla Firefox will be discontinued, and only the GeckoDriver implementation would be used. Hence testers are forced to use GeckoDriver if they want to run automated tests on Mozilla Firefox version 47.0+.


1 Answers

As an addition to DarKy's solution with selenium version downgrade:

  • In the terminal change directory path to the directory where gem was installed
  • Run gem uninstall selenium-webdriver
  • Run gem install selenium-webdriver -v 2.53.4
like image 101
Andrii Vasyliev Avatar answered Oct 05 '22 13:10

Andrii Vasyliev