How to count the number of contents (Values) in the drop down using selenium webdriver?
First we need to store the contents of DDL into one string. Then we need to split that string by line (\n).
Normally it will count "-Select-" as a string. So we need minus 1 from the array length.
WebElement J = driver.findElement(By.id("ddlType"));
String text = J.getText();
String[] DDLcount =text.split("\n");
System.out.println("Count of DDL contents:" +(DDLcount.length-1));