find_element_by_xpath("//button[@id='btn-submit']")
Attribute value is a variable:
find_element_by_xpath("//div[@data-automation-id='"+var_id+"']")
Child element's text contains a string or variable:
find_element_by_xpath(".//*[text()[contains(.,'ABC')]]")
find_element_by_xpath(".//*[text()='something']")
find_element_by_xpath(".//*[contains(., 'something')]")
find_element_by_xpath(".//button[contains(.,'"+var_text+"')]")
find_element_by_xpath(".//button[contains(text(),'"+var_text+"')]")
find_element_by_xpath(".//*[contains(text(),'"+var_text+"')]")
Match partial attribute value :
find_element_by_xpath("//span[contains(@class, 'presence')]")
find_element_by_xpath("//span[contains(@class, '"+var_value+"')]")
find_element_by_xpath("//div[starts-with(., 'sometext')]")
Match multiple attributes:
find_element_by_xpath("//div[@class='contact'][contains(@title, '"+var_title+"')]")
Current element's parent:
find_element_by_xpath('..')
Check if an element exists:
len(find_elements_by_xpath(...)) > 0
Get element's font style:
element.value_of_css_property('font-style')
find_element_by_xpath(".//button[contains(text(),'"+var_text+"')]")
find_element_by_xpath(".//*[contains(text(),'"+var_text+"')]")
Match partial attribute value :
find_element_by_xpath("//span[contains(@class, 'presence')]")
find_element_by_xpath("//span[contains(@class, '"+var_value+"')]")
find_element_by_xpath("//div[starts-with(., 'sometext')]")
Match multiple attributes:
find_element_by_xpath("//div[@class='contact'][contains(@title, '"+var_title+"')]")
Current element's parent:
find_element_by_xpath('..')
Check if an element exists:
len(find_elements_by_xpath(...)) > 0
Get element's font style:
element.value_of_css_property('font-style')
No comments:
Post a Comment