Last active
August 25, 2015 20:08
-
-
Save aaltat/ff568e08962bde193a8e to your computer and use it in GitHub Desktop.
This file contains 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
from selenium import webdriver | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.common.by import By | |
from selenium.webdriver.support import expected_conditions as EC | |
driver = webdriver.Chrome() | |
driver.get('http://www.w3schools.com/js/tryit.asp?filename=tryjs_prompt') | |
driver.switch_to_frame('iframeResult') | |
element = WebDriverWait(driver, 10).until( | |
EC.presence_of_element_located( | |
(By.XPATH, '//button[text()="Try it"]'))) | |
element.click() | |
wait = WebDriverWait(driver, 10) | |
alert = wait.until(EC.alert_is_present()) | |
try: | |
print alert.text | |
alert.dismiss() | |
finally: | |
driver.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment