Hi Ashwin,
I would suggest to you use List instead of String to store the values. You could use WebDriver to achieve this as following -
// List to hold drop down values
List<String>dropDownValues = new ArrayList<String>();
// List to hold drop down elements in drop down
List<WebElement> dropDownElement = new Select(driver.findElement(By
.cssSelector("drop down locator"))).getAllSelectedOptions();
// Store drop down values
for(WebElement element: dropDownElement) {
dropDownValues.add(element.getText());
}
// Print drop down values
for(String value: dropDownValues) {
System.out.println(value);
}Let us know if you have any doubt.
~ seleniumtests.com