Jump to content

IE Page Loading - Error Protection


Recommended Posts

So far, to ensure that a page is loaded correctly, I just read the text on the page and see if I can find a word unique to the page I'm trying to load. My current method is as follows:

$oIE = _IECreate()

_IENavigate($oIE, "http://google.com)
_IELoadWait($oIE)

;Makes sure page is loaded
$pageText = _IEBodyReadText($oIE)
$check = StringInStr($pageText, "Advanced Search")

If $check = 0 Then
    Do
        Sleep(30000)
        _IEAction($oIE, "refresh")
        $pageRefresh = _IEBodyReadText($oIE)
        $check = StringInStr($pageRefresh, "Advanced Search")
    Until $check > 0
EndIf
;-----------------------------------

However, I was wondering if there is a better way to do this. Perhaps there is a function or a method to read the url that is currently loaded?

The main thing I'm looking for is how to detect the url of the current page. That way, I can more easily accommodate for login pages.

Thanks in advance for any help.

Link to comment
Share on other sites

From the help file:

Several IE.au3 functions call _IELoadWait() automatically (e.g. _IECreate(), _IENavigate() etc.). Most functions that do this also allow you to turn this off with a $f_wait parameter if you do not want the wait or if you want to call it yourself.

#include 

$oIE = _IECreate("http://google.com")

MsgBox(0,"",_IEPropertyGet ( $oIE, "locationurl" ))
Link to comment
Share on other sites

So far, to ensure that a page is loaded correctly, I just read the text on the page and see if I can find a word unique to the page I'm trying to load. My current method is as follows:

However, I was wondering if there is a better way to do this. Perhaps there is a function or a method to read the url that is currently loaded?

The main thing I'm looking for is how to detect the url of the current page. That way, I can more easily accommodate for login pages.

Thanks in advance for any help.

Many web pages with logins use a standard Windows API to pop up a dialog box. The page in IE will not finish loading until the pop up dialog is dealt with. Of course, this is not an issue if the login is HTML code on the page.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Many web pages with logins use a standard Windows API to pop up a dialog box. The page in IE will not finish loading until the pop up dialog is dealt with. Of course, this is not an issue if the login is HTML code on the page.

:)

And if the former is the case, see the new example for _IEAction (Example 2) in the latest AutoIt release to find a method of dealing with it (I found I was answering this question several times a week, so I made certain the example got into this release).

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

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...