Hi
I am automating the inputting of text and date/time fields using VBA and IE. The site concerned has AngularJS java scripts running behind the HTML.
I have triggered events to handle the date and time picker by clicking on buttons navigating the calendar if the month/year does not match what I want etc. and the updates work great.
However I have an issue with simple plain text fields on the page. I can:-
But I cannot get the necessary scripts to run so that the variable data that I have added is recognised and is actually saved (when I recall the record the text data is as it was).
The following is the HTML code:
There are the following events associated with the field - blur, change, compositionend, compositionstart, input
I have tried to use fireevent to trigger "blur" "change" and "input" but get an error message in debug saying object required.
the code I am using is as follows (I have kept the commented out lines so that you can see the variations I have tried and have failed:
IE.document.getElementById("text0").Focus = True
IE.document.getElementById("text0").Click
strSub = Left("text to enter", Len("text to enter") - 1)
strKey = Right("text to enter", 1)
IE.document.getElementById("text0").Value = strSub
Application.SendKeys strKey
'IE.document.getElementById("text0").className = "ng-valid ng-valid-maxlength ng-dirty ng-valid-parse ng-touched"
'IE.document.getElementById("text0").Value = "text to enter"
'IE.document.getElementById("text0").innerText = "text to enter"
'IE.document.getElementById("text0").className = "ng-valid ng-valid-maxlength ng-dirty ng-valid-parse ng-touched"
'IE.document.getElementById("text0").feedbackItem.textValue = "text to enter"
IE.document.getElementById("text0").className = "ng-valid ng-valid-maxlength ng-dirty ng-valid-parse ng-touched"
'Elements.FireEvent ("change")
IE.document.getElementById("text0").Focus = False
IE.document.getElementById("date1").Focus = True 'this is the next field to populate
I am assuming that I need to either trigger the JS event(s) and/or somehow change the value of "feedbackItem.textValue"?
Anyone see the obvious mistake I'm making or step(s) I've missed?
Thanks in advance
John
I am automating the inputting of text and date/time fields using VBA and IE. The site concerned has AngularJS java scripts running behind the HTML.
I have triggered events to handle the date and time picker by clicking on buttons navigating the calendar if the month/year does not match what I want etc. and the updates work great.
However I have an issue with simple plain text fields on the page. I can:-
- use the getelementbyid("text0").value = "xxxx" and .innertext = "xxxxx" to populate the input field on the web page (so I can see what I expect to see)
- use the.classname = "xxx" to change the class (using DOM I can see that when I work manually on the page the class name changes to indicate that the field is "dirty" which the java must use to tell that a field has changed)
- click the save button automatically
But I cannot get the necessary scripts to run so that the variable data that I have added is recognised and is actually saved (when I recall the record the text data is as it was).
The following is the HTML code:
HTML:
<input type="text" ng-model="feedbackItem.textValue" id="text0" ng-disabled="!feedbackIsEditable || feedbackItem.notApplicable" maxlength="255" class="ng-valid ng-valid-maxlength ng-dirty ng-valid-parse ng-touched" name="" tabindex="0" aria-disabled="false" aria-invalid="false" style="">
There are the following events associated with the field - blur, change, compositionend, compositionstart, input
I have tried to use fireevent to trigger "blur" "change" and "input" but get an error message in debug saying object required.
the code I am using is as follows (I have kept the commented out lines so that you can see the variations I have tried and have failed:
IE.document.getElementById("text0").Focus = True
IE.document.getElementById("text0").Click
strSub = Left("text to enter", Len("text to enter") - 1)
strKey = Right("text to enter", 1)
IE.document.getElementById("text0").Value = strSub
Application.SendKeys strKey
'IE.document.getElementById("text0").className = "ng-valid ng-valid-maxlength ng-dirty ng-valid-parse ng-touched"
'IE.document.getElementById("text0").Value = "text to enter"
'IE.document.getElementById("text0").innerText = "text to enter"
'IE.document.getElementById("text0").className = "ng-valid ng-valid-maxlength ng-dirty ng-valid-parse ng-touched"
'IE.document.getElementById("text0").feedbackItem.textValue = "text to enter"
IE.document.getElementById("text0").className = "ng-valid ng-valid-maxlength ng-dirty ng-valid-parse ng-touched"
'Elements.FireEvent ("change")
IE.document.getElementById("text0").Focus = False
IE.document.getElementById("date1").Focus = True 'this is the next field to populate
I am assuming that I need to either trigger the JS event(s) and/or somehow change the value of "feedbackItem.textValue"?
Anyone see the obvious mistake I'm making or step(s) I've missed?
Thanks in advance
John