Page 2 of 2

Re: Interacting with IE with COM Interface and Java Script

Posted: 30 Sep 2019, 04:36
by Blackholyman
Why i asked for all your code was that in one of your images you had sleep between the navigate and the element interaction but in your 4 lines of code you do not

after a navigate event you have to wait for the document your navigating to load before trying to interact with any elements on the new document

so your 4 lines have at least that issue...

Code: Select all

ie := ComObjCreate(("InternetExplorer.Application"))
ie.Visible:=True
ie.Navigate("https://xxxx/xxxx/man.htm")
while ie.readyState != 4 || ie.document.readyState != "complete" || ie.busy)
	sleep 100
; or simply use a hard coded sleep of 5000 if you always know that 5 seconds is what it takes
ie.document.frames["application"].getElementById("USERNAME.DUMMY.DUMMY").value := "Mary"
also the frame element will most likely have it own .document

Code: Select all

ie.document.parentWindow.frames["application"].document.

Re: Interacting with IE with COM Interface and Java Script

Posted: 01 Oct 2019, 05:10
by aircooled
Blackholyman wrote:
30 Sep 2019, 04:36
Why i asked for all your code was that in one of your images you had sleep between the navigate and the element interaction but in your 4 lines of code you do not

after a navigate event you have to wait for the document your navigating to load before trying to interact with any elements on the new document

so your 4 lines have at least that issue...

Code: Select all

ie := ComObjCreate(("InternetExplorer.Application"))
ie.Visible:=True
ie.Navigate("https://xxxx/xxxx/man.htm")
while ie.readyState != 4 || ie.document.readyState != "complete" || ie.busy)
	sleep 100
; or simply use a hard coded sleep of 5000 if you always know that 5 seconds is what it takes
ie.document.frames["application"].getElementById("USERNAME.DUMMY.DUMMY").value := "Mary"
also the frame element will most likely have it own .document

Code: Select all

ie.document.parentWindow.frames["application"].document.
You are right I didn't put the Delay's but I had a lot and experimented with long waiting times, the problem was not that see below. Thanks anyway.

Re: Interacting with IE with COM Interface and Java Script

Posted: 01 Oct 2019, 05:13
by aircooled
As gregster pointed out this solved the problem:

ie.document.getElementById("application").contentDocument.getElementById("USERNAME.DUMMY.DUMMY").value := "Mary" :bravo: :superhappy:

Re: Interacting with IE with COM Interface and Java Script

Posted: 01 Oct 2019, 05:28
by gregster
Good to know :thumbup:

Re: Interacting with IE with COM Interface and Java Script

Posted: 01 Oct 2019, 05:48
by Blackholyman
What part of what i said was not part of fixing your issue?

You can not interact with the element without waiting -> not doing so will make your code fail

You need to act on the frame’s document -> in your case .contentDocument worked

But great you made it work...