Skip to content

Instantly share code, notes, and snippets.

@vasekch
Created November 24, 2016 19:11
Show Gist options
  • Save vasekch/13b6beb9f382216a1fb064d23bc41b6a to your computer and use it in GitHub Desktop.
Save vasekch/13b6beb9f382216a1fb064d23bc41b6a to your computer and use it in GitHub Desktop.
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