【发布时间】:2017-03-30 16:20:58
【问题描述】:
请有人帮我完成这个..
我想为下拉菜单编写 selenium 代码。当我尝试使用以下语法时。我在 Eclipse 中遇到此错误“WebElement 类型的方法 selectByValue(String) 未定义”。
我使用以下语法:
ele.selectByIndex(5);
ele.selectByValue("3");
ele.selectByVisibleText(Feb);
提前谢谢...
我在找到解决方案后进行了更新。 我已经编写了这样的代码供其他人使用。它对我来说很好。
public void selectCreditCardType(WebElement selectCreditCardType) throws Exception {
logger.info("Select Card");
browser.selectByText(selectCreditCardType, "Visa Card");
browser.Wait(10);
}
【问题讨论】:
-
可能你的元素
ele没有value属性