Mercurial > org-tools
diff sample.py @ 9:d09937a6cb4b
trying to build something to automatically refresh the browser.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 25 Oct 2011 05:33:36 -0700 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/sample.py Tue Oct 25 05:33:36 2011 -0700 1.3 @@ -0,0 +1,18 @@ 1.4 +#!/usr/bin/env python 1.5 + 1.6 +from selenium import webdriver 1.7 +from selenium.common.exceptions import NoSuchElementException 1.8 +from selenium.webdriver.common.keys import Keys 1.9 +import time 1.10 + 1.11 +browser = webdriver.Firefox() # Get local session of firefox 1.12 +browser.get("http://www.yahoo.com") # Load page 1.13 +assert "Yahoo!" in browser.title 1.14 +elem = browser.find_element_by_name("p") # Find the query box 1.15 +elem.send_keys("seleniumhq" + Keys.RETURN) 1.16 +time.sleep(0.2) # Let the page load, will be added to the API 1.17 +try: 1.18 + browser.find_element_by_xpath("//a[contains(@href,'http://seleniumhq.org')]") 1.19 +except NoSuchElementException: 1.20 + assert 0, "can't find seleniumhq" 1.21 +#browser.close()