Unable to set text of object

Hi

I have tried literally everything i can think of and now im stumped. Im trying to input text into a field and it just keeps giving me the same unable to set text error.

Ive tried focus, javascript input, nothing works.

Script NO1
WebUI.click(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/a_Insert New Record'))
WebUI.click(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/span_Pay Details'))
WebUI.delay(5)
WebUI.setText(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/input_Basic Pay ()_JobPayItemAnnotated.JobPay.JpyBasicPay'),   '75000')
WebUI.setText(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/input_Hours_JobPayItemAnnotated.JobPay.JpyHours'),  '38')
WebUI.click(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/button_Update'))
WebUI.click(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/button_Update_1'))
Script no2
WebUI.callTestCase(findTestCase('touchpoint examples/Login and Select an employee - HR - 9.1'), [:], FailureHandling.STOP_ON_FAILURE)
WebUI.click(findTestObject('Job and pay/Page_CIPHR Self Service 9.0.3/a_Insert New Record'))
WebUI.click(findTestObject('Job and pay/Page_CIPHR Self Service 9.0.3/span_Pay Details'))
WebUI.delay(5)
WebElement element = WebUiCommonHelper.findWebElement(findTestObject('Job and pay/last attempt/input_Basic Pay ()_k-formatted-value k-input valid'),  30)
WebUI.executeJavaScript('arguments[0].value=\'50000\';', Arrays.asList(element))

Html of the field -
<input type="text" class="k-formatted-value k-input valid" title="45,000.00" tabindex="0" role="spinbutton" aria-valuenow="45000" aria-disabled="false" style="" aria-invalid="false">

1 Like

i know it’s probably stupid question -
what you need to do, to set that field when you do that manually?

click on the field - clear the text - then input the new text

1 Like

in that case try before insert text also put click on field like:

WebUI.click(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/input_Basic Pay ()_JobPayItemAnnotated.JobPay.JpyBasicPay'))
WebUI.setText(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/input_Basic Pay ()_JobPayItemAnnotated.JobPay.JpyBasicPay'),   '75000')

I have tried this before and it doesnt work - it sets the cursor in the field which is good but then still cant set the text - this is the same if i use focus. I have then tried the clear text step to see if that will allow it to set text but still nothing

2 Likes

did you also try sendKeys? to simulate keystrokes…

It literally just popped into my head before you typed it - ill try now and see what i get

2 Likes

if not, last thing can be use of awt.Robot

1 Like

First thing I notice is, that it’s not a normal input text field. It has tabindex=“0” - that means it must be handled in a different.

In such situation I recommend to use the katalon object spy to identify the object. Does the generated object look similar to your object model?

If so, try to record this small step with the katalon recorder

Good luck!

1 Like

If it try using send keys i recieve this

Test Cases/touchpoint examples/aaaaaa FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to send keys ‘’ to object ‘Object Repository/testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid’
at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:48)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)

Script
WebUI.callTestCase(findTestCase('touchpoint examples/Login and Select an employee - HR - 9.1'), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/a_Insert New Record'))

WebUI.click(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/span_Pay Details'))

WebUI.delay(5)

WebUI.focus(findTestObject('testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid'))

WebUI.sendKeys(findTestObject('testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid'), Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid'), Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid'), Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid'), Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid'), Keys.chord(Keys.BACK_SPACE))

WebUI.setText(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/input_Hours_JobPayItemAnnotated.JobPay.JpyHours'), 
    '38')

WebUI.setText(findTestObject('testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid'), '75000')

WebUI.click(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/button_Update'))

WebUI.click(findTestObject('Object Repository/testing/Page_CIPHR Self Service 9.1.0/button_Update_1'))
1 Like

I must add - when i attempt to use JS it gives me a different error in that it cant find the object which doesnt make sense to me as it can focus on the element fine -

Error

Test Cases/touchpoint examples/Create job and pay record - HR - 9.1 - Copy FAILED.
Reason:
com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid’ located by ‘By.xpath: (//input[@type=‘text’])[25]’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1053)
at com.kms.katalon.core.webui.common.WebUiCommonHelper$findWebElement.call(Unknown Source)
at Create job and pay record - HR - 9.1 - Copy.run(Create job and pay record - HR - 9.1 - Copy:28)

WebUI.callTestCase(findTestCase('touchpoint examples/Login and Select an employee - HR - 9.1'), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject('Job and pay/Page_CIPHR Self Service 9.0.3/a_Insert New Record'))

WebUI.click(findTestObject('Job and pay/Page_CIPHR Self Service 9.0.3/span_Pay Details'))

WebUI.delay(5)

WebUI.focus(findTestObject('testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid'))

WebElement element = WebUiCommonHelper.findWebElement(findTestObject('testing/help pls/input_Basic Pay ()_k-formatted-value k-input valid'), 
    30)

WebUI.executeJavaScript('arguments[0].value=\'50000\';', Arrays.asList(element))
1 Like

I haven’t read through all of this @hpulsford but I’m suspecting you’re targeting the wrong element.

Question: In your first image, are you targeting the highlighted element (the one selected as blue)? That’s the wrong element. The TEXT element is the next one in the image (I think).

This one:

Right so ive made some progress -

@Russ_Thomas - your correct, this is the element for the text, however it could not locate this when i tried using just this element - ive now got it working in the way that it will focus on the element - then ive used send keys to remove the number that was originally in the element - so is partially working.

However its still giving me unable to set text ‘’ of object when i attempt to enter in the number. Could be anything to do with the field only accepting integers?

1 Like

It’s your AUT. Go play and let us know!

1 Like

Even if it is the AUT not allowing the txt to be inputted, doesnt explain why the JS cannot locate the element ?

WebElement element = WebUiCommonHelper.findWebElement(findTestObject('testing/Page_CIPHR Self Service 9.1.0/input_Basic Pay ()_JobPayItemAnnotated.JobPay.JpyBasicPay'), 
    30)

Shouldnt this still work after ive used the send keys? :woozy_face:

That being said, i will take a further look into this page.

1 Like

that’s a big IF.

Fix it man.

Want me to be brutal?

JS can locate the element. You on the other hand… :confused: :wink:

Come on… get your hands in there and fix the damn thing. :nerd_face:

:rofl::rofl:

Yep - will let you know how it goes

2 Likes

All done :smile:

1 Like

And the fix was…?

For some reason the field was becoming read only even when attempting to insert just integers, if im honest i dont know how it was so broken with out me noticing :rofl:. Eithey way i played about with the code and got it working. Although i still have to use the key strokes to clear the text but now sets text fine, still checking that only numbers are inserted.

My script now looks like this.

Script
WebUI.callTestCase(findTestCase('touchpoint examples/Login and Select an employee - HR - 9.1'), [:], FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject('Job and pay/Page_CIPHR Self Service 9.0.3/a_Insert New Record'))

WebUI.click(findTestObject('Job and pay/Page_CIPHR Self Service 9.1.0/span_Pay Details'))

WebUI.delay(5)

WebUI.focus(findTestObject('Job and pay/last attempt/input_Basic Pay ()_k-formatted-value k-input valid'))

WebUI.sendKeys(findTestObject('Job and pay/jpy verify inputting data/input_Basic Pay ()_JobPayItemAnnotated.JobPay.JpyBasicPay'), 
    Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('Job and pay/jpy verify inputting data/input_Basic Pay ()_JobPayItemAnnotated.JobPay.JpyBasicPay'), 
    Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('Job and pay/jpy verify inputting data/input_Basic Pay ()_JobPayItemAnnotated.JobPay.JpyBasicPay'), 
    Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('Job and pay/jpy verify inputting data/input_Basic Pay ()_JobPayItemAnnotated.JobPay.JpyBasicPay'), 
    Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('Job and pay/jpy verify inputting data/input_Basic Pay ()_JobPayItemAnnotated.JobPay.JpyBasicPay'), 
    Keys.chord(Keys.BACK_SPACE))

WebUI.setText(findTestObject('Job and pay/jpy verify inputting data/input_Basic Pay ()_JobPayItemAnnotated.JobPay.JpyBasicPay'), 
    basic_pay)

WebUI.delay(2)

WebUI.focus(findTestObject('Job and pay/last attempt/Hours verify/input_Hours_k-formatted-value k-input valid'))

WebUI.sendKeys(findTestObject('Job and pay/jpy verify inputting data/input_Hours_JobPayItemAnnotated.JobPay.JpyHours'), 
    Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('Job and pay/jpy verify inputting data/input_Hours_JobPayItemAnnotated.JobPay.JpyHours'), 
    Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('Job and pay/jpy verify inputting data/input_Hours_JobPayItemAnnotated.JobPay.JpyHours'), 
    Keys.chord(Keys.BACK_SPACE))

WebUI.sendKeys(findTestObject('Job and pay/jpy verify inputting data/input_Hours_JobPayItemAnnotated.JobPay.JpyHours'), 
    Keys.chord(Keys.BACK_SPACE))

WebUI.setText(findTestObject('Job and pay/jpy verify inputting data/input_Hours_JobPayItemAnnotated.JobPay.JpyHours'), hours)

WebUI.delay(2)

WebUI.click(findTestObject('Job and pay/Page_CIPHR Self Service 9.0.3/button_Update'))

WebUI.delay(5)

WebUI.verifyElementVisible(findTestObject('Job and pay/Page_CIPHR Self Service 9.0.3/button_Update_1'), FailureHandling.STOP_ON_FAILURE)

WebUI.click(findTestObject('Job and pay/Page_CIPHR Self Service 9.0.3/button_Update_1'))

WebUI.delay(10)

if (WebUI.verifyElementVisible(findTestObject('Job and pay/verify elements expected/button_OK'), FailureHandling.OPTIONAL)) {
    WebUI.click(findTestObject('Job and pay/verify elements expected/button_OK'))

    WebUI.waitForElementVisible(findTestObject('Job and pay/select jpy record/td_Increase Amount_row-select'), 0)

    WebUI.click(findTestObject('Job and pay/select jpy record/td_Increase Amount_row-select'))
} else {
    WebUI.waitForElementVisible(findTestObject('Job and pay/select jpy record/td_Increase Amount_row-select'), 0)

    WebUI.click(findTestObject('Job and pay/select jpy record/td_Increase Amount_row-select'))
}

WebUI.click(findTestObject('Page_CIPHR Self Service 9.0.3/span_Pay Details'))

WebUI.verifyElementAttributeValue(findTestObject('Job and pay/last attempt/input_Basic Pay ()_k-formatted-value k-input valid'), 
    'aria-valuenow', basic_pay, 0)

WebUI.verifyElementAttributeValue(findTestObject('Job and pay/verify elements expected/input_FTE_JobPayItemAnnotated.'), 
    'aria-valuenow', fte, 0)

WebUI.verifyElementAttributeValue(findTestObject('Job and pay/verify elements expected/input_Hourly Rate ()_JobPayIte'), 
    'aria-valuenow', hourly_rate, 0)

object1 = WebUI.getAttribute(findTestObject('Job and pay/last attempt/input_Basic Pay ()_k-formatted-value k-input valid'), 
    'aria-valuenow')

object2 = WebUI.getAttribute(findTestObject('Job and pay/verify elements expected/input_Home Currency Basic Pay'), 'aria-valuenow')

WebUI.verifyEqual(object1, object2)

object3 = WebUI.getAttribute(findTestObject('Job and pay/verify elements expected/input_Annual Pay ()_JobPayItem'), 'aria-valuenow')

WebUI.verifyEqual(object1, object3)
1 Like