Created
May 15, 2014 18:38
-
-
Save tourdedave/16cff54b35942e90629c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'selenium-webdriver' | |
| require 'rspec-expectations' | |
| include RSpec::Matchers | |
| driver = Selenium::WebDriver.for :firefox | |
| driver.get 'http://the-internet.herokuapp.com/javascript_alerts' | |
| driver.find_elements(css: 'button')[1].click | |
| # to click the second button, [0] would click the first, and [2] (or [-1]) would click the last one | |
| popup = driver.switch_to.alert | |
| popup.accept | |
| result = driver.find_element(id: 'result').text | |
| expect(result).to eq('You clicked: Ok') | |
| driver.quit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment