Created
November 24, 2016 19:11
-
-
Save vasekch/13b6beb9f382216a1fb064d23bc41b6a 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
from selenium import webdriver | |
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary | |
from selenium.webdriver.common.by import By | |
from selenium.common.exceptions import * | |
from selenium.webdriver.support.ui import WebDriverWait | |
from selenium.webdriver.support import expected_conditions as EC | |
binary = FirefoxBinary(r'C:\Program Files (x86)\Mozilla Firefox\firefox.exe') | |
browser = webdriver.Firefox(firefox_binary=binary) | |
#browser = webdriver.Firefox() | |
browser.get('http://seleniumhq.org/') | |
try: | |
el = browser.find_element_by_class_name('downloadBox') | |
el.click() | |
re = WebDriverWait(browser, 2).until( | |
EC.text_to_be_present_in_element((By.TAG_NAME, 'h2'), 'Doownloads') | |
) | |
print("Hooray, we are on Downloads page") | |
except TimeoutException: | |
print("Sorry, it didn't work") | |
finally: | |
browser.quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment