SetText not working on Telephone & Identity fields - They accepts only numeric values

Hi Team,
I’ve below 2 fields which accepts only Numeric Values as Input.

Telephone Number

Identity Number

Both the fields accepts only Numeric values as Input. Both the fields will have initial Cursor getting placed at the end. So I’m using Backspace key to bring cursor position to front.
image
image

Through Katalon, I’ve tried both setText, sendKeys options but no use. As the values are not getting populated in Application Screen.

WebUI.sendKeys(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’), Keys.chord(Keys.BACK_SPACE))
WebUI.delay(3)
WebUI.setText(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’), “7877877879”)

WebUI.sendKeys(findTestObject(‘web/Buy Journey/CustomerDetails/customerSSN’), Keys.chord(Keys.BACK_SPACE))
WebUI.delay(3)
WebUI.setText(findTestObject(‘web/Buy Journey/CustomerDetails/customerSSN’), “787787787”)

I don’t see any error. So need some guidance on how to handle this.

When you type the Primary Phone into the page doing it manually, do you have to do anything special to move from one section of the phone number to another, such as using a tab, or mouse click. If so, you will have to do similarly.

How about?
"787\\t787\\t7879"

or

"787" + Keys.chord(Keys.TAB) +"787" + Keys.chord(Keys.TAB) + "7879"

As for the Customer’s SSN, there may be a formula that you need to use in order to get a correct pattern of numbers that the field will accept. You can try the above tab usage first though to see if it works for both elements. The SSN number might go in but be deleted when the page is Saved.

If you have to use a mouse to move from one section to another, then look for different xpaths for the sections.

Here is another option.

I tried below different options and none of them is helping here. Everytime the Script is getting completed successfully but the value is not getting populated.

long primaryPhone = 7877877878
WebUI.sendKeys(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’), Keys.chord(Keys.BACK_SPACE))
WebUI.focus(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’))
WebUI.setText(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’),primaryPhone.toString())

String primaryPhone2 = “(787) 787-7878”
WebUI.sendKeys(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’), Keys.chord(Keys.HOME))
WebUI.focus(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’))
WebUI.setText(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’),primaryPhone2)

WebUI.delay(3)
WebUI.sendKeys(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’), Keys.chord(Keys.BACK_SPACE))
WebUI.delay(3)
WebUI.focus(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’))
WebUI.sendKeys(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’), findTestData(‘web/CreateAccountTestData’).getValue(
4, 1))

WebUI.sendKeys(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’), Keys.chord(Keys.BACK_SPACE))
WebUI.delay(3)
WebUI.focus(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’))
WebUI.sendKeys(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’), Keys.chord(Keys.NUMPAD2, Keys.NUMPAD8,
Keys.NUMPAD8))

Hi @sivakumar.g, this works for me: How to slow down text input (for slower systems)

Possible SIN number solution: How to create 'Social Insurance Number' (SIN) with JavaScript custom keyword

Just a note that doing the above is a waste if you are not going to do any math, like addition or subtraction. And on a phone number, that doesn’t happen. So, even though you have a lot of numbers, make them a String from the start.

def primaryPhone = "7877877878"
or
String primaryPhone = "7877877878"

Again, I urge you to try entering the phone number manually and then you will have to enact the same manner using the test plan.

maybe even:
def pp1 = "787"
def pp2 = "787"
def pp3 = "7878"

WebUI.focus(findTestObject('web/Buy Journey/CustomerDetails/primaryTelephone'))
WebUI.setText(findTestObject('web/Buy Journey/CustomerDetails/primaryTelephone'), 
    pp1)
WebUI.setText(findTestObject('web/Buy Journey/CustomerDetails/primaryTelephone'), 
    pp2)
WebUI.setText(findTestObject('web/Buy Journey/CustomerDetails/primaryTelephone'), 
    pp3)

Good point Mike, I missed that @sivakumar.g was using integers. As Mike says use a String.

Tried this and it’s not working as well.

WebUI.click(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’))
WebUI.sendKeys(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’), Keys.chord(Keys.BACK_SPACE))
WebUI.focus(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’))
String phoneNbr = ‘7877877878’
for (i = 0; i < phoneNbr.length(); i++) {
String PhoneNumber = phoneNbr.charAt(i)
println('Send: ’ + PhoneNumber)
WebUI.setText(findTestObject(‘web/Buy Journey/CustomerDetails/primaryTelephone’), PhoneNumber)
Thread.sleep(500)
}

Just curious, did you use the “Web Spy” to get your xpath (or whatever you use) to the Primary Phone or did you investigate the HTML to determine it? If you used the “Web Spy”, see if you get the same pathway for each part of the Primary Phone sections. Or can you show us the HTML of the section?

Also, for your code, it would make it so much easier to read if you put three backticks (found on the same key as the tilde ~) above and below your code, like ```

On use of Web Spy, the Object is getting captured with ID - //input[@id=‘input9-302’]

In this xpath, the trailing number - 302 gets changed everytime. So I’ve customized as follows:

//input[@class=“vlocity-input slds-input” and @type=“tel” and contains(@id,“input9”)]

Provided below the Html section of the same :