Problem with SSN field

Hi,

trying to insert the data from excel and have SSN also among them. script is reading the value correctly from excel but SSN values are jumbling while setting into the test box. eg: 123-45-6789 (actual) but inserting as 945-78-1236.

please share your suggestions

What specifically are you insert the data into?
Is there any sort of field validation or parsing happening?
How is the text being entered, is it SetText or SendKeys?
I have seen where browsers handle dates differently, so depending on this field there might some specific property that is different between browsers. I haven’t really seen that, but it is possible.

I am using settext and not using anything. checked the properties of the text box as well and all are regular properties type=text max length = 11 and placeholder is defined as XXX-XX-XXXX

You’ll probably need to do some experimentation.
What happens if you use SendKeys?
What happens if you have a Delay before you use SendText?
How does the field appear if you enter 123456789 and 123-45-6789? Are both of those valid and accepted?
What happens if you paste 123-45-6789 and 123456789 into the field? With and without the dash?
Additionally, if you the Spy feature of Katalon or use the Katalon Recorder for Firefox or Chrome, how does it show the action of entering text into that field? And if you play that action back again, is the field populated as expected?

Most likely there is something about the field causing this issue. You may need to type the values rather than paste the value (SendKeys vs SetText)

tried in all ways as you suggested above:

send keys, delay, timeout options but still no luck and entering the numbers with shuffling. if I do it manually like entering from keyboard/copy paste its working fine and the dashes are taking automatically even though I copied without dashes.

this is happening in chrome only and other browsers are not working for me.

thanks and send me your suggestions if u find any.

Does that mean the dashes are entered automatically? If so, there is validation for that field which could be throwing off entering data.

Does this mean it is working in Chrome and failing in all other browsers? Does it work for a certain browser but not for others? If it works for one, but not others, you will need to set up conditional code to handle the different browsers.

But at this point, it still sounds like the issue is related to the browser and form validation. Do you have any of the output from your previous testing?

@Peter_Wilson I admire your diligence but working blind like that is annoying.

@usekatalon Please post your HTML and a screenshot of the element in the Firefox Inspector (it shows even handlers too). Also, read this and respond with ANYTHING you think might be relevant:

Meanwhile…

This pretty much guarantees there is a validator/event handler dealing with inputs to that field.

You could try sendKeys again using an ENTER key to commit the change or a TAB key to move away from the field and trigger onblur/onchange handling. You can use firefox to open the event handlers directly on the element. Here is a screenshot of this textarea on THIS PAGE - the one you’re reading - look at all the event handlers

thanks Russ for the reply. :slight_smile:
tried the above options but no luck…attaching the SS

Cool. Now post it again without the popup. I need to see the SSN input element.

sss

String js = '''
  var ssn = document.querySelector('#SSN');
  ssn.value = "123456789";
  ssn.onchange();
'''
WebUI.executeJavaScript(js, null)

If that doesn’t work:

String js = '''
  var ssn = document.querySelector('#SSN');
  ssn.value = "123456789";
  ssn.onblur();
'''

Let me know how it goes.

Log viewer:
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to execute JavaScript.
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)

console logs:
Caused by: org.openqa.selenium.JavascriptException: javascript error: ssn.onblur is not a function
(Session info: chrome=77.0.3865.75)
Build info: version: ‘3.141.59’, revision: ‘e82be7d358’, time: ‘2018-11-14T08:25:53’
System info: host: ‘353799D’, ip: ‘172.16.130.96’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 77.0.3865.75, chrome: {chromedriverVersion: 77.0.3865.40 (f484704e052e0…, userDataDir: C:\Users\pkota\AppData\Loca…}, goog:chromeOptions: {debuggerAddress: localhost:14461}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 1f731c5c51ce192762654615d2107fd4

Also i tried with the below as I am passing the value through excel sheet but still facing with the above error:

  • String js = ‘’
    var ssn = document.querySelector(’#SSN’)
    ssn.value = WebUI.setText(findTestObject(‘objectrepository/input_SSN_SSN’), findTestData(‘exceltestsuite’).getValue(15, rowNum))
    ssn.onchange()

    WebUI.executeJavaScript(js, null)/*

You’re making mistakes because you’re trying to run before you can walk.

Try the code that I gave you. Tell me what happens.

Try this in the browser console. Tell me what happens:

document.querySelector('#SSN').value = "123456789"

Reason:
groovy.lang.MissingPropertyException: No such property: document for class: Script1568680728633

Please pay attention…

Try this in the browser console. Tell me what happens:

document.querySelector('#SSN').value = "123456789"

String js = ‘’’
document.querySelector(‘#SSN’).value = “123456789”
‘’’
WebUI.executeJavaScript(js, null)

tried with the above code and it is inserting without dashes in the SSN field
sasas

Now this:

document.querySelector('#SSN').value = "123456789"; document.querySelector('#SSN').onblur()

I’m hoping to see the dashes being applied. Either way, this proves you can assign the field with JavaScript. The original code I gave you should work, too. But DON’T add your stuff yet.

I’m stepping out - I’ll be gone a couple hours.

sure…i dont until you confirm.

still no dashes with the above code.

I’m winging this based on your earlier attempts:

String ssnvalue = findTestData('exceltestsuite').getValue(15, rowNum)
String js = """
  var ssn = document.querySelector('#SSN');
  ssn.value = '${ssnvalue}';
  ssn.onblur();
"""
WebUI.executeJavaScript(js, null)

You can also try ssn.onchange() instead of onblur(). If you’re convinced that something in the code makes the dashes appear, one or other of the events you saw listed in the popup MUST be doing it - you just need to find which one.

If you cannot get this block of code to work, then you should go back to using sendKeys (I still think that’s your best option).