python - 具有多个月日期的python selenium中的日期选择器
问题描述
我对 Python selenium 有点陌生,我有一个程序需要选择回溯日期来获取数据。我经历了堆栈平台中已经提出的许多问题,我的日历如下所示。它在同一张表中也显示了上个月或下个月的日期,有人可以帮我查找有关此类日历的文档,它们被称为什么以及如何处理它们。我试图点击返回日期,代码没有给出错误,但它不起作用。
代码我试图点击所需的日期,但它根本不起作用:
prev=driver.find_element_by_xpath("//th[@class='previous'][1]")
while((cmonth)!=(target_month) and (cyear)!=(target_year) ):
time.sleep(3)
Show10=driver.find_element_by_xpath("//div[@class='datetimepicker']/table[1]/thead[1]/tr[1]/th[contains(text(),'previous')").click()
Show10.click()
month=driver.find_element_by_xpath("//span[@class='month']")
cmonth=month.get_attribute("innerHTML")
year=driver.find_element_by_xpath("//span[@class='year']")
cyear=year.get_attribute("innerHTML")
day=driver.find_element_by_xpath("//div[@class='datetimepicker']//table[@class='days']//tbody")
for row in day.find_elements_by_xpath("//tr"):
for cell in row.find_elements_by_xpath("td"):
if (cell.text == expecteddate):
req_date = driver.find_element_by_link_text(cell.text)
req_date.click()
break
解决方案
推荐阅读
- jmeter - 我如何为基于新插件的 Jmeter 代码做出贡献?
- reactjs - 当我们执行 npm build 我希望构建包含我的文件
- c# - Cannot implicitly convert type 'System.Linq.IQueryable
' to 'System.Linq.IOrderedQueryable ' - sql-server - SQL Server - 使用 bcp.exe 实用程序导出加密数据(列加密设置=启用)
- mysql - 为什么这个 MYSQL 全文搜索没有给出分数?
- animation - 将 svgator 动画 .svg 转换为步进动画...?
- python - Django update_or_create(获取部分)使用相关对象作为kwarg
- bash - 通过 xargs 将 sed 输出传送到 grep 的问题
- java - 如何在不使用 byte[] 的情况下在 json 文件中编写多个二进制文件?
- arrays - 理解 compactMap 和 flatMap 的问题