我有一个大约10个元素包含帐户号的选择列表框。与平衡。这些余额有时会变化,有时会变为零,我想做的是在运行时选择账户余额为正的选项。LB中的文本格式为:Acc没有。(INR 12345:SomeText)
提前感谢。
-
load select option
-
get select option xpath
-
则获取option元素
中的所有文本 -
你的逻辑
List<WebElement> allOptions = driver.findElements(optionXpath); List<String> optionHasMoreMoney = new ArrayList<String>(); for(WebElement eachEle: allOptions){ long amount = Long.parseLong(eachEle.getText()); if(amount > 0){ optionHasMoreMoney.add(eachEle.getText()); } } // list of options which has more money Select select = new Select("your select element"); select.selectByValue(optionHasMoreMoney.get(0));