KeydownEvent.initEvent "keydown", True, False KeyupEvent.initEvent "keyup", True, False 'After IE navigation and page has completely loaded event is assigned to one these elements - hence why I have included a dispatchEvent keydown in the For Next loop below. You might find that a keypress, keydown, etc. Use the browser's DOM inspector to go up the DOM hierarchy to each parent element, looking to see if any events are assigned to that element, until you reach the body element. Also, you might need to trigger other event(s) - within the For Next loop, or maybe before or after it - which are assigned to parent elements of the text input element. keypress, mousedown, etc.) - I have shown how to define these events.Īlso make sure the events are created (by the createEvent lines) after the page (HTMLdoc) is completely loaded, otherwise the dispatchEvent calls might not have any effect. You might need to send a different event or events (e.g. It populates the text input element character by character, sending a keydown event and input event for each character and a change event at the end. The example code below requires a reference to the MS HTML Object Library (set via Tools->References in the VBA editor). You could try dispatchEvent on the text input element instead of FireEvent. What is the URL? It's very difficult to help without knowing that. I am assuming that I need to either trigger the JS event(s) and/or somehow change the value of "feedbackItem.textValue"?Īnyone see the obvious mistake I'm making or step(s) I've missed? IE.document.getElementById("date1").Focus = True 'this is the next field to populate IE.document.getElementById("text0").Focus = False 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").innerText = "text to enter" 'IE.document.getElementById("text0").Value = "text to enter" 'IE.document.getElementById("text0").className = "ng-valid ng-valid-maxlength ng-dirty ng-valid-parse ng-touched" IE.document.getElementById("text0").Value = strSub StrSub = Left("text to enter", Len("text to enter") - 1) IE.document.getElementById("text0").Click IE.document.getElementById("text0").Focus = True 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: I have tried to use fireevent to trigger "blur" "change" and "input" but get an error message in debug saying object required. There are the following events associated with the field - blur, change, compositionend, compositionstart, input 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)īut 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).innertext = "xxxxx" to populate the input field on the web page (so I can see what I expect to see) use the getelementbyid("text0").value = "xxxx" and. However I have an issue with simple plain text fields on the page. 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. The site concerned has AngularJS java scripts running behind the HTML. I am automating the inputting of text and date/time fields using VBA and IE.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |