getFirstSelectedOption
当下拉列表中有大量值时,需要花费大量时间来返回所选值。
请检查以下代码:-
Select attributeDD = new Select(attributeSelection);
WebElement attributeWE = attributeDD.getFirstSelectedOption();
有没有一种方法或技术可以用更少的时间从下拉列表中获取所选值?
最佳答案
这将返回所选选项的 HTML 值
。我不确定这是否是您可以使用的东西,但它可能会更快。
System.out.println(driver.findElement(attributeSelection.getAttribute("value"));
...并且您不需要将其转换为 Select
。
关于java - 当下拉列表包含大量值时,getFirstSelectedOption 需要花费大量时间来返回所选值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32477308/