0

I am trying to find and click on the second sibling of an element that is identified by two conditions using By.XPATH in the following table:

enter image description here

Type == "Renewal" and Seq# == 1, but I cannot seem to make the two conditions work:

driver.find_element(By.XPATH, f"//td[@text()='Renewal' and text()='1']/followingsibling::td[2]/a").click()
Arthur Langlois
  • 137
  • 1
  • 9

1 Answers1

0

To click on the element associated with Type == "Renewal" and Seq# == 1 you can use either of the following locator strategies:

  • Using xpath and following:

    driver.find_element(By.XPATH, "//td[text()='Renewal']//following::td[contains(., '1')]//following::td[1]").click()
    
  • Using xpath and following-sibling:

    driver.find_element(By.XPATH, "//td[text()='Renewal']//following-sibling::td[contains(., '1')]//following-sibling::td[1]").click()
    
  • Note : You have to add the following imports :

    from selenium.webdriver.common.by import By
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352