Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.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 Webdriver_Html Table_Inspect Element - Fatal编程技术网

无法使用Python selenium获取行数

无法使用Python selenium获取行数,python,selenium-webdriver,html-table,inspect-element,Python,Selenium Webdriver,Html Table,Inspect Element,嗨,我正在尝试使用python Selenium获取Html表中所有行的计数。 我的表包含155行,但我的代码只返回30行作为rowcount。我已经选中了inspect元素,它只显示了30行,一旦我向下滚动,旧的行从inspect元素中删除,新的行被添加。因此它保持30为常量。在这种情况下,如何将155作为行数并遍历所有行 tbody=driver.find_elements_by_xpath("gridview-1161-body") rowCount=len(driver.find_ele

嗨,我正在尝试使用python Selenium获取Html表中所有行的计数。 我的表包含155行,但我的代码只返回30行作为rowcount。我已经选中了inspect元素,它只显示了30行,一旦我向下滚动,旧的行从inspect元素中删除,新的行被添加。因此它保持30为常量。在这种情况下,如何将155作为行数并遍历所有行

tbody=driver.find_elements_by_xpath("gridview-1161-body")
rowCount=len(driver.find_elements_by_xpath("//tbody[@id='gridview-1161-body']/tr"));
rows = WebDriverWait(driver, 10).until(EC.visibility_of_all_elements_located((By.XPATH, "//tbody[contains(@id,'gridview-1161-body')]/tr")))
print(rowCount)
使用for循环,我试图给td赋值,在这种情况下,一旦达到21行,它就会失败

rownum=0
for rownum in range(rowCount):
        element=rows[rownum].find_element_by_xpath(".//td[contains(@class,'rp-grid-editable-cell  rp-grid-editable-cell') and @role='gridcell']")
        element.click()
        driver.find_element(By.ID, "numberfield-1243-inputEl").send_keys('1')
        driver.find_element(By.ID, "numberfield-1243-inputEl").send_keys(Keys.ENTER)

包含URL将更容易除了URL之外,您还可以显示HTML结构的外观。