How to get text of li element

I have the following drop down in the UI:

I need to get the text of the first element in the drop down but I can’t seem to figure out how to do that. The values in the drop down change in different environments.
I’m able to use the code below to click on the first element to select it:

TestObject deal = new TestObject()

deal.setSelectorValue(SelectorMethod.CSS, ‘#OppSummDealID_listbox li:nth-child(1)’)



But any other actions I try to perform on the deal object fail with an error, saying the object is null.

The html is:



Since you have the test object defined, perhaps you may try to get the element's text accordingly. eg. WebElement.getText() 

Doing deal.getText() gives me this error:

[ERROR] -(Stack trace: groovy.lang.MissingMethodException: No signature of method: com.kms.katalon.core.testobject.TestObject.getText() is applicable for argument types: () values: []

Possible solutions: getAt(java.lang.String), getClass(), getXpaths(), collect(), inspect(), grep()

Ok figured it out, well sort of. After I click on the first element, the drop down box is populated with that value. So then all I have to do is a .getText() on the drop down box object and I get the string. more of work around I guess but it gets me what I need.

Good to hear that.