0

I want to take input from user every time the user will input company name.So i am getting this error is there any other way to solve this query?

from selenium.webdriver.support.ui import Select
from selenium import webdriver as driver
menu = Select(driver.find_element_by_id('BodyContent__company'))
name=input('Enter company name: ')
for option in menu:
    if option.text == name:
        option.select()
    else:
        pass

Error:

Select is not iteratable
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352

1 Answers1

0

This error message...

Select is not iteratable

...implies that in your code block you are trying to iterate through a WebElement of type Select.


Solution

Instead of iterating the element you need to iterate through the Select.options elements as follows:

from selenium.webdriver.support.ui import Select
from selenium import webdriver as driver

menu = Select(driver.find_element_by_id('BodyContent__company'))
name=input('Enter company name: ')
for option in menu.options:
    if option.text == name:
        option.click()
    else:
        pass
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352