我试图在(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)
页面不使用标准的
dropdown
小部件,但它使用button
和ul
来模拟dropdown
这段代码适用于我在Linux Mint上的
Firefox
和Chrome
首先,我单击
button
打开用ul
创建的dropdown
,然后我用预期文本搜索li
,然后单击它因为它可能有文本
2021
和一些spaces
/tabs
/enters
(哪个浏览器不显示),所以我更喜欢contains
而不是=
相关问题 更多 >
编程相关推荐