【发布时间】:2021-09-19 06:00:40
【问题描述】:
我正在尝试在 (https://www.theknot.com/registry/couplesearch) 上选择 2021 年的下拉年份,但无法弄清楚如何使用该下拉菜单。
#This code is working
typetextfirst = driver.find_element_by_id("couples-search-first-name")
typetextfirst.clear()
typetextfirst.send_keys(row["First"])
typetextlast = driver.find_element_by_id("couples-search-last-name")
typetextlast.clear()
typetextlast.send_keys(row["Last"])
typetextyear = driver.find_element_by_id("couples-search-year")
#None of these options work to populate the year
typetextyear.selectByIndex(1)
typetextyear.select_by_index(1)
typetextyear.selectByVisibleText("2021")
typetextyear.select_by_visible_text("2021")
#This code is working
typetextlast.send_keys(Keys.ENTER)
【问题讨论】:
-
总是将完整的错误消息(从单词“Traceback”开始)作为文本(不是截图,不是链接到外部门户)有问题(不是评论)。还有其他有用的信息。
-
它不使用标准下拉小部件,而是使用
button和ul创建的一些小部件,也许您应该单击它并使用键arrow down移动到选定的年份并发送ENTER.
标签: python selenium driver dropdown