1👍
✅
Each instance of Selenium is independent and starts with a clean history and no cookie. You could simply implement a login page object:
class CreateListingTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
PageLogin(self.driver) \
.visit() \
.login(name, password)
def test_createListing(self):
driver = self.driver
*** continue with test method ***
class PageLogin(object):
url = "http://127.0.0.1:8000/"
def __init__(self, driver):
self.driver = driver
def visit(self):
self.driver.get(self.url)
...
return self
def login(self, name, password):
...
return self
def logout(self):
...
return self
Source:stackexchange.com