Selenium - 只有 class-name 的下拉列表,无法在我当前的网站上使用 selenium 找到元素
Selenium -Drop down list with only class-name , unable to find element using selenium with my current website
The elements of the drop down list im trying to use.
使用
from selenium.webdriver.support.ui import Select
# my current attempt
OrderStatus = Select(driver.find_element_by_xpath("//select[@class='status-filter']"))
OrderStatus.select_by_index("2")
错误-
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//select[@class='status-filter']"}
(Session info: chrome=91.0.4472.124)*
您的元素在 iframe 中。
您首先需要切换到该 iframe,然后才能访问其中的元素。
driver.switch_to.frame(driver.find_element_by_id("moduleManagement"))
The elements of the drop down list im trying to use.
使用
from selenium.webdriver.support.ui import Select
# my current attempt
OrderStatus = Select(driver.find_element_by_xpath("//select[@class='status-filter']"))
OrderStatus.select_by_index("2")
错误-
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//select[@class='status-filter']"} (Session info: chrome=91.0.4472.124)*
您的元素在 iframe 中。
您首先需要切换到该 iframe,然后才能访问其中的元素。
driver.switch_to.frame(driver.find_element_by_id("moduleManagement"))