1

I am a bit new to selenium so pardon my ignorance. I am trying get rows of an ajax loaded table from a website. The code looks something like this:

try:
    table = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, "tableid")))

finally :
    
    for row in table.xpath(".//tr"):
        print(row)

However, I am getting the following error:

AttributeError: 'WebElement' object has no attribute 'xpath'

Let me know what the error

kiteshjain
  • 63
  • 7

1 Answers1

1

This error message...

AttributeError: 'WebElement' object has no attribute 'xpath'

...implies that your program have attempted to invoke an attribute xpath which isn't available.


Solution

WebElement have no attribute as xpath. Instead you may like to invoke find_element_by_xpath() method. So effectively you have to change the line:

for row in table.xpath(".//tr"):

with:

for row in table.find_elements_by_xpath("./tr"):
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352