[ASK] I have a problem with input and select option test

I keep getting an error message when I try to fill in a javascript drop down. Any help on how to fix this error ?

The form that I am trying to work on can be type manually and it would give suggestion and a drop down list that we have to click.

Details on the picture below

1 Like

Is it possible to see the HTML of the “Pengaduan DP 1” element?

Also note that you can also use, WebUI.findWebElement() method, rather than using the one associated with the CommonHelper.

Edit: I reread how the “drop-down” works and I have a similar(??) element for who assisted the customer/client. Are you just trying to “setText” or “sendKeys” to the element and that is what is not working? Not the selection of the drop-down–yet.

gCustAssist = 'JKT_GATEWAY'
WebUI.click(findTestObject('myPage/input_GeneralInfo.CustAssist'))
// throw in the name we will be searching for
WebUI.setText(findTestObject('myPage/input_GeneralInfo.CustAssist'), gCustAssist)
// wait until get search result back
WebUI.waitForElementVisible(findTestObject('myPage/h4_Worker Search'), 10)

The “h4_Worker Search” is a reference to the first item in the drop-down that I created for the OR of the pathway to this element. To figure that out, I had to right click on the first item of the drop-down and select “Inspect” (do this twice) and the HTML displays directly on the drop-down element. Alternatively, you can try with right click on the first item of the drop-down and select “Capture Object” and see if that works for you.
And finally, select my choice:

WebUI.click(findTestObject('myPage/h4_Worker Search'))
gFullName = WebUI.getAttribute(findTestObject('myPage/input_GeneralInfo.CustAssist'), 'value')
1 Like

@heri Welcome to the community

I too faced the same scenario in one of our applications.

There are 2 ways you can achieve this
1

  1. enter the value into the textbox using send keys or set text keyword
  2. take an object for the suggestion
  3. wait for the suggestion to appear
  4. click the suggestion

2

  1. enter the value into the textbox using send keys or set text keyword
  2. wait for a few seconds
  3. use WebUI.sendKeys(findTestObject(‘Test object of the textbox’), Keys.chord(Keys.DOWN, Keys.ENTER))

I hope the 2nd will help you if the auto suggestion is based on the data you are feeding into the textbox.

2 Likes