summaryrefslogtreecommitdiff
path: root/tests/admin_inlines
diff options
context:
space:
mode:
authorCarlton Gibson <carlton.gibson@noumenal.es>2021-10-20 15:54:30 +0200
committerCarlton Gibson <carlton.gibson@noumenal.es>2021-10-21 14:37:16 +0200
commit2ccc0b22db6730ba0950b10bbc5238ae575e4a45 (patch)
tree6107a609c42128b51ae7a5c50805912ba613b8d2 /tests/admin_inlines
parent8fa974fcdde90b6719a1058e77541389ff1809b5 (diff)
Fixed #33211 -- Updated tests for Selenium 4.0.0.
Replaced deprecated `find_element[s]_by_*()` usages, in favour of `find_element[s]()` with an explicit `By`.
Diffstat (limited to 'tests/admin_inlines')
-rw-r--r--tests/admin_inlines/tests.py174
1 files changed, 98 insertions, 76 deletions
diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py
index 831135bdc4..54bbec28aa 100644
--- a/tests/admin_inlines/tests.py
+++ b/tests/admin_inlines/tests.py
@@ -1275,6 +1275,7 @@ class SeleniumTests(AdminSeleniumTestCase):
"""
The "Add another XXX" link correctly adds items to the stacked formset.
"""
+ from selenium.webdriver.common.by import By
self.admin_login(username='super', password='secret')
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_holder4_add'))
@@ -1282,12 +1283,12 @@ class SeleniumTests(AdminSeleniumTestCase):
rows_selector = '%s .dynamic-inner4stacked_set' % inline_id
self.assertCountSeleniumElements(rows_selector, 3)
- add_button = self.selenium.find_element_by_link_text(
- 'Add another Inner4 stacked')
+ add_button = self.selenium.find_element(By.LINK_TEXT, 'Add another Inner4 stacked')
add_button.click()
self.assertCountSeleniumElements(rows_selector, 4)
def test_delete_stackeds(self):
+ from selenium.webdriver.common.by import By
self.admin_login(username='super', password='secret')
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_holder4_add'))
@@ -1296,19 +1297,19 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertCountSeleniumElements(rows_selector, 3)
- add_button = self.selenium.find_element_by_link_text(
- 'Add another Inner4 stacked')
+ add_button = self.selenium.find_element(By.LINK_TEXT, 'Add another Inner4 stacked')
add_button.click()
add_button.click()
self.assertCountSeleniumElements(rows_selector, 5)
- for delete_link in self.selenium.find_elements_by_css_selector('%s .inline-deletelink' % inline_id):
+ for delete_link in self.selenium.find_elements(By.CSS_SELECTOR, '%s .inline-deletelink' % inline_id):
delete_link.click()
with self.disable_implicit_wait():
self.assertCountSeleniumElements(rows_selector, 0)
def test_delete_invalid_stacked_inlines(self):
from selenium.common.exceptions import NoSuchElementException
+ from selenium.webdriver.common.by import By
self.admin_login(username='super', password='secret')
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_holder4_add'))
@@ -1317,42 +1318,46 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertCountSeleniumElements(rows_selector, 3)
- add_button = self.selenium.find_element_by_link_text(
- 'Add another Inner4 stacked')
+ add_button = self.selenium.find_element(
+ By.LINK_TEXT,
+ 'Add another Inner4 stacked',
+ )
add_button.click()
add_button.click()
self.assertCountSeleniumElements('#id_inner4stacked_set-4-dummy', 1)
# Enter some data and click 'Save'.
- self.selenium.find_element_by_name('dummy').send_keys('1')
- self.selenium.find_element_by_name('inner4stacked_set-0-dummy').send_keys('100')
- self.selenium.find_element_by_name('inner4stacked_set-1-dummy').send_keys('101')
- self.selenium.find_element_by_name('inner4stacked_set-2-dummy').send_keys('222')
- self.selenium.find_element_by_name('inner4stacked_set-3-dummy').send_keys('103')
- self.selenium.find_element_by_name('inner4stacked_set-4-dummy').send_keys('222')
+ self.selenium.find_element(By.NAME, 'dummy').send_keys('1')
+ self.selenium.find_element(By.NAME, 'inner4stacked_set-0-dummy').send_keys('100')
+ self.selenium.find_element(By.NAME, 'inner4stacked_set-1-dummy').send_keys('101')
+ self.selenium.find_element(By.NAME, 'inner4stacked_set-2-dummy').send_keys('222')
+ self.selenium.find_element(By.NAME, 'inner4stacked_set-3-dummy').send_keys('103')
+ self.selenium.find_element(By.NAME, 'inner4stacked_set-4-dummy').send_keys('222')
with self.wait_page_loaded():
- self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
+ self.selenium.find_element(By.XPATH, '//input[@value="Save"]').click()
# Sanity check.
self.assertCountSeleniumElements(rows_selector, 5)
- errorlist = self.selenium.find_element_by_css_selector(
- '%s .dynamic-inner4stacked_set .errorlist li' % inline_id
+ errorlist = self.selenium.find_element(
+ By.CSS_SELECTOR,
+ '%s .dynamic-inner4stacked_set .errorlist li' % inline_id,
)
self.assertEqual('Please correct the duplicate values below.', errorlist.text)
- delete_link = self.selenium.find_element_by_css_selector('#inner4stacked_set-4 .inline-deletelink')
+ delete_link = self.selenium.find_element(By.CSS_SELECTOR, '#inner4stacked_set-4 .inline-deletelink')
delete_link.click()
self.assertCountSeleniumElements(rows_selector, 4)
with self.disable_implicit_wait(), self.assertRaises(NoSuchElementException):
- self.selenium.find_element_by_css_selector('%s .dynamic-inner4stacked_set .errorlist li' % inline_id)
+ self.selenium.find_element(By.CSS_SELECTOR, '%s .dynamic-inner4stacked_set .errorlist li' % inline_id)
with self.wait_page_loaded():
- self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
+ self.selenium.find_element(By.XPATH, '//input[@value="Save"]').click()
# The objects have been created in the database.
self.assertEqual(Inner4Stacked.objects.all().count(), 4)
def test_delete_invalid_tabular_inlines(self):
from selenium.common.exceptions import NoSuchElementException
+ from selenium.webdriver.common.by import By
self.admin_login(username='super', password='secret')
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_holder4_add'))
@@ -1361,39 +1366,43 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertCountSeleniumElements(rows_selector, 3)
- add_button = self.selenium.find_element_by_link_text(
- 'Add another Inner4 tabular')
+ add_button = self.selenium.find_element(
+ By.LINK_TEXT,
+ 'Add another Inner4 tabular'
+ )
add_button.click()
add_button.click()
self.assertCountSeleniumElements('#id_inner4tabular_set-4-dummy', 1)
# Enter some data and click 'Save'.
- self.selenium.find_element_by_name('dummy').send_keys('1')
- self.selenium.find_element_by_name('inner4tabular_set-0-dummy').send_keys('100')
- self.selenium.find_element_by_name('inner4tabular_set-1-dummy').send_keys('101')
- self.selenium.find_element_by_name('inner4tabular_set-2-dummy').send_keys('222')
- self.selenium.find_element_by_name('inner4tabular_set-3-dummy').send_keys('103')
- self.selenium.find_element_by_name('inner4tabular_set-4-dummy').send_keys('222')
+ self.selenium.find_element(By.NAME, 'dummy').send_keys('1')
+ self.selenium.find_element(By.NAME, 'inner4tabular_set-0-dummy').send_keys('100')
+ self.selenium.find_element(By.NAME, 'inner4tabular_set-1-dummy').send_keys('101')
+ self.selenium.find_element(By.NAME, 'inner4tabular_set-2-dummy').send_keys('222')
+ self.selenium.find_element(By.NAME, 'inner4tabular_set-3-dummy').send_keys('103')
+ self.selenium.find_element(By.NAME, 'inner4tabular_set-4-dummy').send_keys('222')
with self.wait_page_loaded():
- self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
+ self.selenium.find_element(By.XPATH, '//input[@value="Save"]').click()
+
# Sanity Check.
self.assertCountSeleniumElements(rows_selector, 5)
# Non-field errorlist is in its own <tr> just before
# tr#inner4tabular_set-3:
- errorlist = self.selenium.find_element_by_css_selector(
+ errorlist = self.selenium.find_element(
+ By.CSS_SELECTOR,
'%s #inner4tabular_set-3 + .row-form-errors .errorlist li' % inline_id
)
self.assertEqual('Please correct the duplicate values below.', errorlist.text)
- delete_link = self.selenium.find_element_by_css_selector('#inner4tabular_set-4 .inline-deletelink')
+ delete_link = self.selenium.find_element(By.CSS_SELECTOR, '#inner4tabular_set-4 .inline-deletelink')
delete_link.click()
self.assertCountSeleniumElements(rows_selector, 4)
with self.disable_implicit_wait(), self.assertRaises(NoSuchElementException):
- self.selenium.find_element_by_css_selector('%s .dynamic-inner4tabular_set .errorlist li' % inline_id)
+ self.selenium.find_element(By.CSS_SELECTOR, '%s .dynamic-inner4tabular_set .errorlist li' % inline_id)
with self.wait_page_loaded():
- self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
+ self.selenium.find_element(By.XPATH, '//input[@value="Save"]').click()
# The objects have been created in the database.
self.assertEqual(Inner4Tabular.objects.all().count(), 4)
@@ -1402,50 +1411,51 @@ class SeleniumTests(AdminSeleniumTestCase):
"""
The "Add another XXX" link correctly adds items to the inline form.
"""
+ from selenium.webdriver.common.by import By
self.admin_login(username='super', password='secret')
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_profilecollection_add'))
# There's only one inline to start with and it has the correct ID.
self.assertCountSeleniumElements('.dynamic-profile_set', 1)
self.assertEqual(
- self.selenium.find_elements_by_css_selector('.dynamic-profile_set')[0].get_attribute('id'),
+ self.selenium.find_elements(By.CSS_SELECTOR, '.dynamic-profile_set')[0].get_attribute('id'),
'profile_set-0',
)
self.assertCountSeleniumElements('.dynamic-profile_set#profile_set-0 input[name=profile_set-0-first_name]', 1)
self.assertCountSeleniumElements('.dynamic-profile_set#profile_set-0 input[name=profile_set-0-last_name]', 1)
# Add an inline
- self.selenium.find_element_by_link_text('Add another Profile').click()
+ self.selenium.find_element(By.LINK_TEXT, 'Add another Profile').click()
# The inline has been added, it has the right id, and it contains the
# correct fields.
self.assertCountSeleniumElements('.dynamic-profile_set', 2)
self.assertEqual(
- self.selenium.find_elements_by_css_selector('.dynamic-profile_set')[1].get_attribute('id'),
+ self.selenium.find_elements(By.CSS_SELECTOR, '.dynamic-profile_set')[1].get_attribute('id'),
'profile_set-1',
)
self.assertCountSeleniumElements('.dynamic-profile_set#profile_set-1 input[name=profile_set-1-first_name]', 1)
self.assertCountSeleniumElements('.dynamic-profile_set#profile_set-1 input[name=profile_set-1-last_name]', 1)
# Let's add another one to be sure
- self.selenium.find_element_by_link_text('Add another Profile').click()
+ self.selenium.find_element(By.LINK_TEXT, 'Add another Profile').click()
self.assertCountSeleniumElements('.dynamic-profile_set', 3)
self.assertEqual(
- self.selenium.find_elements_by_css_selector('.dynamic-profile_set')[2].get_attribute('id'),
+ self.selenium.find_elements(By.CSS_SELECTOR, '.dynamic-profile_set')[2].get_attribute('id'),
'profile_set-2',
)
self.assertCountSeleniumElements('.dynamic-profile_set#profile_set-2 input[name=profile_set-2-first_name]', 1)
self.assertCountSeleniumElements('.dynamic-profile_set#profile_set-2 input[name=profile_set-2-last_name]', 1)
# Enter some data and click 'Save'
- self.selenium.find_element_by_name('profile_set-0-first_name').send_keys('0 first name 1')
- self.selenium.find_element_by_name('profile_set-0-last_name').send_keys('0 last name 2')
- self.selenium.find_element_by_name('profile_set-1-first_name').send_keys('1 first name 1')
- self.selenium.find_element_by_name('profile_set-1-last_name').send_keys('1 last name 2')
- self.selenium.find_element_by_name('profile_set-2-first_name').send_keys('2 first name 1')
- self.selenium.find_element_by_name('profile_set-2-last_name').send_keys('2 last name 2')
+ self.selenium.find_element(By.NAME, 'profile_set-0-first_name').send_keys('0 first name 1')
+ self.selenium.find_element(By.NAME, 'profile_set-0-last_name').send_keys('0 last name 2')
+ self.selenium.find_element(By.NAME, 'profile_set-1-first_name').send_keys('1 first name 1')
+ self.selenium.find_element(By.NAME, 'profile_set-1-last_name').send_keys('1 last name 2')
+ self.selenium.find_element(By.NAME, 'profile_set-2-first_name').send_keys('2 first name 1')
+ self.selenium.find_element(By.NAME, 'profile_set-2-last_name').send_keys('2 last name 2')
with self.wait_page_loaded():
- self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
+ self.selenium.find_element(By.XPATH, '//input[@value="Save"]').click()
# The objects have been created in the database
self.assertEqual(ProfileCollection.objects.all().count(), 1)
@@ -1453,6 +1463,7 @@ class SeleniumTests(AdminSeleniumTestCase):
def test_add_inline_link_absent_for_view_only_parent_model(self):
from selenium.common.exceptions import NoSuchElementException
+ from selenium.webdriver.common.by import By
user = User.objects.create_user('testing', password='password', is_staff=True)
user.user_permissions.add(
Permission.objects.get(codename='view_poll', content_type=ContentType.objects.get_for_model(Poll))
@@ -1468,17 +1479,18 @@ class SeleniumTests(AdminSeleniumTestCase):
self.selenium.get(self.live_server_url + change_url)
with self.disable_implicit_wait():
with self.assertRaises(NoSuchElementException):
- self.selenium.find_element_by_link_text('Add another Question')
+ self.selenium.find_element(By.LINK_TEXT, 'Add another Question')
def test_delete_inlines(self):
+ from selenium.webdriver.common.by import By
self.admin_login(username='super', password='secret')
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_profilecollection_add'))
# Add a few inlines
- self.selenium.find_element_by_link_text('Add another Profile').click()
- self.selenium.find_element_by_link_text('Add another Profile').click()
- self.selenium.find_element_by_link_text('Add another Profile').click()
- self.selenium.find_element_by_link_text('Add another Profile').click()
+ self.selenium.find_element(By.LINK_TEXT, 'Add another Profile').click()
+ self.selenium.find_element(By.LINK_TEXT, 'Add another Profile').click()
+ self.selenium.find_element(By.LINK_TEXT, 'Add another Profile').click()
+ self.selenium.find_element(By.LINK_TEXT, 'Add another Profile').click()
self.assertCountSeleniumElements('#profile_set-group table tr.dynamic-profile_set', 5)
self.assertCountSeleniumElements('form#profilecollection_form tr.dynamic-profile_set#profile_set-0', 1)
self.assertCountSeleniumElements('form#profilecollection_form tr.dynamic-profile_set#profile_set-1', 1)
@@ -1486,10 +1498,14 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertCountSeleniumElements('form#profilecollection_form tr.dynamic-profile_set#profile_set-3', 1)
self.assertCountSeleniumElements('form#profilecollection_form tr.dynamic-profile_set#profile_set-4', 1)
# Click on a few delete buttons
- self.selenium.find_element_by_css_selector(
- 'form#profilecollection_form tr.dynamic-profile_set#profile_set-1 td.delete a').click()
- self.selenium.find_element_by_css_selector(
- 'form#profilecollection_form tr.dynamic-profile_set#profile_set-2 td.delete a').click()
+ self.selenium.find_element(
+ By.CSS_SELECTOR,
+ 'form#profilecollection_form tr.dynamic-profile_set#profile_set-1 td.delete a',
+ ).click()
+ self.selenium.find_element(
+ By.CSS_SELECTOR,
+ 'form#profilecollection_form tr.dynamic-profile_set#profile_set-2 td.delete a',
+ ).click()
# The rows are gone and the IDs have been re-sequenced
self.assertCountSeleniumElements('#profile_set-group table tr.dynamic-profile_set', 3)
self.assertCountSeleniumElements('form#profilecollection_form tr.dynamic-profile_set#profile_set-0', 1)
@@ -1497,18 +1513,20 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertCountSeleniumElements('form#profilecollection_form tr.dynamic-profile_set#profile_set-2', 1)
def test_collapsed_inlines(self):
+ from selenium.webdriver.common.by import By
+
# Collapsed inlines have SHOW/HIDE links.
self.admin_login(username='super', password='secret')
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_author_add'))
# One field is in a stacked inline, other in a tabular one.
test_fields = ['#id_nonautopkbook_set-0-title', '#id_nonautopkbook_set-2-0-title']
- show_links = self.selenium.find_elements_by_link_text('SHOW')
+ show_links = self.selenium.find_elements(By.LINK_TEXT, 'SHOW')
self.assertEqual(len(show_links), 3)
for show_index, field_name in enumerate(test_fields, 0):
self.wait_until_invisible(field_name)
show_links[show_index].click()
self.wait_until_visible(field_name)
- hide_links = self.selenium.find_elements_by_link_text('HIDE')
+ hide_links = self.selenium.find_elements(By.LINK_TEXT, 'HIDE')
self.assertEqual(len(hide_links), 2)
for hide_index, field_name in enumerate(test_fields, 0):
self.wait_until_visible(field_name)
@@ -1516,17 +1534,18 @@ class SeleniumTests(AdminSeleniumTestCase):
self.wait_until_invisible(field_name)
def test_added_stacked_inline_with_collapsed_fields(self):
+ from selenium.webdriver.common.by import By
self.admin_login(username='super', password='secret')
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_teacher_add'))
- self.selenium.find_element_by_link_text('Add another Child').click()
+ self.selenium.find_element(By.LINK_TEXT, 'Add another Child').click()
test_fields = ['#id_child_set-0-name', '#id_child_set-1-name']
- show_links = self.selenium.find_elements_by_link_text('SHOW')
+ show_links = self.selenium.find_elements(By.LINK_TEXT, 'SHOW')
self.assertEqual(len(show_links), 2)
for show_index, field_name in enumerate(test_fields, 0):
self.wait_until_invisible(field_name)
show_links[show_index].click()
self.wait_until_visible(field_name)
- hide_links = self.selenium.find_elements_by_link_text('HIDE')
+ hide_links = self.selenium.find_elements(By.LINK_TEXT, 'HIDE')
self.assertEqual(len(hide_links), 2)
for hide_index, field_name in enumerate(test_fields, 0):
self.wait_until_visible(field_name)
@@ -1561,31 +1580,32 @@ class SeleniumTests(AdminSeleniumTestCase):
self.assertIn(element.value_of_css_property(prop), colors)
def test_inline_formset_error_input_border(self):
+ from selenium.webdriver.common.by import By
self.admin_login(username='super', password='secret')
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_holder5_add'))
self.wait_until_visible('#id_dummy')
- self.selenium.find_element_by_id('id_dummy').send_keys(1)
+ self.selenium.find_element(By.ID, 'id_dummy').send_keys(1)
fields = ['id_inner5stacked_set-0-dummy', 'id_inner5tabular_set-0-dummy']
- show_links = self.selenium.find_elements_by_link_text('SHOW')
+ show_links = self.selenium.find_elements(By.LINK_TEXT, 'SHOW')
for show_index, field_name in enumerate(fields):
show_links[show_index].click()
self.wait_until_visible('#' + field_name)
- self.selenium.find_element_by_id(field_name).send_keys(1)
+ self.selenium.find_element(By.ID, field_name).send_keys(1)
# Before save all inputs have default border
for inline in ('stacked', 'tabular'):
for field_name in ('name', 'select', 'text'):
element_id = 'id_inner5%s_set-0-%s' % (inline, field_name)
self.assertBorder(
- self.selenium.find_element_by_id(element_id),
+ self.selenium.find_element(By.ID, element_id),
'1px solid #cccccc',
)
- self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
+ self.selenium.find_element(By.XPATH, '//input[@value="Save"]').click()
# Test the red border around inputs by css selectors
stacked_selectors = ['.errors input', '.errors select', '.errors textarea']
for selector in stacked_selectors:
self.assertBorder(
- self.selenium.find_element_by_css_selector(selector),
+ self.selenium.find_element(By.CSS_SELECTOR, selector),
'1px solid #ba2121',
)
tabular_selectors = [
@@ -1593,20 +1613,21 @@ class SeleniumTests(AdminSeleniumTestCase):
]
for selector in tabular_selectors:
self.assertBorder(
- self.selenium.find_element_by_css_selector(selector),
+ self.selenium.find_element(By.CSS_SELECTOR, selector),
'1px solid #ba2121',
)
def test_inline_formset_error(self):
+ from selenium.webdriver.common.by import By
self.admin_login(username='super', password='secret')
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_holder5_add'))
stacked_inline_formset_selector = 'div#inner5stacked_set-group fieldset.module.collapse'
tabular_inline_formset_selector = 'div#inner5tabular_set-group fieldset.module.collapse'
# Inlines without errors, both inlines collapsed
- self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
+ self.selenium.find_element(By.XPATH, '//input[@value="Save"]').click()
self.assertCountSeleniumElements(stacked_inline_formset_selector + '.collapsed', 1)
self.assertCountSeleniumElements(tabular_inline_formset_selector + '.collapsed', 1)
- show_links = self.selenium.find_elements_by_link_text('SHOW')
+ show_links = self.selenium.find_elements(By.LINK_TEXT, 'SHOW')
self.assertEqual(len(show_links), 2)
# Inlines with errors, both inlines expanded
@@ -1614,8 +1635,8 @@ class SeleniumTests(AdminSeleniumTestCase):
for show_index, field_name in enumerate(test_fields):
show_links[show_index].click()
self.wait_until_visible(field_name)
- self.selenium.find_element_by_id(field_name[1:]).send_keys(1)
- hide_links = self.selenium.find_elements_by_link_text('HIDE')
+ self.selenium.find_element(By.ID, field_name[1:]).send_keys(1)
+ hide_links = self.selenium.find_elements(By.LINK_TEXT, 'HIDE')
self.assertEqual(len(hide_links), 2)
for hide_index, field_name in enumerate(test_fields):
hide_link = hide_links[hide_index]
@@ -1623,7 +1644,7 @@ class SeleniumTests(AdminSeleniumTestCase):
hide_link.click()
self.wait_until_invisible(field_name)
with self.wait_page_loaded():
- self.selenium.find_element_by_xpath('//input[@value="Save"]').click()
+ self.selenium.find_element(By.XPATH, '//input[@value="Save"]').click()
with self.disable_implicit_wait():
self.assertCountSeleniumElements(stacked_inline_formset_selector + '.collapsed', 0)
self.assertCountSeleniumElements(tabular_inline_formset_selector + '.collapsed', 0)
@@ -1635,10 +1656,11 @@ class SeleniumTests(AdminSeleniumTestCase):
The item added by the "Add another XXX" link must use the correct
verbose_name in the inline form.
"""
+ from selenium.webdriver.common.by import By
self.admin_login(username='super', password='secret')
# Hide sidebar.
self.selenium.get(self.live_server_url + reverse('admin:admin_inlines_course_add'))
- toggle_button = self.selenium.find_element_by_css_selector('#toggle-nav-sidebar')
+ toggle_button = self.selenium.find_element(By.CSS_SELECTOR, '#toggle-nav-sidebar')
toggle_button.click()
# Each combination of horizontal/vertical filter with stacked/tabular
# inlines.
@@ -1654,16 +1676,16 @@ class SeleniumTests(AdminSeleniumTestCase):
with self.subTest(url=url_name):
self.selenium.get(self.live_server_url + reverse(url_name))
# First inline shows the verbose_name.
- available, chosen = self.selenium.find_elements_by_css_selector(css_selector % 0)
+ available, chosen = self.selenium.find_elements(By.CSS_SELECTOR, css_selector % 0)
self.assertEqual(available.text, 'AVAILABLE ATTENDANT')
self.assertEqual(chosen.text, 'CHOSEN ATTENDANT')
# Added inline should also have the correct verbose_name.
- self.selenium.find_element_by_link_text('Add another Class').click()
- available, chosen = self.selenium.find_elements_by_css_selector(css_selector % 1)
+ self.selenium.find_element(By.LINK_TEXT, 'Add another Class').click()
+ available, chosen = self.selenium.find_elements(By.CSS_SELECTOR, css_selector % 1)
self.assertEqual(available.text, 'AVAILABLE ATTENDANT')
self.assertEqual(chosen.text, 'CHOSEN ATTENDANT')
# Third inline should also have the correct verbose_name.
- self.selenium.find_element_by_link_text('Add another Class').click()
- available, chosen = self.selenium.find_elements_by_css_selector(css_selector % 2)
+ self.selenium.find_element(By.LINK_TEXT, 'Add another Class').click()
+ available, chosen = self.selenium.find_elements(By.CSS_SELECTOR, css_selector % 2)
self.assertEqual(available.text, 'AVAILABLE ATTENDANT')
self.assertEqual(chosen.text, 'CHOSEN ATTENDANT')