2016-04-01 96 views
2

Selenium Pythonのドロップダウンフィールドから値を選択しています。Selenium Python AttributeError: 'WebElement'オブジェクトに 'select_by_visible_text'属性がありません

def select_dataset_from_dataset_dropdown(self): 
    dataset_drop_down_element = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable((By.ID, 'search_variables_lb_datasets'))) 
    dataset_drop_down_element.select_by_visible_text(str("Query (Query)")) 

HTMLは次のとおりです:

<select id="search_variables_lb_datasets" class="gwt-ListBox marginbelow" style="display: inline;"> 
<option value="-">-</option> 
<option value="CRM">CRM</option> 
<option value="ESCR">ESCR</option> 
<option value="ORCHARD">ORCHARD</option> 
<option value="Edit_test">Edit_test</option> 
<option value="Query (Query)">Query (Query)</option> 
</select> 
私は値「クエリを選択したいと思います

(ダウンしているドロップを選択するために

AttributeError: 'WebElement' object has no attribute 'select_by_visible_text' 

私の方法:私はエラーを取得していますクエリ)」

この値を選択できますか?

エラートレースがある:

Traceback (most recent call last): 
    File "C:\Webdriver\ClearCore Regression Test\ClearCore - Regression Test\TestCases\StructuredSearch_TestCase.py", line 54, in test_00001_create_search_query_dataset_for_search_and_check_search_variables_dm_query_variables_are_displayed 
    search_variables_dm_query_page.select_datamap_and_dataset_from_the_dropdown() 
    File "C:\Webdriver\ClearCore Regression Test\ClearCore - Regression Test\Pages\Structured_Search\search_dm_query_page.py", line 90, in select_datamap_and_dataset_from_the_dropdown 
    self.select_dataset_from_dataset_dropdown() 
    File "C:\Webdriver\ClearCore Regression Test\ClearCore - Regression Test\Pages\Structured_Search\search_dm_query_page.py", line 79, in select_dataset_from_dataset_dropdown 
    dataset_drop_down_element.select_by_visible_text(str("Query (Query)")) 
AttributeError: 'WebElement' object has no attribute 'select_by_visible_text' 

おかげで、リアズ

答えて

5

select_by_visible_text()方法は、それをインスタンス化し、Selectクラスで提供されています:

from selenium.webdriver.support.select import Select 

dataset_drop_down_element = WebDriverWait(self.driver, 20).until(EC.element_to_be_clickable((By.ID, 'search_variables_lb_datasets'))) 
dataset_drop_down_element = Select(dataset_drop_down_element) 
+0

ああ、私は選択を忘れてしまいました。それは今働いている。ご協力いただきありがとうございます。 –

関連する問題