Skip to content

Instantly share code, notes, and snippets.

@jMyles
Created December 20, 2013 19:16
Show Gist options
  • Save jMyles/8059895 to your computer and use it in GitHub Desktop.
Save jMyles/8059895 to your computer and use it in GitHub Desktop.
The output of Selenium Builder exporting to Python/unittest after recording the activity of browsing to HackerNews and searching for "reelio."
from selenium.webdriver.firefox.webdriver import WebDriver
from selenium.webdriver.common.action_chains import ActionChains
import time, unittest
def is_alert_present(wd):
try:
wd.switch_to_alert().text
return True
except:
return False
class SearchForReelio(unittest.TestCase):
def setUp(self):
self.wd = WebDriver()
self.wd.implicitly_wait(60)
def test_SearchForReelio(self):
success = True
wd = self.wd
wd.get("https://news.ycombinator.com/")
wd.find_element_by_css_selector("center").click()
wd.find_element_by_name("q").click()
wd.find_element_by_name("q").clear()
wd.find_element_by_name("q").send_keys("reelio")
self.assertTrue(success)
def tearDown(self):
self.wd.quit()
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment