Select a dropdown by label

I have several scripts working correctly but struggling with a dropdown. I would like to read a value from Excel and select that value from a dropdown list. This is a subset of my code.

LastRC = findTestData(‘List of ratecard levels’).getValue(‘Name’, index)

WebUI.selectOptionByLabel(findTestObject(‘Object Repository/Ratecard/Page_TecEFX/select_’), LastRC, false)

WebUI.verifyOptionSelectedByLabel(findTestObject(‘Object Repository/Ratecard/Page_TecEFX/select_’), LastRC, false,
60)
I’m pretty certain that LastRC has a value that is in the dropdown but how do I check this, println?

I am expecting an exact match, anything wrong with that code?

Thank you

This is the error code log…
2019-12-07 17:25:05.320 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/Add ratecard levels FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to select option by label
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword.selectOptionByLabel(SelectOptionByLabelKeyword.groovy:98)
at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword.execute(SelectOptionByLabelKeyword.groovy:71)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:60)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.selectOptionByLabel(WebUiBuiltInKeywords.groovy:1200)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$selectOptionByLabel$5.call(Unknown Source)
at Add ratecard levels.run(Add ratecard levels:27)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1575739306755.run(TempTestCase1575739306755.groovy:23)
Caused by: java.lang.IllegalArgumentException: Object is null
at com.kms.katalon.core.helper.KeywordHelper.checkTestObjectParameter(KeywordHelper.java:33)
at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword$_selectOptionByLabel_closure1.doCall(SelectOptionByLabelKeyword.groovy:80)
at com.kms.katalon.core.webui.keyword.builtin.SelectOptionByLabelKeyword$_selectOptionByLabel_closure1.call(SelectOptionByLabelKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)

This means that the Test Object is null. Can you provide the relevant test script you’re currently using ? And also make sure you can open the Test Object at the test step which is failing. To check this, in the Manual mode of the test case, you can right click on the object and choose ‘Open {name of test object}’.

1 Like

Thanks, that got me looking in the right place. When I captured the drop down they got named like ‘Select_ Value 1 Value 2’ hence Select_ didn’t exist. I removed the values from the name and it worked.
I’m puzzled as to why Web Record would name the object such that the name included the current values.
But this fixed my problem. Thank you.

1 Like