1

The elements of the drop down list im trying to use.

using

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")

error -

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)*

Prophet
  • 32,350
  • 22
  • 54
  • 79
Ben Cohen
  • 89
  • 6

1 Answers1

0

Your element is inside an iframe.
You first need to switch to that iframe and only after that will be able to access elements inside it.

driver.switch_to.frame(driver.find_element_by_id("moduleManagement"))
Prophet
  • 32,350
  • 22
  • 54
  • 79
  • Firstly, thanks for the response!! secondly do you have an example on how i can do it with my current elements ? OrderStatus=Select(driver.find_element_by_xpath("//iframe[@id='moduleManagement']/select[@class='status-filter']")) – Ben Cohen Jun 29 '21 at 06:32
  • No, you perform switching to the iframe. After that you are working regularly. When you will need to access elements out of the iframe you will have to switch to the default content – Prophet Jun 29 '21 at 06:43
  • Works! thanks you. driver.switch_to.frame(driver.find_element_by_id("moduleManagement")) OrderStatus = Select(driver.find_element_by_class_name("status-filter")) OrderStatus.select_by_value("2") – Ben Cohen Jun 29 '21 at 06:56