Skip to content

Instantly share code, notes, and snippets.

@gromin
Created July 10, 2012 10:46
Show Gist options
  • Save gromin/3082623 to your computer and use it in GitHub Desktop.
Save gromin/3082623 to your computer and use it in GitHub Desktop.
How to use various remote selenium drivers with Cucumber
# This should be placed inside features/support/env.rb
# So we could specify at command prompt desired remote address and browser, e.g.:
# be cucumber REMOTE=true REMOTE_BROWSER=ie REMOTE_ADDR=192.168.1.1
# But there are some peculiarities which should be further investigated:
# * chrome needs chromedriver executable
# * opera loses focus and no further execution possible
# * it's impossible to attach a file to remote browser in file-handling scenarios
if ENV['REMOTE'] == 'true'
case
when ENV['REMOTE_BROWSER'] == 'ie'
caps = Selenium::WebDriver::Remote::Capabilities.internet_explorer
when ENV['REMOTE_BROWSER'] == 'chrome'
caps = Selenium::WebDriver::Remote::Capabilities.chrome
when ENV['REMOTE_BROWSER'] == 'opera'
caps = Selenium::WebDriver::Remote::Capabilities.opera
else
caps = Selenium::WebDriver::Remote::Capabilities.firefox
end
Capybara.register_driver :remote do |app|
Capybara::Selenium::Driver.new(app, :browser => :remote, :url => 'http://'+ENV['REMOTE_ADDR']+':4444/wd/hub', :desired_capabilities => caps)
end
Capybara.default_driver = :remote
Capybara.javascript_driver = :remote
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment