fix deprecated find_elements_by* and find_element_by*

This commit is contained in:
2025-03-13 04:53:43 -07:00
parent 1aabfdbcce
commit 5895102451
20 changed files with 255 additions and 218 deletions

View File

@@ -1,67 +1,69 @@
import re
from secrets import choice
from test.test_description import TestDescription
from unittest import TestCase
from secrets import choice
import re
from selenium.webdriver.common.by import By
class TestDescriptionPerFeatures(TestDescription, TestCase):
def setUp(self):
super(TestDescriptionPerFeatures, self).setUp()
self.driver.find_element_by_id('button-for-filter-by-features').click()
self.driver.find_element(By.ID, 'button-for-filter-by-features').click()
self.match = re.compile(r'^(.*)(\s\(\d*\))$')
def test_description_per_features(self):
featureSelectionRow = self.driver.find_element_by_id(
'featureSelectionRow')
featureSelectionRow = self.driver.find_element(
By.ID, 'featureSelectionRow')
inputs = [
x.get_attribute(
'id'
) for x in featureSelectionRow.find_elements_by_tag_name(
'input'
) for x in featureSelectionRow.find_elements(
By.TAG_NAME, 'input'
)
]
for x in inputs:
button = self.driver.find_element_by_id(
x).find_element_by_xpath('..')
button = self.driver.find_element(
By.ID, x).find_element(By.XPATH, '..')
self.features = self.match.search(
button.find_element_by_tag_name('label').text).group(1)
button.find_element(By.TAG_NAME, 'label').text).group(1)
button.click()
self.coalesced_text_test()
self.driver.find_element_by_id(
x).find_element_by_xpath('..').click()
self.driver.find_element(
By.ID, x).find_element(By.XPATH, '..').click()
def test_description_per_features_random(self):
self.randomly_select_feature()
def randomly_select_feature(self):
featureSelectionRow = self.driver.find_element_by_id(
'featureSelectionRow')
featureSelectionRow = self.driver.find_element(
By.ID, 'featureSelectionRow')
inputs = [
x.get_attribute(
'id'
) for x in featureSelectionRow.find_elements_by_tag_name(
'input'
) for x in featureSelectionRow.find_elements(
By.TAG_NAME, 'input'
)
]
unchecked_inputs = [
x for x in inputs if self.driver.find_element_by_id(
x).is_selected() is False
x for x in inputs if self.driver.find_element(
By.ID, x).is_selected() is False
]
if len(unchecked_inputs) > 0:
random_input = choice(unchecked_inputs)
button = self.driver.find_element_by_id(
random_input).find_element_by_xpath('..')
button = self.driver.find_element(
By.ID, random_input).find_element(By.XPATH, '..')
feature = self.match.search(
button.find_element_by_tag_name('label').text).group(1)
button.find_element(By.TAG_NAME, 'label').text).group(1)
button.click()