不使用<;时如何选择下拉选项;选择>;在Python中使用Selenium标记

不使用<;时如何选择下拉选项;选择>;在Python中使用Selenium标记,python,html,selenium,selenium-webdriver,Python,Html,Selenium,Selenium Webdriver,要在以下URL中选择日期(突出显示黄色): 在检查HTML代码时,我找不到任何“选择”标记,如下所示: 我的代码: chrome\u options=options() chrome\u选项。添加\u参数(“--headless”) chrome_选项。添加_参数(“窗口大小=19201080”) driver=webdriver.Chrome(options=Chrome\u options,executable\u path=r'/Users/Woodylin/Desktop/Pyt

要在以下URL中选择日期(突出显示黄色):

在检查HTML代码时,我找不到任何“选择”标记,如下所示:

我的代码:

chrome\u options=options()
chrome\u选项。添加\u参数(“--headless”)
chrome_选项。添加_参数(“窗口大小=19201080”)
driver=webdriver.Chrome(options=Chrome\u options,executable\u path=r'/Users/Woodylin/Desktop/Python Learnings/chromedriver')
#driver=webdriver.Chrome(options=Chrome\u options,executable\u path=r'C:/Users/wolin/Desktop/Python/chromedriver.exe')
url1=https://www.hkex.com.hk/Mutual-Market/Stock-Connect/Statistics/Historical-Daily?sc_lang=zh-HK#选择4=2&5=1&3=0&1=1&2=6'#滬港通 
获取驱动程序(url1)
睡眠(3)
ele_date=driver.find_element_by_id('select-target-date')#target date
DropDown1=选择(删除日期)
下拉列表1.按可视文本(“7”)选择文档:

构造器。检查给定元素是否确实是SELECT标记

您的目标元素不是
SELECT
标记。因此,您不能使用
Select

尝试使用css选择器的另一种方法。您需要首先单击日期元素以使下拉菜单显示日期列表,在单击元素目标之前,先使用
location\u滚动到\u视图中

driver.find_element_by_css_selector('div.csm-dailystat-day-selection').click()
target_date = '7'
ele_date = driver.find_element_by_css_selector('div.csm-dailystat-day-selection div[data-value="{}"]'.format(target_date))
ele_date.location_once_scrolled_into_view
ele_date.click()

发现如果我使用以下XPATH可以选择:#下面的命令将选择“第五天”驱动程序。通过#XPATH(“/*[@id='mainform']/div[8]/main/section/div[2]/div[1]/div[2]/div[5]/a”)查找元素。但是,如果我使用下面的命令选择“第31天,它返回以下错误:Err msg:selenium.common.exceptions.elementnotinteractitableexception:Message:element不可交互驱动程序。通过xpath(“//*[@id='mainform']]/div[8]/main/section/div[2]/div[1]/div[2]/div[31]/a”)查找\u元素?您能否共享包含所有日期的div,以便我们可以帮助您使用正确的Xpath。因此,如果我对目标月执行相同操作,则会出现以下错误:selenium.common.exceptions.element ClickInterceptedException:Message:element click intercepted:element。。。在点(744,24)处不可单击。其他元素将收到点击:我可以知道如何获得目标月吗?我是否需要使用“预期条件”来单击后面的其他元素?@Woody For
target\u month
使用此选择器
div.csm-dailystat-month-selection