Sign in to follow this  
Followers 0
Chimaera

Is there a way to tell for certain a webpage was loaded

13 posts in this topic

#1 ·  Posted (edited)

Im working on a check sheet for work but im stumped on a way to check a webpage

The button when pressed opens IE/Chrome and Firefox or however many are present on the system

But i want to set a reg key that the check was completed , ie: all three browsers connect properly to a webpage

I looked at _IECreate but i cant get it to error if the internet is down for eg

I tried getting to load a second page through the first no joy it cant seem to detect what i need.

And i need to have chrome and FF check as well

Any hints?

Edited by Chimaera

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

If you have something you want to interact with...loop until it's present.  Will always work.  Unless your page never produces it, of course.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

I dont have a thing to interact with, all i need to know is that the webpage opened in the browsers 

Because we check that all installed browsers work before we send the machine back to the customer

It has to be certain as it sets a reg key to say the test is passed, the tech should be looking as well but human interaction.....

When i tried with the internet disconnected with _IECreate it passes because the browser opens, but it hasn't loaded the page.

This maybe more tricky than i thought, ill prob have to do a yes / no box for now

Share this post


Link to post
Share on other sites

You need _IELoadWait for the _IE* funcs, and I"m sure the ff.au3/chrome.au3 have something similar.


Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I tried this with a disabled network connection and it doesn't give error

$test = _iecreate ('www.bbc.co.uk',0,1)
$test1 = _IELoadWait ($test)

ConsoleWrite( $test1 & @crlf) 

The trouble is when we have problems at work the browsers often need resetting to get back on the net so it has to be able to detect that the browser didnt work or even that its not connected.

Like i said it may not be possible in the way i think it is :)

Thx

Edited by Chimaera

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

If you navigate to a specific page, and then validate that a know element is present, you know it loaded.  (this is a re-phrasing of what my initial suggestion was.)

example:

$oIE = _IECreate("www.google.com")
Local $oObj
$iTimer = TimerInit()
While Not IsObj($oObj) And TimerDiff($iTimer)<10000
    ; loop until you can see the google search input
    $oObj = _IEGetObjById($oIE,"lst-ib")
WEnd

If IsObj($oObj) Then
    ConsoleWrite("page fully loaded!" & @CRLF)
Else
    ConsoleWrite("page NOT fully loaded!" & @CRLF)
EndIf

Better representation:

_IEErrorHandlerRegister()
$oIE = _IECreate("www.google.com",0,1,0)
Local $oObj
$iTimer = TimerInit()
While Not IsObj($oObj) And TimerDiff($iTimer)<10000
    ; loop until you can see the google search input
    $oObj = _IEGetObjById($oIE,"lst-ib")
    ConsoleWrite("Attempt" & @CRLF)
WEnd

If IsObj($oObj) Then
    ConsoleWrite("page fully loaded!" & @CRLF)
Else
    ConsoleWrite("page NOT fully loaded!" & @CRLF)
EndIf
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I dont get a consolewrite either with those the page opens but no result

The second one i managed to find the _IEErrorHandlerRegister() and added it to the script

;===============================================================================
;
; Function Name:   _IEErrorHandlerRegister()
; Description:      Register and enable a user COM error handler
; Parameter(s):     $s_functionName - String variable with the name of a user-defined COM error handler
;                                     defaults to the internal COM error handler in this UDF
; Requirement(s):   AutoIt3 V3.2 or higher
; Return Value(s):  On Success  - Returns 1
;                   On Failure  - Returns 0 and sets @ERROR
;                   @ERROR      - 0 ($_IEStatus_Success) = No Error
;                               - 1 ($_IEStatus_GeneralError) = General Error
;                   @Extended   - Contains invalid parameter number
; Author(s):        Dale Hohm
;
;===============================================================================
;
Func _IEErrorHandlerRegister($s_functionName = "__IEInternalErrorHandler")
    $sIEUserErrorHandler = $s_functionName
    $oIEErrorHandler = ""
    $oIEErrorHandler = ObjEvent("AutoIt.Error", $s_functionName)
    If IsObj($oIEErrorHandler) Then
        SetError($_IEStatus_Success)
        Return 1
    Else
        __IEErrorNotify("Error", "_IEPropertySet", "$_IEStatus_GeneralError", _
                "Error Handler Not Registered - Check existance of error function")
        SetError($_IEStatus_GeneralError, 1)
        Return 0
    EndIf
EndFunc   ;==>_IEErrorHandlerRegister 

But it then errors on __IEErrorNotify which i cant seem to find, i have #include <IE.au3> added

Edited by Chimaera

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

I'm using an older version of _IE* and autoit....you will need to find the relevant functions...or maybe they aren't even required anymore (no idea).

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

why don't you ping continuosly your web servers to check if are on line or not instead of checking the loading of web pages (also the presence of web pages in the cache could give false positive)


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
Share on other sites

Im actually checking that the browser loads a webpage, when they have been virused etc they often dont work.

As a final technican check we insist the check all browsers work before it goes back to the customer.

I have automated like this so far

Case $BrowserOpen
            ShellExecuteWait("iexplore.exe")
            If FileExists(@ProgramFilesDir & '\Google\Chrome\Application\chrome.exe') Then ShellExecuteWait("chrome.exe")
            If FileExists(@ProgramFilesDir & '\Mozilla Firefox\firefox.exe') Then ShellExecuteWait("firefox.exe")
            If Not ProcessExists('iexplore.exe') Or Not ProcessExists('chrome.exe') Or Not ProcessExists('firefox.exe') Then
                Switch MsgBox(BitOR($MB_YESNO, $MB_ICONWARNING), 'Browsers Check', 'Did All Browsers Work')
                    Case 6
                        GUICtrlSetImage($BrowserIcon, $tick)
                        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\Setup\Simple', 'Browser', 'REG_SZ', _Date_Time_SystemTimeToDateTimeStr($CuDate))
                    Case 7
                        RegWrite('HKEY_LOCAL_MACHINE\SYSTEM\Setup\Simple', 'Browser', 'REG_SZ', 'False')
                EndSwitch
            EndIf

So it waits for all three browsers then they have to choose and it sets a key accordingly

I just wondered whether it could be completly automated BUT im beginning to think human intervention at this point isnt a bad thing

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

If ya'll are techs, then load the perspective pages with your own html that creates a log file on your sever, then read the server data from your app.

Very few lines of code and very little over head.

Edit:

eg.

html/javascript that navigates to a web page on your sever (just a computer running apache or something if you don't have a dedicated server).  It could be a simple php page that collects browser type, whatever you want, then creates a log file or you could write to a mysql db (my preference).

then if it's on a network, you could read the log file or connect to the mysql db remotely (if it's not on a network) (of course doesn't have to be mysql)

I've run this scenario many many times in the past for other things.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
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
Sign in to follow this  
Followers 0