Jump to content

StringInStr() and _IEDocReadHTML() New Behavior When Run As a Service - IE11


Recommended Posts

Summary:

I am completely stumped and have tried everything I can think of. Sorry for the excessive information, I just want to save time in the Q & A Process.  At this time, my problem appears to be some very obscure interaction between 1)  _IEDocReadHTML()  and StringInStr()  2)  having the script be executed by a system service 3)  IE11   4) The specific version of the custom JVM based web application I'm automating.  I've ruled out each of these components individually, and am now stuck.  If you are good with _IE(), any insight would be appreciated.  It's convoluted, so I'll be grateful if I get any responses at all. Thanks in advance. 

Details: 

My script is automating the browsing of an Intranet "WebApp" which runs on Oracle Weblogic web server, and is therefor JVM based.  I am dealing with two versions of "WebApp", 5.0, and 5.1.  A system service kicks off the script regularly and reads the results via STDOUT, then records them in a database.  It had been working very well on "WebApp" versions 5.0 and 5.1 while running the scripts from a Server 2008 R2 server running IE8. 

Recently, I moved the scripts to be launched from a Server 2012 R2 box running IE11.  After putting the intranet sites in compatibility mode, all the 5.0 servers are working just fine when run as a service.  The 5.1 servers are working fine as well, but only when I run them manually from CLI (hidden or visible both work great).

Strangely, the script fails under the following circumstances: 

-Triggered by the system service (works 100% if I run from CLI, even hidden) 

-The text I'm searching for is in the "JVM" applet 

-IE 11 (intranet zone, low security, compatibility mode)

-Accessing "WebApp" version 5.1  (Java applet 5.0 no problem)

I've narrowed down what is failing exactly. It's failing to recognize text using StringInStr() and _IEDocReadHTML() (in a 30 second loop).  

Here are the related steps with the failure steps indicated with ***

Test Login Page Loads

Login with Credentials

Populate a "Search" field on the landing page using _IEFormElementSetValue()

Submit the form using _IEFormSubmit()

***Search the resulting page for text  _IEDocReadHTML() (in a loop)

Enter another search term with _IEFormElementSetValue()

Submit the form using _IEFormSubmit() again

***Search the resulting page for text with _IEDocReadHTML() (in a loop)

Logout and close browser

Here's my "Search Page for Text" function: 

Do
$i = $i + 1
$aStatusCode[$sCurrentStep][1] = $i
$htmlResultString = _IEDocReadHTML ($oIE)

For $j = 1 To Ubound($aSearchTermArray) - 1
If StringInStr($htmlResultString,$aSearchTermArray[$j]) Then
$aStatusCode[$sCurrentStep][2] = 200 + $sCurrentStep
$aStatusCode[$sCurrentStep][3] = "Info : Found Desired Text : " & $aSearchTermArray[$j]
ExitLoop
EndIf
Next

If $logging >= 2 Then _LogRawData($htmlResultString,$sCurrentStep)
If Round($aStatusCode[$sCurrentStep][2],-2) <> 100 Then
ExitLoop
Else
Sleep (1000)
EndIf
Until $i = 30
What have I tested So Far? 
 

As I said, the search routine works great when run manually from CLI.  This confirms that _IEDocReadHTML() access the text inside the JVM applet on WebApp 5.1, on IE11 just fine.  Furthermore, when I dump the result of _IEDocReadHTML() to an HTML file and open in notepad, the string is there as expected.  I then dumped the results of _IEDocReadHTML() from a successful execution (when i run from CLI manually) and the two HTML files are identical.   So, it's clearly reading the text from the JVM applet, working normally. 

At the same time, all these functions work fine when 1) run as a child process of a system service, 2)  and accessing all the other service which run WebApp 5.0. This confirms running the script from a system service with IE11, using _IEDocReadHTML() to gather text from inside a JVM applet is possible.  

Regards,

Jerry

 

Link to comment
Share on other sites

Try outputting $htmlResultString somewhere to see if it contains what you expect it to contain.  

Examine @error after your _IE calls to see what error status might be returned.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

When I dump the result of _IEDocReadHTML() to an HTML file (htmlResultString)and open in notepad, the string is there as expected.  I then dumped the results of _IEDocReadHTML() (htmlResultString)from a successful execution (when i run from CLI manually) and the two HTML files are identical.  

I will try dumping @error after each  _IEDocReadHTML()  in the loop. 

Thanks Dale

Link to comment
Share on other sites

Is there a way to redirect the contents if _IEErrorNotify() to my debug file rather than console?  Because the script only has issue when run as a service, I do not get to see the console. 

I'll go ahead and write the value of @error for now. 

Link to comment
Share on other sites

I added the command below in three places and re-ran. (I substituted the actual IE function name for "_IEfunctionname" in each case). 

1. After _IEFormElementSetValue

2. After _IEFormSubmit

3. After _IEDocReadHTML (inside the loop). 

There were no errors in the debug log. 

If @Error Then _FileWriteLog($debugFile,"_IEFunctionName @Error =" & @error,1)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...