Skip to content

Instantly share code, notes, and snippets.

@shoesCodeFor
Last active April 24, 2019 16:14
Show Gist options
  • Save shoesCodeFor/5512803d4f859fd56a0b55fb44d4f185 to your computer and use it in GitHub Desktop.
Save shoesCodeFor/5512803d4f859fd56a0b55fb44d4f185 to your computer and use it in GitHub Desktop.
Basic Chrome/Selenium login with Ruby
require "selenium-webdriver"
driver = Selenium::WebDriver.for :chrome
wait = Selenium::WebDriver::Wait.new(:timeout => 18)
driver.navigate.to "https://someloginsite.web"
sleep 2
element = driver.find_element(:class, "username")
element.send_keys "[email protected]"
pwd = driver.find_element(:class, "password")
pwd.send_keys "MyPasswords"
submit_btn = $driver.find_element(name: "submit")
submit_btn.click
sleep 3
puts $driver.title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment