Quantcast
Viewing all articles
Browse latest Browse all 3

Answer by Jim Zhou for Selenium Python: How can I count the number of tables in a div?

Assuming that there would be at least one element that matches the xpath of '//*[@id="emailwrapper"]/div/div/table', you can simply do:

driver.find_elements_by_xpath('//*[@id="emailwrapper"]/div/div/table')

It will return a list, or raise NoSuchElementException if none are found.

Exact same results but written differently:

from selenium.webdriver.common.by import By
driver.find_elements(By.XPATH, '//*[@id="emailwrapper"]/div/div/table')

After which you can do a len() on the list for how many elements


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>