Home > Mobile >  TypeError: 'Select' object is not callable error selecting an option from a dropdown using
TypeError: 'Select' object is not callable error selecting an option from a dropdown using

Time:09-02

I'm seeing an error:

TypeError: 'Select' object is not callable 

while selecting an option from a dropdown using Selenium Python.

Code trials:

Select = Select(driver.find_element(By.NAME, "delivery-size_type"))
Select.select_by_visible_text("Big")

Element snapshot:

enter image description here

CodePudding user response:

My assumption is that this is a capitalization issue. Your variable name is Select which is also the name of the Select class. Try this instead...

dropdown = Select(driver.find_element(By.NAME, "delivery-size_type"))
dropdown.select_by_visible_text("Big")

CodePudding user response:

This error message...

TypeError: 'Select' object is not callable

...implies that you have tried to call select_by_visible_text() method on the Select class. You need to call select_by_visible_text() method on the object instead.


Solution

You need to differentiate between the name of the class and it's object. Both can't be same. Your effective code block will be:

select = Select(driver.find_element(By.NAME, "delivery-size_type")) 
select.select_by_visible_text("Big")
  • Related