Quantcast
Channel: AutoIt v3 - General Help and Support
Viewing all articles
Browse latest Browse all 12506

Waiting for IE Modal Dialog to load

$
0
0
I can't seem to find anything that will help me determine when a modal dialog has finished loading. Here's the scenario:

This is a poorly performing system where IE actions such as navigations can take upwards of 60 seconds to load.

- In my automated script, I input a search query and click Go.
- After anywhere from 1-60 seconds, the modal dialog will appear and the body is initially blank.
- The URL in the address bar actually changes to a different URL after a few (10-20) seconds (post back) and then
- at some point, a large amount of content loads

Here's the snippet of code that I'm trying to improve.

IE_ClickLinkByText($oFrame, $sGuidelineCodeLink, 0, $iIndentCount) ; FORUM COMMENT: oFrame is a derived from a parent oIE object that isn't seen here.

Local $oIE_new

Common_LogComment("Waiting for dialog to load. Searching for " & $sValidationString, $iIndentCount)

$PreviousTitleMatchMode = Opt("WinTitleMatchMode", 2)
Local $oWinHandle = WinWait($sValidationString, "", 120) ; FORUM COMMENT: I beleive I am able to get the HWND 100% of the time.
Opt("WinTitleMatchMode", $PreviousTitleMatchMode)

;
; FORUM COMMENT: I never fail here
;
If $oWinHandle = 0 Then
	Test_Fail($oIE, "GuidelineSearch_AutoSelectGuideline() - Timed out while waiting for popup dialog!", $iIndentCount)
EndIf

$oIE_new  = _IEAttach($oWinHandle, "HWND")

;
; FORUM COMMENT: This is where I fail intermittently. @error is 7 so I feel like its a timing issue where IEAttach doesn't like the state of the HWND object or perhaps properities of the HWND object are still getting populated. I can put in a hard sleep here but I would prefer it be event driven.
;
If $oIE_new = 0 Then
	If @error = 5 Then
		Test_Fail($oIE, "GuidelineSearch_AutoSelectGuideline() - Invalid value passed in for $oWindHandle! @error: " & @error, $iIndentCount)
	ElseIf @error = 7 Then
		Test_Fail($oIE, "GuidelineSearch_AutoSelectGuideline() - No matching dialog found! @error: " & @error, $iIndentCount)
	EndIf
EndIf
If StringInStr(_IEPropertyGet($oIE_new, "locationurl"), $sTestSite) Then
	Common_LogComment("Found matching dialog.", $iIndentCount)
Else
	Common_LogComment("Found wrong dialog.", $iIndentCount)
EndIf


After a succesful Attach, I tried looking at these IE properities to see if I can use any of them to determine if the document is done loading but they never change.

When I looked at PropertyGet for the oIE object, I get the following values for 30 seconds even though the page loaded and completed.
[11:12:56] busy:False
[11:12:57] readystate:4
[11:12:57] statusbar:True
[11:12:57] statustext:Done

When I looked at the oFrame object, I got all 0's

When I looked at the $oIE_new object, I got mixed results where statustext turned into blank after 10 seconds but that only happened once which is confusing.

Viewing all articles
Browse latest Browse all 12506

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>