如何使用Java计算Selenium WebDriver选择下拉框中的选项数量? [英] How to count the number of options in a select drop down box in Selenium WebDriver using Java?
本文介绍了如何使用Java计算Selenium WebDriver选择下拉框中的选项数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
使用 .getOptions()
方法并将它们存储在列表中。然后找到它的大小。
选择se = new Select driver.findElement(By.id(select drop down locator)));
列表< WebElement> l = se.getOptions();
l.size();
-Ajay
I have Select Dropdown list with xpath //*[@id="ddlTablePay"]. I need to count the number of options in this dropdown.Thank You
解决方案
Use .getOptions()
method and store them in a list .Then find its size.
Select se = new Select(driver.findElement(By.id("select drop down locator")));
List<WebElement> l = se.getOptions();
l.size();
-Ajay
这篇关于如何使用Java计算Selenium WebDriver选择下拉框中的选项数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文