I am trying to validate dropdowns using Selenium and Java, I have a resuable component written as below
public static void verifyExpectedAndActualOptionsInDropdown(
WebElement element, List<String> listOfOptions) {
Select ele = new Select(element);
/*
* List<String> ds = new ArrayList<String>(); ds.add("Asia");
* ds.add("Europe"); ds.add("Africa");
*/
List<String> expectedOptions = listOfOptions;
List<String> actualOptions = new ArrayList<String>();
for (WebElement option : ele.getOptions()) {
System.out.println("Dropdown options are: " + option.getText());
actualOptions.add(option.getText());
}
System.out.println("Numbers of options present in the dropdown: "
+ actualOptions.size());
Assert.assertEquals(expectedOptions.toArray(), actualOptions.toArray());
}
I wanted to create a Java Action in RedwoodHQ for this method where Webelement has to be passed from TestCases Tab. Could anyone help?