我有一个小任务,从https://www.carecredit.com/doctor-locator/抓取数据。 我无法使用我的脚本执行复选框勾选。在
我正在做
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import StaleElementReferenceException
driver = webdriver.Chrome()
driver.get('https://www.carecredit.com/doctor-locator/')
driver.find_element_by_xpath("//select[@id='dl-
profession']/option[@value='9']").click()
driver.find_element_by_xpath("//*[@id='specialty-106']").click()
把错误当作
^{pr2}$
以下是您问题的答案:
此代码块将打开URL
https://www.carecredit.com/doctor-locator
,单击Profession
下拉列表,选择Weight Loss
,最后选中复选框Weight Loss Surgery
。在如果这回答了你的问题,请告诉我。在
回溯包含了一个非常清楚的错误解释。在
您可能需要在两次单击之间添加一个延迟,以等待DOM更新,以便元素可以单击。在
相关问题 更多 >
编程相关推荐