pbellino Absent Member.
Absent Member.
273 views

Difference between SetText and TypeKeys for a DomTextField

Running SILKTest 19.0 using 4test.

I have a DomTextfield that has a max limit of 64 characters.

If I use the routine TypeKeys and attempt to enter more than 64 characters, only 64 characters will be written as to be expected.

If I use the routine SetText and enter more than 64 characters, all of those characters will in fact be set into the DomTextField.

Can someonetell me why this can occur?

Thanks,

Phil

0 Likes
2 Replies
Highlighted
Micro Focus Frequent Contributor
Micro Focus Frequent Contributor

RE: Difference between SetText and TypeKeys for a DomTextField

Hi Phil,

The Typekeys() and SetText() function in very different ways - Typekeys is a low level method that uses the Keyboard to enter the Keys, while SetText() is a high level method that basically sends an API message to the textfield control.

To me the most likely explanation is that SetText() method bypasses whatever mechanism the textfield uses to limit the user to 64 characters, as it does not utilise the keyboard to enter the text.

Regards...

JohnM.
0 Likes
b1mrs03
New Member.

RE: Difference between SetText and TypeKeys for a DomTextField

Hi Phil,

I can confirm JohnM.'s answer. It's basically the equivalent of doing a copy/paste. Not using the keyboard bypasses the front-end edit that prevents the extra characters.

Before you enter the SetText() in your code you can always trim it to 64 characters. No?

I hope this helps.

Good Luck
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.