我想获取从下拉列表中选择的文本并打印
List<Person> test = new ArrayList<>();
test.stream().filter(s -> s.getFirstName().equals("John")).findFirst();
答案 0 :(得分:0)
您可以使用以下代码:
Select dropDown = new Select(Driver.findElement(PUT_YOUR_ELEMENTS_XPATH_CSS_OR_OTHER)));
List<WebElement> e = dropDown.getOptions();
int size = e.size();
for(int x = 0; x < size; x++)
{
System.out.println(e.get(x).getText());
if (e.get(l).getText().equals("February") {
System.out.println("I found february")
} else {
System.out.println("I can't see Fenruary")
}
}
希望对您有帮助!