0

Screenshot of the webpage in the link below:

webpage

I'm trying to select an option tag in the select element but I'm getting an error message saying element cannot be scrolled into view.

selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable: Element is not currently visible and may not be manipulated (Session info: chrome=71.0.3578.98)

Code:

dropdown = Select(driver.find_element_by_id("motes"))
dropdown.select_by_value("ALDERSHOT [Aldershot]")
Jab
  • 26,853
  • 21
  • 75
  • 114

1 Answers1

0

Your code should be

dropdown = Select(driver.find_element_by_id("motes"))
dropdown.select_by_visible_text("ALDERSHOT [Aldershot]")

There are three methods available to select an option from drop down.

  • dropdown.select_by_index(1) - Uses index of the option, starts from 1

  • dropdown.select_by_value("") - Uses value of the option i.e. text of html attribute 'value'

  • dropdown.select_by_visible_text("") - Uses visible text

For example, if you want to select "ACOMB - ELEC [York Acomb]"

dropdown = Select(driver.find_element_by_id("motes"))
dropdown.select_by_index(4)
dropdown.select_by_visible_text("ACOMB - ELEC [York Acomb]")
dropdown.select_by_value("433372-#42454c")

Note: Value of ALDERSHOT [Aldershot] option is hidden in screenshot hence used alternative.

arunkvelu
  • 1,631
  • 10
  • 21
  • Already tried that, but I get the following error: selenium.common.exceptions.ElementNotVisibleException: Message: element not interactable: Element is not currently visible and may not be manipulated (Session info: chrome=71.0.3578.98) – Sam Dempsy Jan 21 '19 at 00:21