I have a field which has some structure in it which limits how many characters can be entered.
example, field has a 5 character limit. As a user, if I try to enter any more, it just won't even let me but I want to make an automated test where I send 6 characters and watch it do the same
At the moment, I am using UFT One, and if I try to use the .Set function to send 6 characters, it gives an error which I have confirmed with Micro Focus is a bug. They say it should not give an error because I am sending max + 1 character, and the .Set function should allow it to exceed sending more than max characters
So they gave me an alternate solution which was to do:
object.Click
Set dr = CreateObject("Mercury.DeviceReplay")
dr.SendString "123456"
This works great when I am running the test manually 100% of the time, but unfortunately when I run it remotely as an automated test it click into the address bar of the browser instead and enters the text (100% of the time!)
I am trying to find alternate ways but none are working.. I tried using jQuery to click in the field instead but it wont click into it
I can send text with jquery using .val("123456") but unfortunately, that forces the text into the field and doesnt truncate it to "12345"
I have tried using property("placeholder", "123456") which again will let the 6th character go into the field and also its not recognised as being an input by the UI because when I hit save, it says the field is blank
So yeah looking for a way with either UFT one (not using text or send string) where I can simulate as a user entering "123456" but the field will only show "12345"
this is the structure of the field. Its a webTable, with the having an input label
<input id="<HTMLID>"
name="<NAME>"
type=""
style=""
class="<CLASSES>"
autocomplete=""
maxlength="5"
placeholder=""
size="5"
onkeydown="var params = new Object(); params.maxLength=5; formatOnField(this,params,[lowerCaseFlash], arguments[0])"
onkeyup="var params = new Object(); params.maxLength=5; formatOnField(this,params,[formatAlphanumericElement, upperCase], arguments[0])"
onblur="if (this.onkeyup) { this.onkeyup(event); }; var params = new Object(); params.maxLength=5; runValidationOnField(this,[validateMandatory], params)"
onfocus="synchroniseValue(this)"
role="textbox"
aria-disabled="false"
aria-readonly="false"
value=""
data-dashlane-rid="<ID>"
tip="A value must be provided for this field" data-form-type="other">
I do see I have some onkeydown and other similar actions etc but even if I send a keydown after thats not simulating what the user does. They dont even have to do anything and just type and the field stops them from entering the 6th character