Skip to content

Instantly share code, notes, and snippets.

@madyasiwi
Last active February 4, 2018 12:18
Show Gist options
  • Save madyasiwi/7f596a28297d5abc4aded6b2f6588061 to your computer and use it in GitHub Desktop.
Save madyasiwi/7f596a28297d5abc4aded6b2f6588061 to your computer and use it in GitHub Desktop.
Basic Django functional test with Selenium
"""
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