Skip to content

Commit

Permalink
fix selenium upgrade errors (#615)
Browse files Browse the repository at this point in the history
[#186384888]
  • Loading branch information
uraniumanchor authored Nov 1, 2023
1 parent 367c7d0 commit 097e5e7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
23 changes: 12 additions & 11 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down
14 changes: 7 additions & 7 deletions tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down

0 comments on commit 097e5e7

Please sign in to comment.