我想自动使用使用Java硒的网络驱动器的下拉菜单,但HTML页面有<option disabledselected>----</option>
(参考附截图)无法选择下拉菜单
我想从下拉菜单中选择第二个菜单项下。我尝试了很多东西,但每次我收到错误消息。
一号方法 - 使用ByVisibleText
:
public void selectHomeCommunity(String name){
Select hmecomm= new Select(hmecommdropdown);
hmecomm.selectByVisibleText(name);
}
public <Webelement> SelfRegistrationPage Community(String pass) {
// TODO Auto-generated method stub
enterPassKey(pass);
System.out.println("Entered into Community method");
pressGoBtn();
}
第二个方法 - JavascriptExecutor
:
((JavascriptExecutor)driver).executeScript("document.getElementById('hmecommdropdown').options.item(0).click().;");
第三届方法 - getFirstSelectedOption
:
String selectedLabel = new Select(driver.findElement(By.id("CommunityDropdown"))).getFirstSelectedOption().getText();
每当我得到同样的错误:
等待的能见度[[ChromeDriver:在XP (9a6751455dba60b65479430ff8f9aa00)铬] - > ID:CommunityDropdown]
分享请相关的HTML。 – DebanjanB
哪里截图..? –
请分享html DOM /网站网址。 –