Skip to content

Instantly share code, notes, and snippets.

@pfote
Created February 15, 2013 13:11
Show Gist options
  • Save pfote/4960286 to your computer and use it in GitHub Desktop.
Save pfote/4960286 to your computer and use it in GitHub Desktop.
sample selenium webdriver test
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import Select
from selenium.common.exceptions import NoSuchElementException
import unittest, time, re
class FlwebBookingWebdriver(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.driver.implicitly_wait(30)
self.base_url = "http://flweb42.ypsilon.net/"
self.verificationErrors = []
def test_flweb_booking_webdriver(self):
driver = self.driver
driver.get(self.base_url + "/index.php?agent=fluegecomsws")
driver.find_element_by_id("depApt").clear()
driver.find_element_by_id("depApt").send_keys("FRA")
driver.find_element_by_id("dstApt").clear()
driver.find_element_by_id("dstApt").send_keys("MIA")
driver.find_element_by_name("submit").click()
driver.find_element_by_xpath("(//input[@name='submit'])[7]").click()
driver.find_element_by_link_text("KLENZ").click()
driver.find_element_by_xpath("//input[@value='Ticket kaufen']").click()
return self.is_element_present(By.LINK_TEXT, "Buchungsauftrag drucken")
def is_element_present(self, how, what):
try: self.driver.find_element(by=how, value=what)
except NoSuchElementException, e: return False
return True
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment