Skip to content

Instantly share code, notes, and snippets.

@DylanLacey
Last active July 20, 2016 06:25
Show Gist options
  • Save DylanLacey/094532b6a4a2bc37c87645277c0c7565 to your computer and use it in GitHub Desktop.
Save DylanLacey/094532b6a4a2bc37c87645277c0c7565 to your computer and use it in GitHub Desktop.
source "http://www.rubygems.org"
gem "selenium-webdriver"
## Have in a directory with Gemfile.
## Run `gem install bundler && bundle install` beforehand.
## Start a Marionette-enabled Selenium Server and change server_url to match (line 8).
## Then run this script with `bundle exec ruby test_script.rb`.
require "selenium/webdriver"
def server_url
"http://127.94.0.1:4444/wd/hub"
end
def caps
caps = Selenium::WebDriver::Remote::Capabilities.firefox marionette: true
end
driver = Selenium::WebDriver.for :remote, :url => server_url, :desired_capabilities => caps
driver.navigate.to "http://google.com"
driver.find_element :tag_name, "h1"
driver.execute_script "window.open()"
puts driver.window_handles
driver.quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment