2017-08-10 123 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! –

相关问题