25.11.2014 Views

Conference Notes and Best Practices Release 1.3 ... - Read the Docs

Conference Notes and Best Practices Release 1.3 ... - Read the Docs

Conference Notes and Best Practices Release 1.3 ... - Read the Docs

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Conference</strong> <strong>Notes</strong> <strong>and</strong> <strong>Best</strong> <strong>Practices</strong>, <strong>Release</strong> <strong>1.3</strong><br />

pip install selenium<br />

Create a new Test case:<br />

from django.test import LiveServerTestCase<br />

from selenium import webdriver<br />

from selenium.webdriver.support.ui import Select<br />

import time<br />

class SomethingAppTest(LiveServerTestCase):<br />

fixtures = [’groups.json’]<br />

def setUp(self):<br />

self.browser = webdriver.Firefox()<br />

# Use factories to create objects<br />

def tearDown(self):<br />

self.browser.quit()<br />

def test_something(self):<br />

self.browser.get(self.live_server_url)<br />

self.browser.find_element_by_id(’clickme’).click()<br />

2.5.2 Testing Tid Bits<br />

• It’s a good idea to prime your test cases with data. Ei<strong>the</strong>r prime <strong>the</strong> test case with a fixture or better yet, an<br />

object factory.<br />

12 Chapter 2. <strong>Notes</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!