XPath not working when using a path that clearly exists in the elements tree
11:31 12 Dec 2025

For a WebElement queried from selenium webdriver, when I print element.get_attribute('outerHTML') it prints


  
    . . .                                                                                
  
  . . .

but when I try to retrieve the first TD element with

element.find_element(By.XPATH, "./tr/td[1]")

I get an exception

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"./tr/td[1]"}

This doesn't seem to make any sense to me. Can someone please help?

selenium-webdriver