Handle Datalist

Hi, I’ve problem with datalist. How to select datalist when I type on text?


and how you do it when you test manually?
can’t you repeat that in script?

This is my test on script :slight_smile:

textWebUI.callTestCase(findTestCase('SPI Non PO/Master/Login'), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase('SPI Non PO/Master/nvNonPO'), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject('Input PKS/btnAddNewPKS'))

WebUI.setText(findTestObject('Input PKS/txtPKSNumber'), 'PKS/AUTOMATE/001')

WebUI.clearText(findTestObject('Input PKS/txtPKSAmount'), FailureHandling.STOP_ON_FAILURE)

WebUI.setText(findTestObject('Input PKS/txtPKSAmount'), '15000000')

WebUI.setText(findTestObject('Input PKS/txtSONumber'), '123456789')

WebUI.setText(findTestObject('Input PKS/txtNPWP'), '123456789')

WebUI.selectAllOption(findTestObject('Input PKS/ddlBillingType'))

WebUI.selectOptionByLabel(findTestObject('Input PKS/ddlBillingType'), 'FULL  :  BAST 100% MAINT RUTIN (14 days after receiving completed invoice)', 

WebUI.setText(findTestObject('Input PKS/txtSite'), 'ter')

WebUI.click(findTestObject('Input PKS/Datalist'))`

And the error :

com.kms.katalon.core.exception.StepFailedException: Unable to click on object 'Object Repository/Input PKS/Datalist'

You have two issues

  1. the WebUI.select* APIs only work with HTML select elements.
  2. Datalists are a fudge - a shameful, “thrown together from the other side of the room” by the HTML spec/people. They are not descendant/related to the text control they appear on except by reference.

I’m guessing but I think your best bet is to focus the text control and use Send Keys.

1 Like

Hi, Rus. Thank you for your advice!

But it still not work for me.

WebUI.callTestCase(findTestCase(‘SPI Non PO/Master/Login’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.callTestCase(findTestCase(‘SPI Non PO/Master/nvNonPO’), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject(‘Input PKS/btnAddNewPKS’))

WebUI.setText(findTestObject(‘Input PKS/txtPKSNumber’), ‘PKS/AUTOMATE/001’)

WebUI.clearText(findTestObject(‘Input PKS/txtPKSAmount’), FailureHandling.STOP_ON_FAILURE)

WebUI.setText(findTestObject(‘Input PKS/txtPKSAmount’), ‘15000000’)

WebUI.setText(findTestObject(‘Input PKS/txtSONumber’), ‘123456789’)

WebUI.setText(findTestObject(‘Input PKS/txtNPWP’), ‘123456789’)

WebUI.selectAllOption(findTestObject(‘Input PKS/ddlBillingType’))

WebUI.selectOptionByLabel(findTestObject(‘Input PKS/ddlBillingType’), ‘FULL : BAST 100% MAINT RUTIN (14 days after receiving completed invoice)’,

WebUI.setText(findTestObject(‘Input PKS/txtSite’), ‘ter’)


WebUI.sendKeys(findTestObject(‘Input PKS/txtSite’), Keys.chord(Keys.ARROW_DOWN))



You want sendKeys, not setText.

I have a suspicion that the page is not using the datalist directly on the input type=text control. Can you send a copy of the html when the dropdown is active?

@Andrej_Podhajsky can take a look while I get my beauty sleep (which I need, badly) :stuck_out_tongue_winking_eye:

before typed ‘ter’

after typed ‘ter’ on text, datalist it will be assigned value

after I choose one of them

can you try to send those keystrokes directly to datalist?

Still not working

sendKeys(findTestObject(“Input PKS/Datalist”), Keys.chord(ARROW_DOWN, ARROW_DOWN)) FAILED.
com.kms.katalon.core.exception.StepFailedException: Unable to send keys ‘’ to object

can you please post whole exception? which element is set to process keydown evenst?