1

I have to automate highlighted "P" tag text.

Snapshot of the element:

enter image description here

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:

enter image description here

Another snapshot:

enter image description here

Any solution on this??

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
S_G
  • 67
  • 6

1 Answers1

1

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"]')))
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352