Linked Questions

Popular Questions

I need to get the len of tds and trs from a table, I am using xpath but whenever I run the code I get values completly different from the correct ones;

The table follows this scheme:

<table class="kktable stats">
<tbody>
<tr>
<td></td>
...
</tr>

My current attempt:

tr_ = driver.find_elements_by_xpath('//table/tbody/tr')
tds_ = driver.find_elements_by_xpath('//table//tbody//tr[1]//td')

print(len(tr_), len(tds_))

¡This should output 34, 13 but it outputs 43, 35 and I need something non absolute because the page changes daily!

the class of the table is kktable stats

I am currently using this method down bellow /

table = '/html/body/div[4]/div[2]/div[6]/div[3]/div/div/div/div[3]/div/table/tbody'
trs = driver.find_elements_by_xpath(table+"/tr")
tds = driver.find_elements_by_xpath(table+"/tr[1]/td")

This is outputting correctly => 34, 13

I've also tried this:

tds_ = driver.find_elements_by_xpath('//table[@class="kktable.stats"]//tbody//tr[1]//td')

But unfortunately it returned 0

Related Questions