Drop down options lists are not shown and I need to check that they exist and they’re names

So i am testing a website with many drop downs, but all the options that we get are from the Database, so it’s not a list from the Front end, but some of the drop downs are static, and i need to check that it contains 3 items named X Y and Z.

I know someone spammed with this question but i got no help from those questions/answers.

 

Thanks in advance

Meanwhileyou may try create custom keyword as below. You need add List of strings from the Manual Mode

import org.openqa.selenium.WebElement
import org.openqa.selenium.support.ui.Select
import org.testng.Assert

import com.kms.katalon.core.annotation.Keyword

public class VerifyExpectedAndActualOptionsInDropdown {
@Keyword
public static void VerifyExpectedAndActual(WebElement element, List<String> listOfOptions) {
try {
Select ele = new Select(element);
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());
}

Assert.assertEquals(expectedOptions.toArray(), actualOptions.toArray());
} catch (Exception e) {

Assert.fail(e.getMessage());
}
}

}

Hi Francisc,

We are implementing a keyword named “Verify Options Present” that meets your expectation. Please stay tune and wait for our next release.

Thanks.