Skip to content

Instantly share code, notes, and snippets.

@aaltat
Last active August 25, 2015 20:08
Show Gist options
  • Save aaltat/ff568e08962bde193a8e to your computer and use it in GitHub Desktop.
Save aaltat/ff568e08962bde193a8e to your computer and use it in GitHub Desktop.
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