Beginning Selenium tests
authorCharles Connell <charles@connells.org>
Mon, 16 Dec 2013 02:47:47 +0000 (21:47 -0500)
committerCharles Connell <charles@connells.org>
Mon, 16 Dec 2013 02:47:47 +0000 (21:47 -0500)
reqs/dev.txt
test/selenium/add_course.py [new file with mode: 0644]

index 0bd6378b7ba8c2b5f3a3230ac3f29c1b42714a28..3bf4f04d2705e98f95118746041d5ddda27349cb 100644 (file)
@@ -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 (file)
index 0000000..2a931ee
--- /dev/null
@@ -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")