How can i select an item from drop-down list, i have tried all the 3 ways to select but unfortunately unable to select the desired one.

Unable to select the item from drop-down list.


i need to select an option from this html class = “ng-dropdown-panel ng-star-inserted ng-select-top” as shown in the picture.Please help me to get this

1 Like

Hi there,

Thank you very much for your topic. Please note that it may take a little while before a member of our community or from Katalon team responds to you.

Thanks!

Hi @hidinv44,
You could try using WebUI.click(findTestObject(yourObject)) or WebUI.enhancedClick(findTestObject(yourObject)) where the object has the following XPath.

(//*[contains(@class, 'ng-dropdown-panel ng-star-inserted ng-select-top')])[1] where [1] is the first item to be selected. You would use [2] and so on to pick the other items.

You could also try changing up contains to change the XPath to something like this (//*[contains(@class, 'ng-dropdown-panel')])[1] where [1] is the first item to be selected. You would use [2] and so on to pick the other items.

Use Condition to try some other locator methods…
The following would result in XPath: (//*[contains(@class, 'ng-dropdown-panel')])[1]

Not sure you can use the “selectOptionByXXX” on a <ng-select> tag. However, another possibility is to collect the “drop-down” items into a list and then go through the list until you find the item you want.

How to handle web table in Katalon Studio | by Katalon | Katalon | Medium

TestObject myItem = com.Tools.makeTO("//*[contains(@class, 'ng-dropdown-panel ng-star-inserted ng-select-top')]")
WebUI.waitForElementVisible(myItem, 10)
List<WebElement> myList= WebUI.findWebElements(myItem, 10)

WebUI.comment("Number of items is ${myList.size().toString()}")

for (cnt = 0; cnt < myList.size(); cnt++) { ...

Edit: if the number of items exceed the count within a specific drop-down, then you may have to quantify the specific “formcontrolname” before you get your web elements.

Maybe:

Something like below gets the control and then gets “input” elements within that control. If your app does not have “input” elements, then see what works for you:

def sysLookupList = com.Slider.findControl(driver, "InjectorType");

List<WebElement> listOptions = null;
try {
	listOptions = sysLookupList.findElements(By.cssSelector("input[value='${strModule}']"));
} catch (Exception) {
	listOptions = null;
}
if (listOptions != null) {

	if (listOptions.size() > 0)
	{
		if (listOptions.get(0).isDisplayed())
		{
			listOptions.get(0).click();
		}
	}
}

Edit: do you have a <form> tag above the view that you have shown? You may have to use that too.

Did you try option Select by Label ?

You are testing an Angular website. Selenium and Katalon’s select methods do not work. The possible solution is to first click on the dropdown list and then click the option.

Hope this helps.

1 Like