如何解决Selenium Python:此页面上都不使用Element Click或.send_keys
在this网页上,我无法弄清楚如何在搜索框中输入文本或如何从下拉菜单中选择给定状态。在其他网站上这样做似乎很简单,但我无法弄清楚。
尝试1次(从下拉菜单中选择):
driver = webdriver.Chrome()
driver.get("https://orderz.sheetz.com/#/main/location/search")
driver.find_element_by_xpath('//*[@id="state-search"]/select/option[2]').click()
尝试2(在搜索中输入文字):
driver = webdriver.Chrome()
driver.get("https://orderz.sheetz.com/#/main/location/search")
driver.find_element_by_xpath('//*[@id="storeSearchForm"]/div/div/input').send_keys("pa",Keys.ENTER)
尝试1的错误消息
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="state-search"]/select/option[2]"}
尝试2的错误消息
NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="storeSearchForm"]/div/div/input"}
任何建议,不胜感激!
解决方法
您是否可以尝试使用JavaScript执行器单击Web元素。
请参考链接:https://dzone.com/articles/perform-actions-using-javascript-in-python-seleniu
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。