Set number in the field which is only numberic

On Mobile site when i am in payment page i am trying to insert Numeric value on the credit card number field which is in frame it is not getting set. i am able to click on the field but not able to set value in the field as it is numberic.

Code:
card_num = 1234567890123456
WebUI.setText(findTestObject(‘object_card_num’), card_num)

above is the code but not working

1 Like

I believe WebUI.setText() will only set Strings, not numbers. Although, if you are not getting a MissingMethodException, then maybe it identifies the large number as a String. My suggestion though would be to try WebUI.sendKeys() instead.

Also, credit card numbers usually have an algorithm that identifies the card as either MasterCard, Visa or otherwise. Does your app check the validity of the credit card? If it does, then you cannot use just any random set of numbers.

Finally, if you are on a “Mobile” site, should you not be using a Mobile command, not a web browser one?

i believe a mobile website is still navigated to using a browser, like chrome, so WebUI applies
that said, input type number restricts what TEXT you can write to that fields, so you just have to call .toString() on the number and it will work as expected, but as mentioned above, if there is validation on the input field, then you will be unable to proceed regardless

1 Like

Yes, it validates input field saying its mastercard or visa etc. and i am using valid card number

1 Like

then you should try what you have while passing said number as a string, either by declaring it as a String or by calling .toString() on the number when you pass it to WebUI.setText(), since the setText method expects a string as a parameter, if not, it would likely fail with error message that it can’t find a matching method setText(TestObject, Integer)

so for example
int card_num = 1234567890123456
WebUI.setText(findTestObject(‘object_card_num’), card_num.toString())

1 Like

No Success

2 Likes

If you enter the credit card number manually, do you have to do anything specific to the textbox first, such as click on it?

Again, you are not getting a MissingMethodException, so the concern is not to do with the field being numeric–unless the zero is an oh :slight_smile:. If you could send text to the field, does it display an error?

1 Like

Ramesh, if you’re expecting people to help you, please try to be a little more helpful toward us. “No Success” imparts no more information than your original post, which itself was very brief.

Please post screenshots. Show us the HTML and the code verbatim.

Aside: Everything in HTML is a string. All representations of objects, dates, numbers and everything else are just strings of characters - what you perceive as numeric values (dates, objects) is done via smoke and mirrors (usually JavaScript and browser wizardry).

If you can click on the element, how did you prove that worked?

If WebUI.setText on an HTML <input> element is not working, then what is the error message?

Thanks its is been solved

1 Like