ruby - Selenium Webdriver 无法创建 chrome webdriver 实例

标签 ruby selenium

我们一直在 chrome 和 firefox 上使用 Selenium 针对 Rails 2 成功运行集成测试。但是,我们最近升级到 Rails 3,在创建 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

有什么建议吗?

最佳答案

当我将一个包含“向后移植”gem 作为其依赖项的一部分的 gem 包含到我的 Gemfile 中时,我看到了这一点。 backports gem 重写了一些 Ruby 1.8 内部结构,它覆盖了部分 UDPSocket 核心类。尝试摆脱 backports gem 并试一试。

关于ruby - Selenium Webdriver 无法创建 chrome webdriver 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13848210/

相关文章:

ruby - 需要双服务器配置建议

javascript - Protractor 模式对话框返回 ng-repeater 的多个结果

java - NoClassDefFound错误: org/apache/http/conn/SchemePortResolver - Selenium

css - 关于不包含 class 或 id 属性的 css 选择器的 selenium 测试

ruby - 适用于 ruby​​ 的 aws-sdk。如何为实例分配公共(public)IP地址?

ruby-on-rails - rails 5 - 无法生成 rspec :install

ruby-on-rails - sidekiq 重试参数耗尽

ruby - ruby 语法错误,哈希中有多种语言

java - Selenium:强制测试人员在参数的特定值之间进行选择

java - 运行 Cucumber 测试时出现异常