# HG changeset patch # User Goffi # Date 1607081766 -3600 # Node ID 84fb41b515a1adc6872f0fb8c4c7a96472139ce5 # Parent 42d6d00e4e8a01377152e810459a1792aa5b3d06 tests (e2e/libervia/conftest): new `log_in_account1_s2` fixture diff -r 42d6d00e4e8a -r 84fb41b515a1 tests/e2e/libervia/conftest.py --- a/tests/e2e/libervia/conftest.py Fri Dec 04 12:35:00 2020 +0100 +++ b/tests/e2e/libervia/conftest.py Fri Dec 04 12:36:06 2020 +0100 @@ -31,7 +31,7 @@ BASE_URL = f"https://{LIBERVIA_HOST}:{LIBERVIA_PORT_HTTPS}" SIZE_DESKTOP = (1024, 728) SIZE_MOBILE = (380, 640) -account_1_cookies = None +accounts_cookies = {} @pytest.hookimpl(tryfirst=True, hookwrapper=True) @@ -92,20 +92,26 @@ def nobody_logged_in(browser): browser.get_driver().delete_all_cookies() +def log_in(browser, account): + try: + account_cookies = accounts_cookies[account] + except KeyError: + browser.get_driver().delete_all_cookies() + browser.go_to("https://libervia.test:8443/login") + browser.write(account, into="login") + browser.write("test", into="password") + browser.click("log in") + accounts_cookies[account] = browser.get_driver().get_cookies()[0] + else: + browser.get_driver().add_cookie(account_cookies) @pytest.fixture def log_in_account1(browser): - global account_1_cookies - if account_1_cookies is None: - browser.get_driver().delete_all_cookies() - browser.go_to("https://libervia.test:8443/login") - browser.write("account1", into="login") - browser.write("test", into="password") - browser.click("log in") - account_1_cookies = browser.get_driver().get_cookies() - else: - browser.get_driver().add_cookie(account_1_cookies) + log_in(browser, "account1") +@pytest.fixture +def log_in_account1_s2(browser): + log_in(browser, "account1_s2") @pytest.fixture def mobile_screen(browser):