From 9a8f7501de11b9eccbc5c10e1c547c15208b9514 Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Sat, 3 Feb 2024 12:27:48 +0100 Subject: [PATCH] Upgrade Selenium dependency Moreover, ChromeDriverManager isn't needed any longer. --- requirements_dev.txt | 2 +- requirements_e2e.txt | 3 +-- tox.ini | 4 ++-- two_factor/plugins/webauthn/tests/test_e2e.py | 18 +++--------------- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/requirements_dev.txt b/requirements_dev.txt index 5cf2f5ad0..59ec9372d 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -15,7 +15,7 @@ django-user-sessions # Example app (WebAuthn) -webauthn~=1.6.0 +webauthn~=1.11.0 # Testing diff --git a/requirements_e2e.txt b/requirements_e2e.txt index aedc9dbfb..5cf6a82a0 100644 --- a/requirements_e2e.txt +++ b/requirements_e2e.txt @@ -1,3 +1,2 @@ # test with selenium -selenium~=4.4.3 -webdriver-manager~=3.8.3,!=3.8.5 +selenium~=4.16.0 diff --git a/tox.ini b/tox.ini index b6abdf99c..9a098e271 100644 --- a/tox.ini +++ b/tox.ini @@ -45,7 +45,7 @@ deps = dj42: Django<5.0 djmain: https://github.com/django/django/archive/main.tar.gz yubikey: django-otp-yubikey - webauthn: webauthn>=1.2.1,<1.99 + webauthn: webauthn>=1.11.0,<1.99 webauthn: -rrequirements_e2e.txt coverage freezegun @@ -62,7 +62,7 @@ commands = [testenv:flake8] basepython = python3 -deps = flake8<=3.99 +deps = flake8<=6.99 commands = flake8 example tests two_factor [testenv:isort] diff --git a/two_factor/plugins/webauthn/tests/test_e2e.py b/two_factor/plugins/webauthn/tests/test_e2e.py index 30572243b..2db786ce5 100644 --- a/two_factor/plugins/webauthn/tests/test_e2e.py +++ b/two_factor/plugins/webauthn/tests/test_e2e.py @@ -20,15 +20,8 @@ except ImportError: webauthn = None -try: - from webdriver_manager.chrome import ChromeDriverManager - from webdriver_manager.utils import ChromeType -except ImportError: - ChromeDriverManager = None - @skipUnless(webdriver, 'package selenium is not present') -@skipUnless(ChromeDriverManager, 'package webdriver-manager is not present') @skipUnless(webauthn, 'package webauthn is not present') class E2ETests(UserMixin, StaticLiveServerTestCase): port = 8000 @@ -40,12 +33,7 @@ def setUp(self): options = webdriver.ChromeOptions() options.add_argument('headless') - try: - driver = ChromeDriverManager() - except ValueError: - driver = ChromeDriverManager(chrome_type=ChromeType.CHROMIUM) - self.webdriver = webdriver.Chrome(driver.install(), options=options) - + self.webdriver = webdriver.Chrome(options=options) super().setUp() def tearDown(self): @@ -70,7 +58,7 @@ def wait_for_url(self, url): WebDriverWait(self.webdriver, self.timeout).until(EC.url_to_be(url)) def do_login(self): - self.wait_for_url(self.login_url) + self.webdriver.get(self.login_url) username = self.webdriver.find_element(By.ID, 'id_auth-username') username.clear() @@ -84,7 +72,7 @@ def do_login(self): button_next.click() def register_authenticator(self): - self.wait_for_url(urljoin(self.base_url, reverse("two_factor:setup"))) + self.webdriver.get(urljoin(self.base_url, reverse("two_factor:setup"))) self.webdriver.find_element(By.XPATH, "//button[@type='submit']").click() self.wait_for_element(By.XPATH, "//input[@value='webauthn']").click()