The sample page source looks like this
<div class='div1'>
<table class="foot-market">
<tbody data-live="false">
<td class='today-name'/>
</tbody>
<tbody data-live="false">
<td class='today-name'/>
</tbody>
<tbody data-live="false">
<td class='today-name'/>
</tbody>
</table
<table class="foot-market">
<tbody data-live="false">
<td class='today-name'/>
</tbody>
<tbody data-live="false">
<td class='today-name'/>
</tbody>
<tbody data-live="false">
<td class='today-name'/>
</tbody>
</table
</div>
Explanation
Hi,
So let's get to it.
As shown above the code snippet I'm interacting with is housed in a <div class='div1'>.
The <td class='today-name'> is clickable and once clicked it renders a page(the page of interest)
so I would like to loop through getting each <tbody data-live="false"> and click it.
From my research I haven't found anything similar but I have found interesting stuff but nothing to help. I appreciate all help given.
Thanks.
my code
import time
import selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.firefox.options import Options
from BeautifulSoup import BeautifulSoup
#some of the imports are for headless firefox so don't mind them
#for.testing.purposes.only
driver = webdriver.Firefox()
url = 'here://code.above.com/'
driver.get(url)
#looping rows in selenium
table = driver.find_elements_by_xpath("//table[@class='foot-market']")
for row in table.find_element_by_xpath("//tbody[@data-live='false']"):
row.find_element_by_xpath("//td[@class='today-name']").click()
#try for one row first
# driver.back()
break
Error
The error returned is in line:
for row in table.find_element_by_xpath("//td[@data-live='false']"):
Exception:
AttributeError: 'list' object has no attribute 'find_element_by_xpath'
which makes sense and all, but how do I achieve this...