Mercurial > org-tools
comparison 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 |
comparison
equal
deleted
inserted
replaced
8:73beed20f7de | 9:d09937a6cb4b |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 from selenium import webdriver | |
4 from selenium.common.exceptions import NoSuchElementException | |
5 from selenium.webdriver.common.keys import Keys | |
6 import time | |
7 | |
8 browser = webdriver.Firefox() # Get local session of firefox | |
9 browser.get("http://www.yahoo.com") # Load page | |
10 assert "Yahoo!" in browser.title | |
11 elem = browser.find_element_by_name("p") # Find the query box | |
12 elem.send_keys("seleniumhq" + Keys.RETURN) | |
13 time.sleep(0.2) # Let the page load, will be added to the API | |
14 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() |