-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Closed
Labels
C-pyPython BindingsPython Bindings
Description
🚀 Feature Proposal
extend the functionality of text_to_be_present_in_element_value to not only check the attribute "value", but any attribute.
Motivation
I'm currently automating a webpage, where the title of an image changes from "in work" to "finished". text_to_be_present_in_element_value would be exactly what I need, if I just could change "value" to the attribute "title"
Example
As I'm using python, I added following class:
class text_to_be_present_in_element_attribute(object):
"""
An expectation for checking if the given text is present in the elements attribute
locator, attribute, text
"""
def __init__(self, locator, attribute_, text_):
self.locator = locator
self.attribute = attribute_
self.text = text_
def __call__(self, driver):
try:
element_text = _find_element(driver,
self.locator).get_attribute(self.attribute)
if element_text:
return self.text in element_text
else:
return False
except StaleElementReferenceException:
return False
So it can be called like:
WebDriverWait(client, 5).until(EC.text_to_be_present_in_element_attribute((By.XPATH, "//div[contains(text(), 'sending')]/../preceding-sibling::div/img"), "title", "finished"))
Metadata
Metadata
Assignees
Labels
C-pyPython BindingsPython Bindings