Value is not printing in text box

Its a normal textbox and the value is not printing either sending thru excel or hardcoded. working fine in local whereas not working in server. I have tried in different ways like by capturing a new control, setting with different properties i.e xpath, attribute, css still no luck.
Please help if anyone has any answer

Thanks in Advance!!!

Can you show some HTML of the textbox so we can get more information on your concern?
Are you getting any error message or any feedback from KS when you do your setText()?

Here is the html code

input class=“class1” data-val=“true” data-val-length=“Zip Code must be 10 digits.” data-val-length-max=“10” id=“PostalCode” maxlength=“10” name=“PostalCode” type=“text” value=“” autocomplete=“off”

not seeing any errors in console

And what is the setText() statement you are using?

excel
WebUI.setText(findTestObject(‘input_PostalCode’), findTestData(‘CreateNewLocations’).getValue(17, 1))
hard code
WebUI.setText(findTestObject(‘input_PostalCode’), ‘61701’)

The “error” message indicates your Zip Code must be 10 digits (and I remember the TV show, ‘90210’, so 5 digits should be allowed) so is this a “bug” that you have found? Are you able to enter ‘61701’ manually into the textbox?

And, just curious, is there another textbox, or radio button, that dictates whether or not to use Canadian Postal Codes or American Zip Codes? Note: Canadian Postal Codes are ‘AnA nAn’ (alphanumeric), like T2G 1P7.

1 Like

that is just a validation message to display if the User enters less than 10 digits. moreover it is working fine in my local with the same code.

It can accept numerics only

First try replacing setText with sendKeys instead. See if that changes anything.

WebUI.sendKeys(findTestObject('input_PostalCode'), '61701')

I remember there was another OP that had an issue with entering numbers into a textbox and I believe he had to enter them one at a time, using sendKeys. It was on this forum somewhere. That’s another thing to try. If something like it works, then you can make a Keyword out of it with perhaps a loop and substring() parsing method.

Edit: Here are some other ideas:

Thanks alot Grylion for your help. :slight_smile:
tried with all of them still no luck.

What about adding a waitFor statement before the setText.

WebUI.waitForElementClickable(findTestObject('input_PostalCode'), 10)
WebUI.sendKeys(findTestObject('input_PostalCode'), '61701')
WebUI.verifyElementAttributeValue(findTestObject('input_PostalCode'), "value", '61701', 10)

sorry no luck with the above code also

Did you mean WebUI.waitForElementVisible(textField) ?

“Clickable” is supposed to indicate the element is Present, which is not the same as “Visible”, however, it was a stab in the dark why the “sendKeys” was not working.

Finally it worked with the below code

String zipcodevalue = findTestData(‘excel suite’).getValue(17, 1)
String js = “”"
var ssn = document.querySelector(‘#PostalCode’);
ssn.value = ‘${zipcodevalue}’;

“”"
WebUI.executeJavaScript(js, null)

Thanks alot for all your time and help. :slight_smile: