This topic contains 6 replies, has 2 voices, and was last updated by
October 31, 2018 at 3:07 pm #120490
I'm working on automating a series of tests to perform after a software upgrade that simulates what a user would do by clicking and entering data into fields within Internet Explorer to ensure functionality. The problem I have run into is, some fields I can set the value but it require a keystroke or otherwise the field is seen as empty. So when I search, it doesn't search for what I've specified but rather returns 100's of results because it thinks the field is blank. Without using send keys, does anyone have any suggestions on how to get around this? I've tried Focus(), Select(), and SetActive() on the field but this also fails to register that there is data in that field.
How I'm setting the value:
$A = $IE.Document.IHTMLDocument3_getElementById('txtNumber') $A.setAttribute('value',"$Number")
Element I am working with:
October 31, 2018 at 3:33 pm #120510
Are you watching IE and see the data in the field? You need to figure out how it was developed. For instance, they could be looking for an event to do form validation, like onkeyup() or onblur() rather than doing validation on form submit. When you do it manually what happens? I see txtNumber, so if there is validation that it's a number, what happens if you type a letter and release the key (onkeyup())? Do you get a validation error? If not and you click to another field (onblur()), do you get a validation message then? For instance, if it's the second example you could try Focus() on txtNumber, set value, and then focus on the submit button or something to trigger an onblur() event to complete validation.
October 31, 2018 at 4:08 pm #120523
Thanks for the reply Rob. It accepts letters, numbers, and specials so it doesn't appear to validate characters. When I manually enter a number, the classname changes from -empty to -not-empty.
Here is the element again:
input class="SearchCriteria ng-valid FieldValidateWrapper k-textbox k-input Input xj-text-editor ng-touched ng-dirty ng-valid-parse ng-empty" id="txtNumber" type="text" ng-blur="setLastFocus($event)" set-focus="focusOnNumber" ng-model="search_criteria.SEARCH_NUMBER" text-editor="" hide-zero=""
October 31, 2018 at 4:14 pm #120525
Had to take out the greater than and less than for it to paste... operator error. 🙂
November 1, 2018 at 12:51 am #120660
Did you try what I suggested? Based on what you posted, it looks like there is a blur event ng-blur="setLastFocus($event)" which is most likely what is modifying the class. You should be able to Focus on the control, set the value and the set focus to any other control to fire the blur event. Additionally, you could just update the class with DOM as well:
$A.Class = $A.Class -replace 'ng-empty', ng-not-empty'
November 1, 2018 at 1:21 pm #120792
The events associated with the element are blur, change, cut, keydown and paste. I've tried setting focus() from that field, setting the value, then set focus to another with no luck and I've also tried changing the class as well to not-empty. There is also a SelectionStart and SelectionEnd property that is a count of digits in the field (1234567 = 7) and I've changed this as well to match the number I'm attempting to add without success. Is there a way to manually trigger an event? .FireEvent('event') returns true
November 1, 2018 at 3:00 pm #120849
$A.setAttribute('value',"$Number"); $A.keydown(); $A.keypress(); $A.keyup(); $A.blur();
You must be logged in to reply to this topic.