I have to automate highlighted "P" tag text.
Snapshot of the element:
I am trying with below code. But its not identifying the element.
ele = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,'//p[text()="Connection Tested Successfully"]')))
if ele:
print("Pass")
else:
print("Fail")
Output:
Another snapshot:
Any solution on this??
The text within the <p>
tag i.e. Connection Tested Successfully
contains leading and trailing space characters which you need to consider while constructing the locator strategy and you can use either of the following locator strategies:
Using contains()
:
ele = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,'//p[contains(., "Connection Tested Successfully")]')))
Using normalize-space()
:
ele = WebDriverWait(driver,10).until(EC.presence_of_element_located((By.XPATH,'//p[normalize-space() = "Connection Tested Successfully"]')))