Last active
February 4, 2018 12:18
-
-
Save madyasiwi/7f596a28297d5abc4aded6b2f6588061 to your computer and use it in GitHub Desktop.
Basic Django functional test with Selenium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Basic example of Django functional test with Selenium. | |
Requirements: | |
- Python 3 | |
- Django 2 | |
- Selenium (with geckodriver) | |
""" | |
from urllib.parse import urljoin | |
from django.test import LiveServerTestCase | |
from selenium import webdriver | |
class BasicLiveTestCase(LiveServerTestCase): | |
def setUp(self): | |
super().setUp() | |
self.browser = webdriver.Firefox() | |
self.browser.implicitly_wait(2) | |
def tearDown(self): | |
self.browser.quit() | |
super().tearDown() | |
def test_homepage(self): | |
self.browser.get(urljoin(self.live_server_url, '/')) | |
self.assertEqual(self.browser.title, 'Hello, web!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment