微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails – 无法连接到Geckodriver

我试图用 Ruby on Rails运行Selenium的示例scirpt.我要用代理运行它.这是我的代码
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

我收到以下错误

/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)

有人能帮我吗…?我几个小时都在努力,找不到问题……真的不知道该怎么办.

环境:

Ubuntu 16.04 LTS,
Firefox 45.0,
rbenv 2.3.1

其他问题:有人知道Selenium Ruby on Rails的一些例子吗?我找不到真正的好东西…文档很差:(

解决方法

你有selenium-webdriver-3.0.0.beta3.1,仅适用于Firefox 48及更高版本(尚未正常工作).
回退到selenium-webdriver版本 2.53.4并再试一次.

原文地址:https://www.jb51.cc/ruby/270849.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐