【发布时间】:2020-08-11 04:04:47
【问题描述】:
在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"}
任何建议都非常感谢!
【问题讨论】:
-
网页没有为我打开。你能检查一下那个 webelement 是否在 iframe 中吗?
-
sheetz.com,然后点击右上角“Find A Sheetz”
标签: python python-3.x selenium xpath selenium-chromedriver