I have the following Xpath:
'.//*[@id="reporting_usn_browser_tab_source_tree_5_crm_f1/5_address"]'
I would like to use ends with as I would like to find the text address which is at the end of the string
I have tried:
'.//*[@id="reporting_usn_browser_tab_source_tree_5_crm_f1/5_address"][ends-with(@id, 'address']
The HTML is:
<div>
<span id="reporting_usn_browser_tab_source_tree_5_crm_f1/3_address" class="" title="" style="">address</span>
</div>
My function checks if the address element is not on the page. The element is not on the page so I would like to return True.
def is_address_data_object_element_value_not_displayed_from_expanded_tree(self ): # Check if the address data object value is not displayed. For dataset ID f1/3 the address data object value should not be displayed.
#data_objet_address_element = self.get_element(By.XPATH, './/*[ends-with(@id, "address")]')
data_object_address_element = self.get_element(By.XPATH, '.// *[substring( @ id, string - length( @ id) - string - length("address") + 1) = "address"]')
if data_object_address_element.text is None or data_object_address_element == "":
return True
I get the error:
Unable to locate an element with the xpath expression .//*[ends-with(@id, "address")] because of the following error: TypeError: Unable to get property 'I' of undefined or null reference
I have also tried:
data_object_address_element = self.get_element(By.ID, '.// *[substring( @ id, string - length( @ id) - string - length("address") + 1) = "address"]')
I get the error:
NoSuchElementException: Message: Unable to find element with id == .// *[substring( @ id, string - length( @ id) - string - length("address") + 1) = "address"]
What is the Xpath syntax to use ends-with please?
Thanks, Riaz