Mercurial > org-tools
view sample.py @ 10:83e16df2288a
still experimenting
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 25 Oct 2011 07:52:02 -0700 |
parents | d09937a6cb4b |
children |
line wrap: on
line source
1 #!/usr/bin/env python3 from selenium import webdriver4 from selenium.common.exceptions import NoSuchElementException5 from selenium.webdriver.common.keys import Keys6 import time8 browser = webdriver.Firefox() # Get local session of firefox9 browser.get("http://www.yahoo.com") # Load page10 assert "Yahoo!" in browser.title11 elem = browser.find_element_by_name("p") # Find the query box12 elem.send_keys("seleniumhq" + Keys.RETURN)13 time.sleep(0.2) # Let the page load, will be added to the API14 try:15 browser.find_element_by_xpath("//a[contains(@href,'http://seleniumhq.org')]")16 except NoSuchElementException:17 assert 0, "can't find seleniumhq"18 #browser.close()