Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
local selenium server
  • Loading branch information
tlevine committed Jun 4, 2012
1 parent 1e475fb commit 0587a5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions yoga/oh_just_use_selenium.py
Expand Up @@ -2,6 +2,7 @@
from dumptruck import DumpTruck
from lxml.html import fromstring
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from random import normalvariate
from time import sleep

Expand All @@ -15,7 +16,7 @@ def randomsleep():
def _driver_setup():
desired_capabilities = webdriver.DesiredCapabilities.FIREFOX
desired_capabilities['name'] = 'Yoga'
driver = webdriver.Remote(desired_capabilities=desired_capabilities,command_executor="http://thomaslevine.com:4444/wd/hub")
driver = webdriver.Remote(desired_capabilities=desired_capabilities,command_executor="http://localhost:4444/wd/hub")
return driver

def main():
Expand All @@ -40,13 +41,15 @@ def main():
button = driver.find_elements_by_id('ctl00_TemplateBody_ucTeacherDirectory_imgSearch')[0]
button.click()

#import pdb; pdb.set_trace()

while True:
spans = driver.find_elements_by_css_selector('#ctl00_TemplateBody_ucTeacherDirectory_gvTeacherDirectory tr td tr span')
print('Pausing for a few seconds to let the page load and be polite')
sleep(8)
randomsleep()

print [span.text for span in spans]
if spans[0].text != spans[1].text:
spans = driver.find_elements_by_css_selector('#ctl00_TemplateBody_ucTeacherDirectory_gvTeacherDirectory tr td tr span')
if len(spans) == 1:
raise ValueError('Only one navigation row')
elif spans[0].text != spans[1].text:
raise ValueError('Page navigation rows don\'t match.')

page_number = int(spans[0].text)
Expand All @@ -61,7 +64,4 @@ def main():
else:
a.click()

print('Pausing for a few seconds')
randomsleep()

main()
Binary file added yoga/selenium-server-standalone-2.21.0.jar
Binary file not shown.

0 comments on commit 0587a5c

Please sign in to comment.