我正在尝试在此网站上填写表格:https://p2c.coweta.ga.us/p2c/jailinmates.aspx
(点击“过滤囚犯列表”,然后点击+按钮添加一行)
def coweta_search(last, first):
print("Coweta County Jail")
url = "https://p2c.coweta.ga.us/p2c/jailinmates.aspx"
driver = webdriver.Chrome(chrome_options=(), executable_path="/usr/bin/chromedriver")
wait = WebDriverWait(driver, 30)
driver.get(url)
driver.find_element_by_css_selector("#btnGridSearch > span:nth-child(2)").click()
driver.find_element_by_css_selector(".field0 > option:nth-child(7)").click()
driver.find_element_by_css_selector("input.default").send_keys(last)
driver.find_element_by_css_selector(".ui-icon-plusthick").click()
driver.find_element_by_css_selector("tr.sf:nth-child(2) > td:nth-child(1) > select:nth-child(1) > option:nth-child(2)").click()
driver.find_element_by_css_selector("tr.sf:nth-child(2) > td:nth-child(2) > select:nth-child(2) > option:nth-child(7)").click()
return driver
当我如图所示运行代码时,第二行的第二个下拉菜单似乎被隐藏了。堆栈跟踪返回:
element not interactable: Element is not currently visible and may not be manipulated
我已经尝试了其他方法来解决此问题,例如显式等待或等到元素可见为止,但是这些都不起作用。
我也尝试过driver.execute_script:
first_drop = driver.find_element_by_css_selector("tr.sf:nth-child(2) > td:nth-child(2) > select:nth-child(2) > option:nth-child(7)")
driver.execute_script("arguments[0].click();", first_drop)
这没有给出错误,但实际上没有选择该选项(也许是因为它隐藏了?)。
有没有办法我可以选择隐藏的选项?
可能值得一提的是,同一下拉菜单中的默认类似乎位于顶部或其他位置。