Jump to content

Recommended Posts

Posted

I've got a funny problem between two different installations of AutoIT. The first installation is on my test rig, my home computer, and is v3.3.14.5. The second installation is on another computer and is my production rig, but installed version is v3.3.14.1 (for security reasons cannot update). Since I cannot update my production rig, I downgraded to v3.3.14.1 on my test rig and the issue persists. 

Most all of my code is written on my test rig, tested, confirmed satisfactory, and then is copied over to the production rig where it runs without a hitch. This is the first time I've run into an issue where it is successful on one installation but not the other. I wanted to get peoples thoughts on why it might be, and whether or not there is another method or workaround that will work on both installations. 

 

#include <IE.au3>

$oIE = _IECreate()
_IENavigate($oIE, "https://www.fidelity.com/")

$body = _IEBodyReadHTML($oIE)
Sleep(2000)
If StringInStr($body, "Terms of Use") Then
    MsgBox(0, "Success", "The string 'Terms of Use' was found")
Else
    MsgBox(0, "Fail", "The string was NOT found")
EndIf

Exit

 

Test Rig:

Success
The string 'Terms of Use' was found

Production rig:

Fail
The string was NOT found

I want a website to load, and to do one thing if text is present and another thing is text is absent. This is where I am, but it's just not working on both computers. Both are x64, windows 10. Where should I go from here and what am I not checking properly?

Posted
1 hour ago, Danp2 said:

Try checking the value of @error following the call to _IEBodyReadHTML. Chances are it's non-zero.

Depending on your needs, you may be able to use _INetGetSource instead of the _IE* commands.

 

From what I can tell there are no errors, at least nothing being reported. I'll try to look into these two things. 

 

 

1 hour ago, zeenmakr said:

also write $body to text file with FileWrite() and see if html is successfully retrieved.

the issue could also be the result of StringInStr()


If StringInStr($body, "Terms of Use")

try 

If StringRegExp($body, '\bTerms of Use\b') Then

 

 

I replaced the code with what you provided (StringRegExp), and it worked on the test rig but still does not work on the production rig. How to I test the FileWrite() option to see if HTML is retrieved properly? 

Posted
34 minutes ago, Atrax27 said:

From what I can tell there are no errors, at least nothing being reported

what he meant was catch the @error code like this

$body = _IEBodyReadHTML($oIE)
MsgBox(0, 'catch @error', 'error code: '& @error)

 

Posted
19 minutes ago, Atrax27 said:

The resulting file here is blank, nothing present. Weird!

even in test rig?

also, when you are referring to test rig did you mean 'system a' and production rig as 'system b'? if so, are both systems has the same version of autoit installed

Posted
29 minutes ago, zeenmakr said:

even in test rig?

also, when you are referring to test rig did you mean 'system a' and production rig as 'system b'? if so, are both systems has the same version of autoit installed

Yes both have the same version installed. Test rig = computer A, production rig = computer B. 

 

The blank results file and "0" error code are on the computer B. 

Posted
1 minute ago, Atrax27 said:

both have the same version installed

same OS? you might have to wait for someone else to chime in. try right click 'run as administrator' 

Posted
29 minutes ago, zeenmakr said:

same OS? you might have to wait for someone else to chime in. try right click 'run as administrator' 

Yes same OS, no admin privileges on computer B, wonder if that limitation would prevent this from working. As a side note, the below code actually prints all the HTML code as well, so I can physically look at the words right there, but it's not recognizing them upon search (stringinstr)

 

MsgBox(0, "output", _INetGetSource('https://www.fidelity.com/'))
Posted
21 minutes ago, Atrax27 said:

MsgBox(0, "output", _INetGetSource('https://www.fidelity.com/'))

this is the same as $body or write to txt

let's start from the beginning, does the page fully loaded in Internet Explorer with this. this might be your answer.

#include <IE.au3>

 Local $oIE = _IECreate("https://www.fidelity.com/")
_IELoadWait($oIE)
MsgBox(0, "CLOSE IE?", 'click OK to close ie')
_IEQuit($oIE)

and what about this

Local $oIE = _IECreate("http://www.autoitscript.com")
_IELoadWait($oIE)
MsgBox(0, "CLOSE IE?", 'click OK to close ie')
_IEQuit($oIE)

 

Posted
42 minutes ago, zeenmakr said:

this is the same as $body or write to txt

let's start from the beginning, does the page fully loaded in Internet Explorer with this. this might be your answer.

#include <IE.au3>

 Local $oIE = _IECreate("https://www.fidelity.com/")
_IELoadWait($oIE)
MsgBox(0, "CLOSE IE?", 'click OK to close ie')
_IEQuit($oIE)

and what about this

Local $oIE = _IECreate("http://www.autoitscript.com")
_IELoadWait($oIE)
MsgBox(0, "CLOSE IE?", 'click OK to close ie')
_IEQuit($oIE)

 

The first one works and opens a browser window, but does not close the IE window once you click OK. Console output below:

 

--> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_ClientDisconnected (-2147417848, Browser has been deleted prior to operation.)
--> IE.au3 T3.0-2 Error from function _IELoadWait, $_IESTATUS_InvalidObjectType ()
--> IE.au3 T3.0-2 Error from function _IEQuit, $_IESTATUS_InvalidObjectTyp

 

The second one throws error code 1 but I assume that's because it was missing the #include. When I include ie.au3 it works, and it also does close the IE window upon MsgBox confirmation. No console errors here. 

Posted
36 minutes ago, Atrax27 said:

The first one works and opens a browser window

ok that is a good start, now try this

#include <IE.au3>

;~  Local $oIE = _IECreate("https://www.fidelity.com/")             ;show ie
Local $oIE = _IECreate("https://www.fidelity.com/", 0 , 0, 1)       ;hide ie
_IELoadWait($oIE)

; save innerHTML to text
Local $body = _IEDocReadHTML($oIE)
Local $sInnerHTML = @ScriptDir & '\innerHTML.txt'
FileWrite ($sInnerHTML, $body)

; open innerHTML in notepad
If FileExists($sInnerHTML) Then Run ('notepad.exe '& $sInnerHTML, @WindowsDir )

; search string
If StringRegExp($body, '\bTerms of Use\b') Then
    MsgBox(0, "Success", "The string 'Terms of Use' was found")
Else
    MsgBox(0, "Fail", "The string was NOT found")
EndIf

;~ MsgBox(0, "CLOSE IE?", 'click OK to close ie')
_IEQuit($oIE)                                                       ;it should close object  and shutdown ie

 

Posted
2 hours ago, Atrax27 said:

As a side note, the below code actually prints all the HTML code as well, so I can physically look at the words right there, but it's not recognizing them upon search (stringinstr)


MsgBox(0, "output", _INetGetSource('https://www.fidelity.com/'))

I overlooked this and didn't realized you used _INetGetSource() earlier , so here is the work around

#include <Inet.au3>

Local $innerHTMLSource = _INetGetSource("https://www.fidelity.com/", true)

Local $fInnerHTML = @ScriptDir & '\innerHTML.txt'
FileWrite ($fInnerHTML, $innerHTMLSource)

; open innerHTML in notepad [for testing]
;~ If FileExists($fInnerHTML) Then Run ('notepad.exe '& $fInnerHTML, @WindowsDir )

; read innerHTML Source back in from saved file
If FileExists($fInnerHTML) Then 
    Local $hFileOpen = FileOpen($fInnerHTML, $FO_READ)
    
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
    Else
        Local $sFileRead = FileRead($hFileOpen)
    EndIf

    FileClose($hFileOpen)
EndIf

; search string
If StringRegExp($sFileRead, '.*\bTerms of Use\b.*') Then
    MsgBox(0, "Success", "The string 'Terms of Use' was found")
Else
    MsgBox(0, "Fail", "The string was NOT found")
EndIf

 

or the earlier option could also be adapted to

#include <IE.au3>

;~  Local $oIE = _IECreate("https://www.fidelity.com/")             ;show ie
Local $oIE = _IECreate("https://www.fidelity.com/", 0 , 0, 1)       ;hide ie
_IELoadWait($oIE)

; save innerHTML to text
Local $innerHTMLSource = _IEDocReadHTML($oIE)

Local $fInnerHTML = @ScriptDir & '\innerHTML.txt'
FileWrite ($fInnerHTML, $innerHTMLSource)

; open innerHTML in notepad [for testing]
;~ If FileExists($fInnerHTML) Then Run ('notepad.exe '& $fInnerHTML, @WindowsDir )

; read file
If FileExists($fInnerHTML) Then 
  
    Local $hFileOpen = FileOpen($fInnerHTML, $FO_READ)
    If $hFileOpen = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "An error occurred when reading the file.")
    Else
        Local $sFileRead = FileRead($hFileOpen)
    EndIf

    FileClose($hFileOpen)
EndIf

; search string
If StringRegExp($sFileRead, '.*\bTerms of Use\b.*') Then
    MsgBox(0, "Success", "The string 'Terms of Use' was found")
Else
    MsgBox(0, "Fail", "The string was NOT found")
EndIf

_IEQuit($oIE)                                                       ;it should close object  and shutdown ie

 

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
×
×
  • Create New...