Jump to content

Browser (IE) HTML document ready event


rusdady
 Share

Recommended Posts

Hi.

Is there a way in autoit script to wait while browser's html document fully loaded, instead of putting script in Sleep?

I have this code:

        

Sleep(8000)
$oDocument=_UIA_getFirstObjectOfElement($oIE,$cDocumentWindow, $treescope_subtree)
Sleep(8000)

If not isobj($oDocument) Then
   _UIA_DumpThemAll($oIE,$treescope_subtree)
Else
   ......
EndIf

 

I do not like this - Sleep(8000). Sometimes it takes 2 seconds to load, sometimes it takes over 8 seconds...

I would like to have something that would wait when html document is ready/loaded.

Thank you.

Link to comment
Share on other sites

Thank you! You pointed me to the right direction. The only problem is that when I load page it popups the "Windows Security" window asking for credentials and until credentials entered page is not loading... but I'll give it a try. Thanks anyway!

Link to comment
Share on other sites

Finally, I ended up with following approach:
 

$oDocument=_UIA_getFirstObjectOfElement($oIE,$cDocumentWindow, $treescope_subtree)
If not isobj($oDocument) Then
    _UIA_DumpThemAll($oIE,$treescope_subtree)
Else
    $t=stringsplit(_UIA_getPropertyValue($oDocument, $UIA_BoundingRectanglePropertyId),";")
    _UIA_DrawRect($t[1],$t[3]+$t[1],$t[2],$t[4]+$t[2])

    ;~loop until button is loaded
    local $oClock =_UIA_getFirstObjectOfElement($oDocument,"id:=TodaysActivities_btnClock", $treescope_subtree)
    While not IsObj($oClock)
        Sleep(500)
        $oClock =_UIA_getFirstObjectOfElement($oDocument,"id:=TodaysActivities_btnClock", $treescope_subtree)
    WEnd

    _UIA_action($oClock,"leftclick")

    Sleep(2000)
    _UIA_action($oIE,"close")
EndIf

I put "while" cycle to check if needed button is loaded. It seems like it is working...

If anyone has better ideas - please welcome to share it... :-)

Link to comment
Share on other sites

  • 3 weeks later...

Unfortunatelly, this part

;~loop until button is loaded
    local $oClock =_UIA_getFirstObjectOfElement($oDocument,"id:=TodaysActivities_btnClock", $treescope_subtree)
    While not IsObj($oClock)
        Sleep(500)
        $oClock =_UIA_getFirstObjectOfElement($oDocument,"id:=TodaysActivities_btnClock", $treescope_subtree)
    WEnd

has stopped working.

Script cannot find button by id. And it happend, i believe, after windows 10 update...

 

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

×
×
  • Create New...