Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add Selenium slide.

  • Loading branch information...
commit 4017e509dcec0a817a98a484ef5bbe022ef3fa03 1 parent 31adbd2
@carljm authored
Showing with 49 additions and 0 deletions.
  1. +49 −0 views/40_selenium.md
View
49 views/40_selenium.md
@@ -0,0 +1,49 @@
+<!SLIDE>
+
+# In-browser testing #
+
+.notes More and more functionality depends on both JS and server. Needs to be tested too.
+
+<!SLIDE incremental>
+
+## Is easier than you think. ##
+
+* Especially in Django 1.4.
+
+* `pip install selenium`
+
+* `LiveServerTestCase`
+
+<!SLIDE smaller>
+
+
+ @@@ python
+ from django.test import LiveServerTestCase
+ from selenium.webdriver.firefox.webdriver import WebDriver
+
+ class MySeleniumTests(LiveServerTestCase):
+
+ @classmethod
+ def setUpClass(cls):
+ cls.selenium = WebDriver()
+ super(MySeleniumTests, cls).setUpClass()
+
+ @classmethod
+ def tearDownClass(cls):
+ super(MySeleniumTests, cls).tearDownClass()
+ cls.selenium.quit()
+
+ def test_login(self):
+ self.selenium.get(
+ "%s%s" % (self.live_server_url, "/login/"))
+ username_input = self.selenium.find_element_by_name(
+ "username")
+ username_input.send_keys("myuser")
+ password_input = self.selenium.find_element_by_name(
+ "password")
+ password_input.send_keys("secret")
+ self.selenium.find_element_by_xpath(
+ '//input[@value="Log in"]').click()
+
+
+.notes LiveServerTestCase runs the development server in a separate thread.
Please sign in to comment.
Something went wrong with that request. Please try again.