From 097e5e754bc13b4d1f85275147093f50ef4d4815 Mon Sep 17 00:00:00 2001 From: Benjamin Cutler Date: Wed, 1 Nov 2023 14:40:17 -0600 Subject: [PATCH] fix selenium upgrade errors (#615) [#186384888] --- tests/test_admin.py | 23 ++++++++++++----------- tests/util.py | 14 +++++++------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/tests/test_admin.py b/tests/test_admin.py index c5b310606..10b020a0a 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -4,6 +4,7 @@ from django.contrib.auth.models import Permission from django.test import TestCase from django.urls import reverse +from selenium.webdriver.common.by import By from tracker import models @@ -78,10 +79,10 @@ def test_one_step_screening(self): f'{self.live_server_url}{reverse("admin:tracker_ui")}/process_donations/{str(self.event.id)}' ) self.wait_for_spinner() - row = self.webdriver.find_element_by_css_selector( - f'tr[data-test-pk="{self.donation.pk}"]' + row = self.webdriver.find_element( + By.CSS_SELECTOR, f'tr[data-test-pk="{self.donation.pk}"]' ) - row.find_element_by_css_selector('button[data-test-id="send"]').click() + row.find_element(By.CSS_SELECTOR, 'button[data-test-id="send"]').click() self.wait_for_spinner() self.donation.refresh_from_db() self.assertEqual(self.donation.readstate, 'READY') @@ -94,10 +95,10 @@ def test_two_step_screening(self): f'{self.live_server_url}{reverse("admin:tracker_ui")}/process_donations/{str(self.event.id)}' ) self.wait_for_spinner() - row = self.webdriver.find_element_by_css_selector( - f'tr[data-test-pk="{self.donation.pk}"]' + row = self.webdriver.find_element( + By.CSS_SELECTOR, f'tr[data-test-pk="{self.donation.pk}"]' ) - row.find_element_by_css_selector('button[data-test-id="send"]').click() + row.find_element(By.CSS_SELECTOR, 'button[data-test-id="send"]').click() self.wait_for_spinner() self.donation.refresh_from_db() self.assertEqual(self.donation.readstate, 'FLAGGED') @@ -108,14 +109,14 @@ def test_two_step_screening(self): ) self.wait_for_spinner() self.select_option('[data-test-id="processing-mode"]', 'confirm') - self.webdriver.find_element_by_css_selector( - 'button[data-test-id="refresh"' + self.webdriver.find_element( + By.CSS_SELECTOR, 'button[data-test-id="refresh"' ).click() self.wait_for_spinner() - row = self.webdriver.find_element_by_css_selector( - f'tr[data-test-pk="{self.donation.pk}"]' + row = self.webdriver.find_element( + By.CSS_SELECTOR, f'tr[data-test-pk="{self.donation.pk}"]' ) - row.find_element_by_css_selector('button[data-test-id="send"]').click() + row.find_element(By.CSS_SELECTOR, 'button[data-test-id="send"]').click() self.wait_for_spinner() self.donation.refresh_from_db() self.assertEqual(self.donation.readstate, 'READY') diff --git a/tests/util.py b/tests/util.py index 82d765cf5..119f0fc36 100644 --- a/tests/util.py +++ b/tests/util.py @@ -609,22 +609,22 @@ def tearDown(self): def tracker_login(self, username, password='password'): self.webdriver.get(self.live_server_url + reverse('admin:login')) - self.webdriver.find_element_by_name('username').send_keys(username) - self.webdriver.find_element_by_name('password').send_keys(password) - self.webdriver.find_element_by_css_selector('form input[type=submit]').click() - self.webdriver.find_element_by_css_selector( - '.app-tracker' + self.webdriver.find_element(By.NAME, 'username').send_keys(username) + self.webdriver.find_element(By.NAME, 'password').send_keys(password) + self.webdriver.find_element(By.CSS_SELECTOR, 'form input[type=submit]').click() + self.webdriver.find_element( + By.CSS_SELECTOR, '.app-tracker' ) # admin page has loaded def tracker_logout(self): self.webdriver.get(self.live_server_url + reverse('admin:logout')) self.assertEqual( - self.webdriver.find_element_by_css_selector('#content h1').text, + self.webdriver.find_element(By.CSS_SELECTOR, '#content h1').text, 'Logged out', ) def select_option(self, selector, value): - Select(self.webdriver.find_element_by_css_selector(selector)).select_by_value( + Select(self.webdriver.find_element(By.CSS_SELECTOR, selector)).select_by_value( value )