Skip to content

Instantly share code, notes, and snippets.

@ndmanvar
Created October 6, 2015 23:57
Show Gist options
  • Save ndmanvar/512a0e2c70ca1710e288 to your computer and use it in GitHub Desktop.
Save ndmanvar/512a0e2c70ca1710e288 to your computer and use it in GitHub Desktop.
# prereq: have sauce username and accesskey set as environment variables
# i.e. export SAUCE_USERNAME=YOUR_USERNAME
# export SAUCE_ACCESS_KEY=YOUR_ACCESS_KEY
require 'selenium-webdriver'
url = "http://#{ENV['SAUCE_USERNAME']}:#{ENV['SAUCE_ACCESS_KEY']}@ondemand.saucelabs.com:80/wd/hub".strip
browser = Selenium::WebDriver.for(:remote, :url => url,
:desired_capabilities => {
:browserName => 'firefox',
:version => '40',
:platform => 'Windows 7'
})
browser.manage.add_cookie({
:name => 'CookieName',
:value => 'CookieValue',
:path => '/',
:secure => false
})
puts "Printing out cookies : #{browser.manage.all_cookies}"
# go to URL / app where authentication was needed / prompted.
# i.e.
# browser.get 'http://yourwebsite.com'
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment