Remote Selenium WebDriver not responding to Cucumb

2019-06-13 15:43发布

问题:

I've set up a feature in cucumber and am using the @javascript tag to have it run in selenium On my dev machine selenium runs fine but because webdriver doesn't support native events on osx yet I need to hook it up to a virtual machine running ubuntu

I've got webdriver server running on my ubuntu machine

and hacked my capybara driver like so it connect to the remote server like so:

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

When I running my test the console on my virtual machine shows somethings going on and outputs:

WebDriver remote server: INFO executing ....

But thats it the test fails after some time due to timeout

Any ideas?

回答1:

I am not sure what is causing your specific problem. But you should register your driver using the built in mechanism:

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

and then you can switch to it using the normal mechanism:

Capybara.current_dirver :firefox_ubuntu