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

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.