How to count the number of options in a select drop down box in Selenium WebDriver using Java?

eclipse, java, selenium, selenium-webdriver

Solution

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();

Problem

I have Select Dropdown list with this: ``` xpath //*[@id="ddlTablePay"] ``` I need to count the number of options in this drop-down. Thank You

Original source