【问题标题】:Remote Selenium WebDriver not responding to Cucumber tests远程 Selenium WebDriver 不响应 Cucumber 测试
【发布时间】:2011-06-21 23:22:13
【问题描述】:

我已经在 cucumber 中设置了一个功能,并且正在使用 @javascript 标签让它在 selenium 中运行 在我的开发机器上,selenium 运行良好,但因为 webdriver 不支持 osx 上的本机事件,但我需要将它连接到运行 ubuntu 的虚拟机

我的 ubuntu 机器上运行了 webdriver 服务器

并像这样破解了我的水豚驱动程序,因此它像这样连接到远程服务器:

def browser
  unless @browser

    @browser = Selenium::WebDriver.for(:remote, :url => "http://192.168.1.69:4444/wd/hub", 
      :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.firefox)
    #@browser = Selenium::WebDriver.for(options.delete(:browser) || :firefox, options)
    at_exit do
      @browser.quit
    end
  end
  @browser
end

当我运行我的测试时,我的虚拟机上的控制台显示正在发生的事情并输出:

WebDriver 远程服务器:INFO 正在执行 ....

但就是这样,由于超时,一段时间后测试失败

有什么想法吗?

【问题讨论】:

    标签: macos ubuntu selenium cucumber capybara


    【解决方案1】:

    我不确定是什么导致了您的具体问题。但是您应该使用内置机制注册您的驱动程序:

    profile = Selenium::WebDriver::Firefox::Profile.new
    profile["network.http.use-cache"] = false
    
    Capybara.register_driver :firefox_ubuntu do |app|
      Capybara::Driver::Selenium.new(app,
        :browser => :remote,
        :url => 'http://192.168.1.69:4444/wd/hub',
        :desired_capabilities =>     Selenium::WebDriver::Remote::Capabilities.firefox(:firefox_profile => profile)
      )
    end
    

    然后你可以使用正常机制切换到它:

    Capybara.current_dirver :firefox_ubuntu
    

    【讨论】:

    • 啊太棒了,我也在寻找一种更好的方法来解决这两个问题,我该如何设置配置文件?我从另一篇文章中猜到了一半:profile = Selenium::WebDriver::Firefox::Profile.new 但后来我得到:未初始化的常量 Selenium
    • 我更新了我的答案以包括设置配置文件 - 请注意,这适用于 selenium-webdriver 0.1.3。我认为它不适用于以前的版本。
    猜你喜欢
    • 2011-12-23
    • 2016-06-24
    • 1970-01-01
    • 1970-01-01
    • 2017-02-20
    • 1970-01-01
    • 1970-01-01
    • 2012-10-01
    • 1970-01-01
    相关资源
    最近更新 更多