【发布时间】:2022-01-02 13:41:06
【问题描述】:
enter image description here我是使用 selenium 和练习的 Python 新手。我正在尝试单击作为下拉列表的此元素,但该元素已突出显示但未单击。您可以在下面找到我尝试过的代码以及我正在检查的屏幕截图和 HTML。
driver.implicitly_wait(30)[enter image description here][1]
time.sleep(10)
print("The Non fiction is selected")
# choose_category_in_list = driver.find_element(By.ID, "div-nonfiction").click()
# choose_category_in_list = driver.find_element(By.ID, "div-nonfiction").click()
# button = driver.find_element_by_link_text("Nonfiction")
# choose_category_in_list = driver.find_element(By.XPATH , "//a[contains(text(),'Nonfiction')]").click()
element = driver.find_element_by_xpath("//a[contains(text(),'Nonfiction')]")
driver.execute_script("arguments[0].click();", element)
# action = TouchActions(driver)
# action.tap(mySelect).perform()
# mySelect.select_by_visible_text('ATLANTIC')
# choose_category_in_list = driver.find_element(By.ID, "icon-nonfiction").click()
# # choose_category_in_list = driver.find_element(By.ID, "icon-nonfiction").click()
# # choose_category_in_list = driver.find_element(By.XPATH , "//a[contains(text(),'Nonfiction')]")
# actions = ActionChains(driver)
# actions.double_click(choose_category_in_list).perform()
# driver.find_element_by_link_text("Nonfiction").click()
# choose_category_in_list = driver.find_element(By.XPATH , "//a[contains(text(),'Nonfiction')]").click()
# choose_category_in_list = driver.find_element(By.XPATH , "//a[contains(text(),'Nonfiction')]").click()
element = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Nonfiction")))
element.click()
【问题讨论】:
-
你能分享一个指向那个页面的链接,或者至少是那个页面的 HTML 吗?不是图片,是代码
标签: python selenium html-select html.dropdownlistfor