2016-08-30 17 views
0

select型のドロップダウンメニュー内のデータを消去したいが、select.clear()を使用することはできません "要素はユーザが編集可能でなければなりませんそれをクリアするために "、それは完全な意味を作る。それぞれのフィールドをクリアするためにどのコマンドを使用するのか知っていますか?SeleniumのドロップダウンメニューをJavaでクリアする方法

+1

によって選択することができます。あなたの推測では、単純な選択ドロップダウンがあります。 – Grasshopper

答えて

1

要素に<select>というタグがある場合は、相互作用のために選択クラスを使用できます。

// first, initialize the WebElement (using the appropriate selector type, this is just an example) 
WebElement element = driver.findElement(By.id("elementId")); 

// next, pass it to the Select object 
Select selectElement = new Select(element); 

// then, select an option from the element 
selectElement.selectByVisibleText("Option Text"); 

我々はまた、あなたが空白のオプションを持っている場合は、その選択をインデックスまたは値(documentation

// finally, to clear your selection, try: 
selectElement.deselectAll(); 
関連する問題