# Entered Masked phone number text disappeared

**URL:** <https://forum.katalon.com/t/entered-masked-phone-number-text-disappeared/58949>\
**Category:** Web Testing\
**Tags:** katalon-studio\
**Created:** [October 6, 2021, 9:11pm UTC](https://forum.katalon.com/t/entered-masked-phone-number-text-disappeared/58949 "2021-10-06T21:11:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maltesh.c](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/maltesh.c/32/16104_2.png) [@maltesh.c](https://forum.katalon.com/u/maltesh.c)\
**Post date:** [October 6, 2021, 9:11pm UTC](https://forum.katalon.com/t/entered-masked-phone-number-text-disappeared/58949/1 "2021-10-06T21:11:10Z")

</div>

I have a peculiar problem to which I was unable to find an answer. I use Javascript to input masked phone number into the field of salesforce application. I can see the text going in, but as I click create account button, the text in the phone number field disappears.

**Note** : I tried with SetText, SendKey and also Set Masked Text keywords but in this case text itself not appeared but katalon shows step has passed that’s why I used Javascript.

Can someone help me to over come this issue.

Code :

WebUI.verifyElementPresent(findTestObject(‘Mobile Buy Journey/version\_2/obj\_TC\_05\_toVerifyCustomerDetailsSection/inputPrimaryPhoneNumber’),  
5)

WebElement pno = WebUiCommonHelper.findWebElement(findTestObject(‘Mobile Buy Journey/version\_2/obj\_TC\_05\_toVerifyCustomerDetailsSection/inputPrimaryPhoneNumber’),  
30)

WebUI.executeJavaScript(‘arguments[0].value=“(989) 898-0909”’, Arrays.asList(pno))

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/7/4/745d5a577890915f84d8816de0f6dcd53eccd561.png)

**Phone Number appears when Javascript executed:**

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/f/f/ff0226a8ff5153118c7170c78b9bdcc38002bb36.png)

**Phone Number Disappear after clicking CreateAccount Button**

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/6/c/6c57e03b8b0bb9ac7e12f735cdad41c0423f3178.png)

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/8/f/8f950266173bfa2a84fe5a2663358a937185ab46.png)

**Here is Element Input Snap :**

 ![image](https://europe1.discourse-cdn.com/katalon/original/3X/3/7/3700d52b46d453655ae0dca3bbc93ad4e474f250.png)

---

<div class="post-metadata">

**Author:** ![kazurayam](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/kazurayam/32/333_2.png) [@kazurayam](https://forum.katalon.com/u/kazurayam)\
**Post date:** [October 7, 2021, 2:46am UTC](https://forum.katalon.com/t/entered-masked-phone-number-text-disappeared/58949/2 "2021-10-07T02:46:34Z")

</div>

Your target HTML has a fragment:  
`<input vlocity_cmt_maskedinput_maskedinput_slds ...`

What is `vlocity_cmt_maskedinput`?

I made a Google search and found the following stuff.

- [https://developer.salesforce.com/files/credential-resources/CME\_EPC\_PDF-en.pdf](https://developer.salesforce.com/files/credential-resources/CME_EPC_PDF-en.pdf)

> © 2021 Vlocity LLC, a Salesforce company

I (@kazurayam) knew nothing about this product, but I would guess that `vlocity_cmt_maskedinput` is a JavaScript&CSS library that does a lot of mysterious things behind the scene.

a quote from the page 171:

> # Constrain Product Attributes Using a Format Mask
> 
> You can constrain attribute values using a format mask. For example, if a field contains a telephone number, you can define an attribute mask that constrains the value to an appropriate set of data, such as (999) 999-9999. **By applying a format mask, you ensure that a user can type only in a predetermined pattern.** The format mask is a part of setting up product attributes on a product.

This description tells me that the Vlocity’s Format Mask software will intervene between the character input by the key stroke and the output on the display as echo. _The Vlocity Format Mask software will display only characters that it accepted as valid._

You should be aware that such sophisticated processing is done behind the scene.

> [@maltesh.c](#):
>
> **Note** : I tried with SetText, SendKey and also Set Masked Text keywords but in this case text itself not appeared

Usually in a simple (poorman’s ) web page, when you call setText() to put text “foo” into a `<input type="text">` element, the text “foo” will be displayed. But you wrote that your text did not appeared. I do not know exactly what happened. I guess the “Vlocity” library did something myterious behind the scene. I presume, the “Vlocity” only recognise keys typed by a user manually; it does not recognize text trasferred by Selenium `SetText` command, etc. So that “Vlocity” did not echoed the text you set by `setText()` keyword.

> [@maltesh.c](#):
>
> `WebUI.executeJavaScript(‘arguments[0].value="(989) 898-0909"’, Arrays.asList(pno))`

I think that this javascript code changes the `value` property of the `<input type="tel" value="...">` element.

> **[HTML DOM Input Text value Property](https://www.w3schools.com/jsref/prop_text_value.asp)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

> The value property contains the default value OR the value a user types in (or a value set by a script).

I guess, the text “(989)898-0909” was set into the value property. It was visible only until you clicked the Create Account button.

> [@maltesh.c](#):
>
> but as I click create account button, the text in the phone number field disappears.

When you do “click”, the page will be re-drawn: this may result the phone number field is refreshed. When you do “click”, the Vlocity library does something for the `<input>` element. I guess, the Vlocity library did not recognize the “value” property that you set by `WebUI.executeJavaScript(...)` call. The text was ignored by the library.

On the page after the click, beside the “Primary Phone” field, you can find a notification “Required” in red color. This proves that the Vlocity library did not recognize the text “(989)898-0909” at all.

@maltesh.c

I tried to describe my guess what happened.

I have no idea how to modify your test script so that you get comfortable about it.

> [@maltesh.c](#):
>
> **Note** : I tried with SetText, SendKey and also Set Masked Text keywords but in this case text itself not appeared but katalon shows step has passed

“The text didn’t appear” — I think, it is not a big issue. You shouldn’t worry about it much because you are not debugging the Vlocity product. If tests for your web app run forward, I think, it’s good enough.

---

<div class="post-metadata">

**Author:** ![grylion54](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/grylion54/32/16265_2.png) [@grylion54](https://forum.katalon.com/u/grylion54)\
**Post date:** [October 7, 2021, 3:38pm UTC](https://forum.katalon.com/t/entered-masked-phone-number-text-disappeared/58949/3 "2021-10-07T15:38:03Z")

</div>

Since the “Primary Phone” already has the parenthesis and hyphen displayed, and with @kazurayam’s information, enter the phone number without them, such as `"989 898 0909"`, or `"9898980909"` or `"989\\t898\\t0909"`.

---

<div class="post-metadata">

**Author:** ![jennifer](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/jennifer/32/20464_2.png) [@jennifer](https://forum.katalon.com/u/jennifer)\
**Post date:** [August 24, 2022, 1:48am UTC](https://forum.katalon.com/t/entered-masked-phone-number-text-disappeared/58949/4 "2022-08-24T01:48:12Z")

</div>

I have found a solution to this. Although Katalon may pass a value that is numerical (0-9) it is passed to text objects as strings, not integers. As described in the other posts **vlocity masked input** will block it as it interprets it as invalid for this reason.

The work around is to use the ROBOT library to simulate keyboard presses of numbers.  
For simplicity; below is code for a CustomKeyword that can be passed a string of numbers that will be ‘typed’ by the robot.

Within Test case: _Keywordname_.robotType(‘1234567890’)

```auto
import java.awt.Robot;
import org.openqa.selenium.Keys;
import java.awt.event.KeyEvent;

@Keyword
public static robotType(String TypeThis)
{
       Robot robot = new Robot()
       String TypeLetter
       Integer i

       for (i=0;i< TypeThis.length();i++)
       {
             TypeLetter = TypeThis.charAt(i)
             println('Type: ' + TypeLetter)

             switch(TypeLetter)
             { case '0': robot.keyPress(KeyEvent.VK_0); robot.keyRelease(KeyEvent.VK_0);break
                    case '1': robot.keyPress(KeyEvent.VK_1); robot.keyRelease(KeyEvent.VK_1);break
                    case '2': robot.keyPress(KeyEvent.VK_2); robot.keyRelease(KeyEvent.VK_2);break
                    case '3': robot.keyPress(KeyEvent.VK_3); robot.keyRelease(KeyEvent.VK_3);break
                    case '4': robot.keyPress(KeyEvent.VK_4); robot.keyRelease(KeyEvent.VK_4);break
                    case '5': robot.keyPress(KeyEvent.VK_5); robot.keyRelease(KeyEvent.VK_5);break
                    case '6': robot.keyPress(KeyEvent.VK_6); robot.keyRelease(KeyEvent.VK_6);break
                    case '7': robot.keyPress(KeyEvent.VK_7); robot.keyRelease(KeyEvent.VK_7);break
                    case '8': robot.keyPress(KeyEvent.VK_8); robot.keyRelease(KeyEvent.VK_8);break
                    case '9': robot.keyPress(KeyEvent.VK_9); robot.keyRelease(KeyEvent.VK_9);break
             }
             //Thread.sleep(500)
       }
}

```
