Script hangs on child IE window

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Optimus
Newbie
Posts: 12
Joined: Wed Nov 22, 2006 12:25 pm
Location: Australia

Script hangs on child IE window

Post by Optimus » Thu Nov 23, 2006 5:52 am

(This is the same code I was trying to run in topic 3430 but a different problem).

I'm trying to script a 3rd party website. The first page is a login page.
When submit is clicked, the login page is closed and and a new IE window is opened to handle subsequent requests. I believe this is handled by server-side ASP.NET code. Meanwhile MacroScheduler is trying to handle the login page closure, a windows warning dialog box stating the webpage is closing a window, and a new IE window.

I used WebRecorder to record the script below. I had to add code to handle the windows warning dialog box appearing in IE7: it didn't show up in WebRecorder.

The script appears to stop processing when trying to communicate with the new IE window. According to the debugger, the script is still running.
When I click stop, Macroscheduler crashes.

I'm trying to stay within the confines of using IEAuto.DLL as I want to capture and process the content from a subsequent web page, and then navigate to new pages in the context of the current authenticated user.

Thanks in advance for any pointers. Sorry if this sounds like mush. I've been working on this just over two days solid and not getting very far.

Code: Select all

// Generated by MacroScript WebRecorder 1.71
// Recorded on Thursday, November 23, 2006, at 02:45 PM
LibLoad>IEAuto.dll,hIE
If>hIE=0
  MessageModal>Could not load IEAuto.dll, make sure it is in the path or edit the LibLoad line.
  Goto>end_script
EndIf

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1

LibFunc>hIE,CreateIE,IE[0],0

LibFunc>hIE,Navigate,r,%IE[0]%,http://www.xxxxxxxx/
LibFunc>hIE,WaitIE,r,%IE[0]%
Wait>delay

LibFunc>hIE,WaitIE,r,%IE[0]%
Wait>delay

Let>FrameName={""}
Let>FormName={"frmLogin"}
Let>FieldName={"txtUsername"}
Let>FieldValue={"optimus"}
LibFunc>hIE,FormFill,r,%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0

Let>FrameName={""}
Let>FormName={"frmLogin"}
Let>FieldName={"txtPassword"}
Let>FieldValue={"xxxxxx"}

// changed by me
// call submit directly, do not use click(btnLogin)
//LibFunc>hIE,FormFill,r,%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,0
LibFunc>hIE,FormFill,r,%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,submit

// commented out by me
//Let>FrameName={""}
//Let>FormName={"frmLogin"}
//Let>TagValue={"btnLogin"}
//LibFunc>hIE,ClickTag,r,%IE[0]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue

// start of problem area ??

// added by me
// required to close windows security dialog
WaitWindowOpen>Windows Internet Explorer
Wait>delay
SetFocus>Windows Internet Explorer
Wait>delay
Press ENTER

LibFunc>hIE,WaitIE,r,%IE[0]%
Wait>delay

libFunc>hIE,WaitNewIE,IE[1],0
libFunc>hIE,WaitIE,r,%IE[1]%

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

// end of problem area ??
// code below doesn't appear to happen

Let>FrameName={""}
Let>FormName={"frmSupplierAlertList"}
Let>TagValue={"btnContinue"}
LibFunc>hIE,ClickTag,r,%IE[1]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

Let>FrameName={""}
Let>FormName={"Form1"}
Let>TagValue={"btnContinue"}
LibFunc>hIE,ClickTag,r,%IE[1]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

Let>FrameName={""}
Let>FormName={"Form1"}
Let>TagValue={"91383.1"}
LibFunc>hIE,ClickTag,r,%IE[1]%,str:FrameName,str:FormName,A,TEXT,str:TagValue

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

Let>FrameName={""}
Let>FormName={"frmSupplierQuotation"}
Let>TagValue={"btnPrint"}
LibFunc>hIE,ClickTag,r,%IE[1]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

WaitWindowOpen>Print
SetFocus>Print
LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

WaitWindowOpen>Print
SetFocus>Print
Let>FrameName={""}
Let>FormName={"frmSupplierQuotation"}
Let>TagValue={"Back"}
LibFunc>hIE,ClickTag,r,%IE[1]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

LibFree>hIE
Label>end_script

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Nov 23, 2006 8:46 am

This looks like it will hang forever:


Let>FrameName={""}
Let>FormName={"frmSupplierQuotation"}
Let>TagValue={"btnPrint"}
LibFunc>hIE,ClickTag,r,%IE[1]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue

LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

WaitWindowOpen>Print
SetFocus>Print
LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay

Looks from this like you click an element and that causes the print dialog to appear. But in between you have it waiting while IE is busy. IE usually reports busy while a dialog is being displayed. So you will never get to the WaitWindowOpen line. Remove the interim WaitIE line. It's not needed and will stall the script. So you just need:


Let>FrameName={""}
Let>FormName={"frmSupplierQuotation"}
Let>TagValue={"btnPrint"}
LibFunc>hIE,ClickTag,r,%IE[1]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue

WaitWindowOpen>Print
SetFocus>Print

Same goes in similar scenarios where waiting for a dialog.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Optimus
Newbie
Posts: 12
Joined: Wed Nov 22, 2006 12:25 pm
Location: Australia

Post by Optimus » Thu Nov 23, 2006 9:50 pm

Thanks for the tip.

Could you comment on this part of the macro where one IE window is being closed and another is being opened:
LibFunc>hIE,FormFill,r,%IE[0]%,str:FrameName,str:FormName,str:FieldName,str:FieldValue,submit

//Let>FrameName={""}
//Let>FormName={"frmLogin"}
//Let>TagValue={"btnLogin"}
//LibFunc>hIE,ClickTag,r,%IE[0]%,str:FrameName,str:FormName,INPUT,NAME,str:TagValue

// required to close windows security dialog
WaitWindowOpen>Windows Internet Explorer
Wait>delay
SetFocus>Windows Internet Explorer
Wait>delay
Press ENTER

**BREAKPOINT**

//LibFunc>hIE,WaitIE,r,%IE[0]%
Wait>delay

libFunc>hIE,WaitNewIE,IE[1],0
libFunc>hIE,WaitIE,r,%IE[1]%

//LibFunc>hIE,WaitIE,r,%IE[1]%
Wait>delay
When I reach the BREAKPOINT, the second IE instance, IE[1], is already open and done, ie. it is not busy. When I step forward , the script waits indefinitely for WaitNewIE(). My interpretation of this is that it is waiting for something that has already happened and therefore hangs.
Is there a different way of handling this window behaviour with the IEAuto dll or is it something that needs to handled explicitly at a lower level using HTTPRequest/Response, for example.

Thanks.

Optimus
Newbie
Posts: 12
Joined: Wed Nov 22, 2006 12:25 pm
Location: Australia

Post by Optimus » Tue Nov 28, 2006 11:41 pm

I'm surmising this is an IE7 issue.

I moved to another host running IE6 and the script continues fine past the WaitNewIE command.

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Dec 05, 2006 6:28 pm

Just to let you know we have now fixed this issue (IEAuto hanging on WaitNewIE when using IE7). Version 1.78 can now be downloaded.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

theonex
Junior Coder
Posts: 44
Joined: Thu May 10, 2012 12:32 pm

IE_WaitNew>0,IE[1]

Post by theonex » Fri May 03, 2013 7:17 am

hello

i am trying to wait for a child window to open i have used IE_WaitNew>0,IE[1]
to wait for the child window to open the script hangs i am using windows 7 ie 8 version 8.0.76 and one other thing i would like to know is IE_WaitNew>0,IE[1] uses numbering of child windows eg. [1],[2],[3],[4] ect. is there a way to get IE_WaitNew>0,IE[n] or is there a way to determine the number of the child window. i hope i haven't complicated my question. and am using windows 7 ie 8 version 8.0.76

thanks in advance of any help and advice

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri May 03, 2013 12:54 pm

IE[1], IE[2] etc are just variables created by WebRecorder. They could be "fred" or "sally" but since there could be new windows we opted for a more sensible numbering system.

Anyway if you look in the watch list you'll see that these variables have values. The first is probably 0, the next 1 and so on.

So you just need to get the value from the result of IECreate and then you can use that value when you refer to other IE functions. You can use any variable name you like.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

theonex
Junior Coder
Posts: 44
Joined: Thu May 10, 2012 12:32 pm

IE_WaitNew>0,IE[1] hangs script

Post by theonex » Fri May 03, 2013 1:49 pm

hi

well am using the script bellow

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1
IE_Create>0,IE[0]
IE_Navigate>%IE[0]%,http://www.xxxxxyyyy.com,r
IE_Wait>%IE[0]%,r
wait>1

//few actions carried out here
//script clicks on a link the link opens in a new ie window


IE_WaitNew>0,IE[1]

IE_Quit>%IE[0]%,r
Message>IE_Quit>%IE[0]%,r closed

IE_Quit>%IE[1]%,r
Message>IE_Quit>%IE[1]%,r closed


the problem i have is that IE_WaitNew>0,IE[1] hangs the script i have tried removing IE_WaitNew>0,IE[1] from the script and when it is removed the script continues however only IE_Quit>%IE[0]%,r works and it closes the original ie page where as IE_Quit>%IE[1]%,r which is supposed to close the child window does not work.


any advice would be appreciated

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri May 03, 2013 2:17 pm

Makes it sound like it's not actually another browser window. Are you able to share the domain so that we can test it here? If you can't share it here please email support AT mjtnet.com
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

theonex
Junior Coder
Posts: 44
Joined: Thu May 10, 2012 12:32 pm

Post by theonex » Fri May 03, 2013 3:32 pm

hi marcus


thanks for putting up with me and still trying to help me solve this issue.

this is an example of what i am trying to do.

// Generated by MacroScript WebRecorder 2.3
// Recorded on Friday, May 3, 2013, at 04:26 PM

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1
IE_Create>0,IE[0]

IE_Navigate>%IE[0]%,http://www.webmaster-talk.com/html-foru ... tab.html,r
IE_Wait>%IE[0]%,r
Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay


Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"http://www.w3.org/TR/2004/WD-css3-hyperlinks-20040224/"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,A,TEXT,str:TagValue,r

IE_WaitNew>0,IE[1]
IE_Wait>IE[1],r

IE_Wait>%IE[1]%,r
Wait>delay

IE_Quit>%IE[1]%,r

Label>end_script.

the above script is what i got from the web recorder as you can see the web recorder is labeling the child window as IE[1] however when the script is run it hangs when it gets to IE_WaitNew>0,IE[1].

thanks in advance

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri May 03, 2013 3:51 pm

Your script works for me.

I notice that this is with quite an old version of WebRecorder.

I ran it with the WebRecorder v3 runtime.

The latest version (4.0) with Macro Scheduler 14 requires no runtimes as the functions have become native.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

theonex
Junior Coder
Posts: 44
Joined: Thu May 10, 2012 12:32 pm

Post by theonex » Sat May 04, 2013 4:20 pm

marcus

does the script bellow run on macro scheduler 14 i tried it.... it seem that the script is running however the ie windows which is supposed to open and be visible is no longer visible.

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1
IE_Create>0,IE[0]

IE_Navigate>%IE[0]%,http://www.webmaster-talk.com/html-foru ... tab.html,r
IE_Wait>%IE[0]%,r
Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay

IE_Wait>%IE[0]%,r
Wait>delay


Let>FrameName={""}
Let>FormName={""}
Let>TagValue={"http://www.w3.org/TR/2004/WD-css3-hyperlinks-20040224/"}
IE_ClickTag>%IE[0]%,str:FrameName,str:FormName,A,TEXT,str:TagValue,r

IE_WaitNew>0,IE[1]
IE_Wait>IE[1],r

IE_Wait>%IE[1]%,r
Wait>delay

IE_Quit>%IE[1]%,r

Label>end_script.

User avatar
Marcus Tettmar
Site Admin
Posts: 7378
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue May 07, 2013 8:48 am

Yes, your code runs in v14.

*BUT* this code is not native Macro Scheduler code. It is using old WebRecorder import code. So for this to run (in any version of Macro Scheduler) the WebRecorder runtime files need to be in the Imports folder of the Macro Scheduler program folder.

So you would need to copy the Imports folder over to the Macro Scheduler 14 program folder.

But note my point earlier - you appear to be using an old version of WebRecorder and this code uses that version of the runtime. So moving this code and your runtime to a different version of Macro Scheduler isn't going to make a jot of difference to how it runs because you'll still be running the code via the same - old - runtime.

So if you're going to use v14 then modify the code to use v14 native functions. Then you don't need any runtimes and you'll be using the latest code. As follows:

Code: Select all

//Move the mouse cursor out of harm's way to avoid causing mouseover events to interrupt
MouseMove>0,0
Let>delay=1
IECreate>IE[0]
IENavigate>%IE[0]%,http://www.webmaster-talk.com/html-forum/32504-hyperlink-target-open-in-new-tab.html,r
IEWaitDocumentComplete>IE[0],r

Let>TagValue={"http://www.w3.org/TR/2004/WD-css3-hyperlinks-20040224/"}
IEClickTag>%IE[0]%,,,A,TEXT,TagValue,r
IEWaitNew>IE[1]
IEWaitDocumentComplete>IE[1],r
Wait>delay

IEQuit>IE[1],r
This code works perfectly in v14 for me.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

theonex
Junior Coder
Posts: 44
Joined: Thu May 10, 2012 12:32 pm

Post by theonex » Wed May 08, 2013 1:31 pm

marcus i appreciate all your help and understanding. i have one last question

i have run the script you have sent me it works it does what it should do... but i get this error message "Exception EAccessViolation in module msched.exe at 00008189. Access violation at address 00408189 in module `msched.exe`. Read of address FFFFFFCC.

I am running macro scheduler 14.0.8 and its being run in windows 7.

jsmurff
Newbie
Posts: 2
Joined: Tue Jun 11, 2013 8:03 pm

Me too

Post by jsmurff » Tue Jun 11, 2013 8:08 pm

I am running macro scheduler 14.0.8 and its being run in windows 7 also.

Also, getting hung on child window.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts