Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python-Selenium-找到了一些元素,但没有找到其他元素_Python_Selenium_Tags - Fatal编程技术网

Python-Selenium-找到了一些元素,但没有找到其他元素

Python-Selenium-找到了一些元素,但没有找到其他元素,python,selenium,tags,Python,Selenium,Tags,发现了前10个“td”,但其他800个左右的都没有。这是怎么发生的,非常令人沮丧 我只想要一份该页面上所有TD的列表,但即使所有TD都可见,也只能找到一些TD driver.get("http://www.skyracing.com.au/index.php?component=racing&task=todayraces&Itemid=88&id=18") heading3 = len(driver.find_elements_by_xpath('/

发现了前10个“td”,但其他800个左右的都没有。这是怎么发生的,非常令人沮丧

我只想要一份该页面上所有TD的列表,但即使所有TD都可见,也只能找到一些TD

driver.get("http://www.skyracing.com.au/index.php?component=racing&task=todayraces&Itemid=88&id=18")
heading3 = len(driver.find_elements_by_xpath('//td'))
count = 0
while count <= heading3:
    count = count + 1
    StringCount = str(count)
    try:
        heading4 = driver.find_element_by_xpath("//td[" + StringCount + "]").text
    except NoSuchElementException:
        pass
    print(StringCount)
    print(heading4)
driver.get(“http://www.skyracing.com.au/index.php?component=racing&task=todayraces&Itemid=88&id=18")
heading3=len(driver.find_elements_by_xpath('//td'))
计数=0

当count时,为什么不在
驱动程序返回的列表上循环。通过xpath('//td')
查找元素

对于idx,枚举中的元素(驱动程序。通过xpath('//td')查找元素):
打印(i+1,元素文本)

为什么不循环查看
驱动程序返回的列表。通过xpath('//td')查找元素?
?你是说heading3的长度是10?在没有看到HTML的情况下很难说是什么导致了这种情况,但是如果heading3的长度是10,那么我猜您需要使用不同的xpath。请向我们提供HTML代码。这比为您的问题找到解决方案更容易。感谢您指出这一点,但它并没有真正回答问题。您确定所有这些TDs都在主文档中,而不是在一个或多个IFRAME元素中吗?或者您只需要等待其他TDs加载。