I'm currently experiencing some difficulties writing a method that will allow me to find the value of the currently selected option within a Select element.
<select id="select_foo_bar">
<option value="0">FOO</option>
<option value="1" selected="selected">BAR</option>
<option value ="2">FOOBAR</option>
</select>
Currently I have this:
def find_selected_option(self):
self.wait.until(EC.presence_of_element_location((By.ID, "select_foo_bar"))
option = Select(self.driver.find_element_by_id("select_foo_bar")).first_selected_option()
return option.get_attribute("value")
As I understand it, that method will find the option
element, get the value
and return it.
Unfortunately, I'm receiving the error TypeError: 'WebElement' object is not callable
. This is occurring on the option = Select(self.driver.find_element_by_id("select_foo_bar")).first_selected_option()
line. It doesn't even reach the point of the return
statement.
Any help would be gratefully received.