From: Charles Connell Date: Mon, 16 Dec 2013 02:47:47 +0000 (-0500) Subject: Beginning Selenium tests X-Git-Tag: release-20150131~386^2~10^2~6 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c5977cdd2703adf0e93ec7a00cfb393933b2a7a1;p=oweals%2Fkarmaworld.git Beginning Selenium tests --- diff --git a/reqs/dev.txt b/reqs/dev.txt index 0bd6378..3bf4f04 100644 --- a/reqs/dev.txt +++ b/reqs/dev.txt @@ -7,3 +7,4 @@ django-extensions==1.0.3 # some extra debugging tools for manage.py # Testing requirements django-nose==1.1 coverage==3.6 +selenium==2.38.4 diff --git a/test/selenium/add_course.py b/test/selenium/add_course.py new file mode 100644 index 0000000..2a931ee --- /dev/null +++ b/test/selenium/add_course.py @@ -0,0 +1,40 @@ +from selenium import webdriver +from selenium.webdriver.common.by import By +from selenium.webdriver.common.keys import Keys +from selenium.webdriver.support import expected_conditions as EC +import unittest + +# Create a new instance of the Firefox driver +from selenium.webdriver.support.wait import WebDriverWait + +class AddCourseTest(unittest.TestCase): + + def setUp(self): + self.driver = webdriver.Firefox() + + def tearDown(self): + self.driver.close() + + def testSchoolName(self): + self.driver.get("http://localhost:8000") + + addCourseButton = self.driver.find_element_by_id("add-course-btn") + addCourseButton.click() + + schoolInput = self.driver.find_element_by_id("str_school") + + schoolInput.send_keys("harvard u") + + wait = WebDriverWait(self.driver, 10) + wait.until(EC.element_to_be_clickable((By.CLASS_NAME, "ui-menu-item"))) + + schoolInput.send_keys(Keys.DOWN) + + autocompleteMenuItem = self.driver.find_element_by_id("ui-active-menuitem") + autocompleteMenuItem.click() + + self.assertEqual(schoolInput.get_attribute("value"), "Harvard University") + + schoolId = self.driver.find_element_by_id("id_school") + + self.assertEqual(schoolId.get_attribute("value"), "1817")