I use Selenium WebDriver to scrape a table taken from a web page, written in JavaScript.
I am iterating on a list of table rows. Each row may be of a different class. I want to get the name of this class so that I can choose appropriate action for each row.
table_body = table.find_element_by_tag_name('tbody')
rows = table_body.find_elements_by_tag_name('tr')
for row in rows:
if (row.GetClassName()=="date"):
Action1()
else:
Action2()
Is this possible with Selenium? Or suggest another approach.
.get_attribute()
方法就是你要找的:
row.get_attribute("class")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.