Issue with drop down box

Hello,

I have a drop down box which is showed here:

The object is captured as //label[@id=‘contactDetailSubviewId:contactDetailForm:contactDetailComboBox_label’]. I tried to select the options using index.

WebUI.selectOptionByIndex(findTestObject(‘My contact//label_—Select Contact Type—’), 1) but katalon throws error as

selectOptionByIndex(findTestObject(“My contact/label_—Select Contact Type—”), 1) FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to select option by index ‘1’ of object ‘Object Repository/My contact/label_—Select Contact Type—’
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:48)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)

Any thoughts on this? Please help.

Regards,
Neethu

Hi,
did you try WebUI.selectOptionByLabel?

Hello @neethu73
I was getting an error because of the structure used in the design. You can check my text. I hope it helps.

Hi @Marek_Melocik,

Yes i have tried, but no luck.

selectOptionByLabel(findTestObject(“My contact/label_—Select Contact Type—”), “Fax”, false) FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to select option by label ‘Fax’ of object ‘Object Repository/My contact/label_—Select Contact Type—’
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:48)

Hi @emine

Yes in this way, i have to capture each element from the drop down and click on the item which I want. But still, if we have so many items from the drop down and I want to make a random selection, then I may go for select by index option. Is that error i stated is because of the span element?

@neethu73
As I saw in the screenshot, select Option By Index does not work in these structures, but selects the item in the Select box field but does not select the item.
The test will be successful if the article I have submitted for this is applied.

Thanks @emine . It works.

Me too thank .Good work…

Hello Emine. I think your recommendation will resolve a lot of problems that I encounter with selecting an item in a dropdown list. I am not certain how to “right click on the item to select // right click to detect the item”. On the Mac, right clicking on California in the dropdown brings up the box, see screenshot below.

I must not fully understand how to perform the right click operation in this context. Can you elaborate?

hello @dcody

Katalon Studio detects when we click on the select box in the test case record stage. And it opens the list of options below. However, it does not detect when selecting an item from the list.

To do this, point to the relevant item and press the right side of the mouse to select the corresponding option in our test case step.

Then after saving the Test Case finishes:
As right click, we apply the other steps in the same way as in my article for the expression in the test case steps.