rows = driver.find_element_by_xpath("//div[@style='display: block;']//table[@style='display: table;']//tr")
当我尝试迭代行时,它会抛出错误TypeError: 'WebElement' object is not iterable
def get_size(e):
for entry in e:
count = count + 1
return count
get_size(rows)
答案 0 :(得分:15)
试试这个。这应该工作。使用find_elements_by_xpath
Listlinker = []
Listlinker = driver.find_elements_by_xpath(""//div[@style='display: block;']//table[@style='display: table;']//tr")
for link in Listlinker:
// more code