How to use java to calculate the number of options in the selection drop-down box in selenium webdriver?

I have a selection drop-down list:

xpath //*[@id="ddlTablePay"]

I need to calculate the number of options in this drop-down menu thank you

Solution

use. Getoptions () method and store them in the 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

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>