【发布时间】:2019-10-07 19:58:11
【问题描述】:
当我尝试单击仅在单击父按钮后出现的按钮时,我在 Python 中遇到了 Selenium webdriver 的 click() 功能问题。
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
url = "https://law.lexmachina.com/cases/?pending-from=2000-01-01&pending-to=2000-02-01&filters=true&tab=summary&view=analytics&cols=475"
driver.get(url)
driver = webdriver.Chrome()
elem0 = driver.find_element_by_id('export-icon-container') # this works
all_children_by_css = elem0.find_elements_by_css_selector("*") # this works, but doesn't click on the sub-button (XLS) one successfully when I run below...
all_children_by_css[0].click() # this just makes the parent button's little window appear and disappear, the same as elem0.click() does.
>>> all_children_by_css[0] # this is the webElement that I thought was for the XLS button
<selenium.webdriver.remote.webelement.WebElement (session="6b4a559408fa4d512f8596759d81eaf7",
element="d83be2ca-c879-4706-85ef-db7120d345a3")>
基本上,我想通过 Webdriver 导出 XLS 文件,以便稍后我可以在带有数据过滤器 URL 的循环中执行此操作。
我在下面添加了带注释的屏幕截图,详细说明了我尝试单击的按钮以及与它们相关联的检查代码。
【问题讨论】:
标签: python selenium-webdriver xpath click inspect