Skip to content

Commit c7bc7db

Browse files
Merge pull request #1548 from VWS-Python/adamtheturtle/vws-web-tools-issue-1506
Log in again when the shared test session has expired
2 parents 2d4499c + 05b9568 commit c7bc7db

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

tests/test_create_database.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,33 @@ def fixture_logged_in_chrome_driver(
3737
driver.quit()
3838

3939

40+
@pytest.fixture(name="_logged_in_session", autouse=True)
41+
def fixture_logged_in_session(
42+
logged_in_chrome_driver: WebDriver,
43+
vws_credentials: VWSCredentials,
44+
) -> None:
45+
"""Log in again if the shared session has expired.
46+
47+
``logged_in_chrome_driver`` is module-scoped, so it logs in once and
48+
every test in the module shares that one session. A module which
49+
runs for longer than the session lasts leaves the later tests
50+
driving a logged-out browser, which surfaces as a timeout waiting
51+
for an element that is never going to appear. Load a page which
52+
needs a session before each test, and log in again if the portal
53+
sends the browser to the login page instead.
54+
"""
55+
logged_in_chrome_driver.get(
56+
url="https://developer.vuforia.com/develop/databases",
57+
)
58+
current_url = logged_in_chrome_driver.current_url
59+
if "/auth/login" in current_url: # pragma: no cover
60+
vws_web_tools.log_in(
61+
driver=logged_in_chrome_driver,
62+
email_address=vws_credentials.email_address,
63+
password=vws_credentials.password,
64+
)
65+
66+
4067
@pytest.fixture(name="license_name", scope="module")
4168
def fixture_license_name(
4269
logged_in_chrome_driver: WebDriver,

0 commit comments

Comments
 (0)