String variable in which I want to pass as a value to Droddown: Error Msg: java.lang.IllegalArgumentException: Object is null

Hi All,

I have a String variable in which I want to pass as a value to Droddown. I am getting this below error:

Caused by: java.lang.IllegalArgumentException: Object is null

com.kms.katalon.core.exception.StepFailedException: Unable to select option by value

And here is my code:

def sellerNameSelection = “Some Random Text”;

WebUI.selectOptionByValue(findTestObject(‘Object Repository/Page_Login Validation/selectVendorNameInDropdown’),
sellerNameSelection, false)

Please help me how to resolve this issue

You may not be familiar with the “Value” in the selectOptionByValue. The “Value” is found in the value attributes of the select tag which is found in the HTML of the web page.

If “Some Random Text" is what displays in the dropdown, then you want selectOptionByLabel instead.

Edit: And, obviously, the text for Label has to match with the display text and the text for Value has to match the value attribute text. If it doesn’t match, then you have to use Regular Expression to make a comparison instead. If you are not sure about RegEx, then ask.

1 Like

Branched this topic for you but accidentally missed the final response. Marking as correct and closing this thread.

pvulimiri

selected

4h

Thank you grylion54. This resolved my issue