2017-08-10 121 views
-1

enter image description here選擇從下拉菜單中硒的webdriver

enter image description here

選擇一天月份和年份從下拉這顯示雙方在Java的網絡驅動器在Firefox錯誤和鉻的一天。

請告訴我如何做這類降下來

+1

不張貼代碼爲圖像。 –

+1

請張貼適當的細節,如元素的HTML代碼段,代碼的努力,你嘗試過什麼了,到目前爲止和完整的堆棧跟蹤一個問題因此,它可能更容易理解你的問題,有人幫你 – NarendraR

+1

我猜,你正在使用deselectByIndex()方法代替selectByIndex()。請嘗試用selectByIndex(1)或selectByVisibleText( 「四月」)。 – Murthi

回答

0
import org.openqa.selenium.support.ui.Select; 

public void selectDropdownOption(WebDriver driver, By by, String value) 
{ 
    Select selectList = new Select(driver.findElement(by)); 
    selectList.selectByValue(value); 
} 

Usage: 

selectDropdownOption(driver, By.xpath("//select[@id='dob_month']"), "December"); 

我希望這可以幫助你!

+0

感謝sniperd! –

相關問題