現在、Select 要素内で現在選択されているオプションの値を見つけることができるメソッドを作成するのに苦労しています。
<select id="select_foo_bar">
<option value="0">FOO</option>
<option value="1" selected="selected">BAR</option>
<option value ="2">FOOBAR</option>
</select>
現在、私はこれを持っています:
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")
私が理解しているように、そのメソッドはoption
要素を見つけて取得し、value
それを返します。
残念ながら、エラーが表示されますTypeError: 'WebElement' object is not callable
。これはoption = Select(self.driver.find_element_by_id("select_foo_bar")).first_selected_option()
回線上で発生しています。return
発言の要点にも達していません。
どんな助けでもありがたく受け取られます。