I am writing a functions that searches inside a website using a name_parameter, but I am sure I am misspelling something and I cannot get the correct button with my input. I know the XPATH has the correct structure because if I hard code the page_name then I get the expected result
def change_user(self, page_name):
select_user = WebDriverWait(self.driver, 4).until(
EC.element_to_be_clickable((
By.XPATH, f'//div/div/div/span[contains(text(), {0} )]'.format(page_name)))
)
time.sleep(random.uniform(0.15, 0.5))
select_user.click()
A hard coded actually working version of this function is the following:
def change_user(self, page_name):
select_user = WebDriverWait(self.driver, 4).until(
EC.element_to_be_clickable((
By.XPATH, f'//div/div/div/span[contains(text(), "Carl Rogers" )]'))
)
time.sleep(random.uniform(0.15, 0.5))
select_user.click()
I am using this reference for the syntax https://www.w3schools.com/python/ref_string_format.asp