XPath на Python с использованием Selenium, похоже, не работаетPython

Программы на Python
Anonymous
XPath на Python с использованием Selenium, похоже, не работает

Сообщение Anonymous »


I am trying to check if the "strong" element on a website contains the text "Status: Available" and then add the text into a list. Here is my current code:

def add_input(self, by: By, value: str, text: str, available_usernames: list, counter: int): field = self.browser.find_element(by=by, value=value) self.human_typing(field, text) time.sleep(3) try: strong_element = self.browser.find_element(By.XPATH, "//strong[contains(text(), 'Status:')]") if strong_element.text == "Status: Available": available_usernames.append(text) counter += 1 except NoSuchElementException: pass There is no specific error code, but the code is not functioning as intended. The problem seems to be in the strong_element = self.browser.find_element(By.XPATH, "//strong[contains(text(), 'Status:')]") part of the code.

What is wrong, and how do I fix it?


Источник: https://stackoverflow.com/questions/780 ... be-working

Вернуться в «Python»