Write your test code with the functions/methods/classes you wish existed, not the ones you've been given. For example, don't write this:
self.driver.get(self.live_server_url + reverse("contact_form"))
self.driver.find_element_by_css_selector("#id_email").send_keys("[email protected]")
self.driver.find_element_by_css_selector("#id_message").send_keys("Hello")
self.driver.find_element_by_css_selector("input[type=submit]").click()
WebDriverWait(self.driver, 10).until(lambda driver: driver.find_element_by_css_selector("body"))
That looks very tedious! Write this instead:
self.get_url("contact_form")
self.fill({
"#id_email": "[email protected]",
"#id_message": "Hello",
})
self.submit("input[type=submit]")
– Luke Plant, https://lukeplant.me.uk/blog/posts/test-smarter-not-harder/