我们已经在Google Chrome和Firefox上使用Selenium成功运行了Ruby on Rails 2的集成测试。然而,我们最近升级到Ruby on Rails 3,在创建Google Chrome webdriver示例时遇到了问题。
当我们尝试创建时,我们得到以下堆栈:
irb(main):002:0> profile = Selenium::WebDriver::Chrome::Profile.new
translate])#<Selenium::WebDriver::Chrome::Profile:0x64f2fd0 @extensions=[], @model=nil>
irb(main):003:0> profile['download.prompt_for_download'] = false
false
irb(main):004:0> driver = Selenium::WebDriver.for(:chrome, :profile => profile, :switches => %w[--ignore-certificate-errors --disable-popup-blocking --disable-translate])
ArgumentError: wrong number of arguments (0 for 1)
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/platform.rb:157:in `open'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/platform.rb:157:in `ip'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/platform.rb:170:in `interfaces'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/port_prober.rb:23:in `free?'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/port_prober.rb:5:in `above'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/chrome/service.rb:33:in `default_service'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/chrome/bridge.rb:14:in `initialize'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/driver.rb:37:in `new'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver/common/driver.rb:37:in `for'
from /var/www/myapp/shared/bundle/ruby/1.8/gems/selenium-webdriver-2.27.2/lib/selenium/webdriver.rb:67:in `for'
from (irb):4
字符串
有什么建议吗?
3条答案
按热度按时间s8vozzvw1#
当我在Gemfile中包含一个gem时,我看到了这一点,其中包含 backports gem作为其依赖项的一部分。backports gem重写了一些Ruby 1.8内部,覆盖了
UDPSocket
核心类的一部分。尝试摆脱 backports gem并尝试一下。6fe3ivhb2#
ChromeDriver安装:
请从“http://chromedriver.storage.googleapis.com/index.html?path=2.8/”下载Chromedriver 2.x。
解压缩文件并将其保存在任意驱动器上的文件夹中。通过以下步骤设置 path:
运行 selenium 测试:
现在运行你的Selenium测试,它将在Chrome浏览器中运行。
示例代码
字符串
注意:您需要为最新版本的Chrome浏览器安装最新的chromedriver
v2g6jxz63#
这是由于与
backports
gem的干扰以及socket
库重用IO.open
(尽管它改变了接口)的事实造成的。将
backports
升级到v2.6.7 or above应该可以解决这个问题。