aboutsummaryrefslogtreecommitdiff
path: root/test/conftest.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/conftest.py')
-rw-r--r--test/conftest.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/test/conftest.py b/test/conftest.py
index b9c46b0..dec6d91 100644
--- a/test/conftest.py
+++ b/test/conftest.py
@@ -59,10 +59,20 @@ def close_all_but_one_window(driver):
@pytest.fixture()
def driver(_driver, request):
nav_target = request.node.get_closest_marker('get_page')
- close_all_but_one_window(_driver)
- _driver.get(nav_target.args[0] if nav_target else 'about:blank')
- _driver.implicitly_wait(0)
- yield _driver
+ nav_target = nav_target.args[0] if nav_target else 'about:blank'
+
+ second_driver = request.node.get_closest_marker('second_driver')
+
+ if second_driver:
+ with firefox_safe_mode() as _driver:
+ _driver.get(nav_target)
+ yield _driver
+ _driver.quit()
+ else:
+ close_all_but_one_window(_driver)
+ _driver.get(nav_target)
+ _driver.implicitly_wait(0)
+ yield _driver
@pytest.fixture()
def webextension(driver, request):
@@ -87,8 +97,12 @@ def webextension(driver, request):
yield
- close_all_but_one_window(driver)
- driver.get('https://gotmyowndoma.in/')
+ # Unloading an extension might cause its windows to vanish. Make sure
+ # there's at least one window navigated to some other page before
+ # uninstalling the addon. Otherwise, we could be left with a windowless
+ # browser :c
+ driver.switch_to.window(driver.window_handles[-1])
+ driver.get('about:blank')
driver.uninstall_addon(addon_id)
ext_path.unlink()