Why does this page break IE functions?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
devzt
Newbie
Posts: 2
Joined: Wed Aug 13, 2014 12:38 am

Why does this page break IE functions?

Post by devzt » Wed Aug 13, 2014 9:06 pm

I'm currently using the trial version of Macro Scheduler for automating a process of logging into a website and navigating to a series of file downloads, with the intent of upgrading to a full version if it proves suitable for this task. Unfortunately I have hit a strange stumbling block.

The website in question is at https://employercenter.regence.com. Unfortunately I cannot provide a login since the site deals with sensitive personal information. However, most of the problems I am having can be experienced on this login page as well.

Using the macro I've written, I can launch an IE instance and navigate to the site using with no problem. However, once I'm there, many of the "IE[whatever]" functions seem not to work properly.

For instance, I can get to the site using IENavigate, but once there I cannot use IENavigate again to get to any other site (whether it's another page on the same site, or another site entirely).

The IE functions do seem to work from other sites. For example, I can IENavigate to Google, use IEFormFill to enter a search term, IEFormSubmit to initiate the search, and so on. If I then IENavigate to the Regence site, I get there just fine. But if I then attempt to IENavigate back to Google, nothing happens.

One possible suspect I've found is that the page has a few instances of broken HTML tags, at least according to IE10's console. I wouldn't expect that to be the problem, since I presume Macro Scheduler is using IE's API and the site works fine in IE itself, but maybe I'm wrong about that?

The IE functions usually return an unsuccessful result for the return value, but I have not seen any indication of what the error could be while in the debugger. Of particular concern to me is the fact that IEWaitDocumentComplete always times out and returns 0, which suggests to me that it never recognizes the page as having been fully loaded and thus can't parse it. If that's the case then it would certainly explain some things.

It's also worth noting that I can navigate the site using image recognition and mouse/keyboard functions. But that's obviously kind of fragile, and in any case it won't be adequate for some of the things I intend to do after logging in.

Sadly, I have no control over the site in question, so I have to be more focused on workarounds than real solutions if the problem is indeed something that has to be fixed on the site (as I suspect). I have tried disabling Javascript in IE in the hopes that some client-side script was interfering with the macro, but did not see any change in behavior.

For reference and testing, here is my macro:

Code: Select all

MouseMove>0,0
Let>delay=1

//URL's and credentials
Let>google=http://www.google.com
Let>loginURL=http://employercenter.regence.com
Let>formName=dsmartSignon
Let>username=mylogin
Let>password=mypassword

//Enable automatic downloads to My Documents dir, modify path if required
IEOnDownload>1,,ie_res

//Set timeout for ClickTag and FormFill to 10 seconds, increase if pages load more slowly
IESetTimeout>10,ie_res

//My IE instance
IECreate>IE[0]
//To prove that IENavigate itself works, go to Google
IENavigate>IE[0],google,ie_res
//Store current URL, just to test IEGetURL
IEGetURL>IE[0],curUrl
//Test form fill/submit by doing a search
IEFormFill>IE[0],,gbqf,q,Macro Scheduler,,ie_res
IEFormSubmit>IE[0],,gbqf,ie_res
IEWaitDocumentComplete>IE[0],ie_res

//Now go to the actual site I'm working with.  ie_res is 0 (good) after IENavigate, but still 0 (bad) after IEWaitDocumentComplete
IENavigate>IE[0],loginURL,ie_res
IEWaitDocumentComplete>IE[0],ie_res

//Try getting current URL again.  Note how this time it gets nothing
IEGetURL>IE[0],curUrl

//Try to go back to Google.  Nothing happens, and ie_res gets set to 1
IENavigate>IE[0],loginURL,ie_res

// Log into the site
Gosub>doLogin

//Attempt to close the window (this also doesn't work)
IEQuit>IE[0],ie_res

// Login function
SRT>doLogin

  //Attempt to fill in form with IE functions (doesn't work)
  //username 
  IEFormFill>IE[0],,formName,USER,username,,ie_res
  //password
  IEFormFill>IE[0],,formName,PASSWORD,password,,ie_res
  //submit
  IEFormSubmit>IE[0],,formName,ie_res
  
  //Fill in login form using img-rec and mouse/keyboard functions (this works, using images I captured with the wizard)
  //username
  FindImagePos>%BMP_DIR%\username_field.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
  If>NumFound>0
    MouseMove>XArr_0,YArr_0
    Wait>1
    LClick
    Send>username
  Endif
  //password
  FindImagePos>%BMP_DIR%\password_field.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
  If>NumFound>0
    MouseMove>XArr_0,YArr_0
    Wait>1
    LClick
    Send>password
  Endif
  //submit button
  FindImagePos>%BMP_DIR%\login_button.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
  If>NumFound>0
    MouseMove>XArr_0,YArr_0
    Wait>1
    LClick
    IEWaitDocumentComplete>IE[0],ie_res
  Endif
  
END>doLogin


User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1348
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Why does this page break IE functions?

Post by Dorian (MJT support) » Thu Aug 14, 2014 12:20 am

Hi devzt,

I tried your script, and wasn't able to replicate any problems. The only issue I had was with the image recognition, and that was only because we don't have the image files.

I was able to create a very simple script which will visit the site you mentioned, detect if a log in was required, and if so, log in.

I created a video showing how I created it from scratch, along with a (rather rambling) commentary. LINK, and have also attached the script I made to this post.

I hope this helps,

Dorian.
Yes, we have a Custom Scripting Service. Message me or go here

devzt
Newbie
Posts: 2
Joined: Wed Aug 13, 2014 12:38 am

Re: Why does this page break IE functions?

Post by devzt » Thu Aug 14, 2014 3:16 pm

Hi Dorian,

Thanks for your reply. Unfortunately the script you posted is not working for me, which is strange since it so obviously worked in your video.

Obviously this means there is some problem on my end, other than the macro script. I will investigate further and let you know what I find. Thanks for helping me rule out problems with the macro itself and with the Regence site.

EDIT: It looks like I've found at least a partial solution. The problem seems to be IE's Protected Mode. If I turn that off then suddenly everything seems to work fine. This means I'll need to add the site to my trusted sites list, so that I don't have to keep Protected Mode off globally.

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

Re: Why does this page break IE functions?

Post by Marcus Tettmar » Thu Aug 14, 2014 4:57 pm

You do need to disable protected mode for WR functions to work - IE can't be scripted unless protected mode is disabled unfortunately. When you start WebRecorder it does tell you that you need to do this.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

robert.smith
Newbie
Posts: 2
Joined: Fri Jul 15, 2016 10:05 pm

Re: Why does this page break IE functions?

Post by robert.smith » Fri Jul 15, 2016 10:09 pm

I'd like to write a script that Macroscheduler can use to check if IE is in protected mode.
I would appreciate any suggestions on a simple way to accomplish that.
I am planning to post back here with my results when I figure it out.

User avatar
Meryl
Staff
Posts: 124
Joined: Wed Sep 19, 2012 1:53 pm
Location: Texas
Contact:

Re: Why does this page break IE functions?

Post by Meryl » Mon Jul 18, 2016 3:42 pm

Robert,

Answer might be in this post about protected mode.

robert.smith
Newbie
Posts: 2
Joined: Fri Jul 15, 2016 10:05 pm

Re: Why does this page break IE functions?

Post by robert.smith » Wed Jul 20, 2016 9:09 pm

viewtopic.php?t=5925 is the correct link to the issue you mentioned (thank you for drawing my attention to it).
After a bit more research I think I will end up creating a sub routine to use cmd/registry check to determine status of protected mode.

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