Cannot select the item from dropdown list

I have a dropdown for user-type.
When I record the steps, I am selecting the 3rd item from the list.
When I execute the test case, It is clicking on the dropdown item and dropdown menu is shown to me. But it is not selecting the item. and test case got failed.

If you can, can you show us the HTML of the element to ensure it is a select tag for the drop-down list? Right click on the element and choose “Inspect” (do this twice).

2 Likes

Here is the html of the items

It looks like the aria-label contains the list of items, and each item has an id. Make an object in the OR that has an xpath of:
id("rc_select_0_list_2")

Then do a click on that element.

2 Likes

Thank you. I will try this

Make sure to click the dropdown button first!

For example:

public final class GeneralWebUIUtils { 
	public static void HandleDropdown(TestObject dropdownButton, TestObject dropdownSelection) { 
		WebUI.click(dropdownButton);

		WebUI.waitForElementVisible(dropdownSelection, 2);
		WebUI.click(dropdownSelection);
		WebUI.waitForElementNotVisible(dropdownSelection, 2);
	}
}

Save that to a Keyword, then call it from your Test Case like so:

GeneralWebUIUtils.HandleDropdown(roleDropdownBtn, // make Test Object for this
	findTestObject("Your Users Page/Add User Modal/Role Dropdown/Manager Dropdown selection"));

after doing the following:

  • create some role dropdown button in the Object Repository (I cannot see the HTML for it in your screenshot)
  • create some test object for the dropdown selection, call it "Your Users Page/Add User Modal/Role Dropdown/Manager Dropdown selection" (or something similar), and use the xpath //div[@aria-label = 'Moderator'] .

That would be how I approach this

1 Like