Sign in to follow this  
Followers 0
graydwarf

Waiting for IE Modal Dialog to load

2 posts in this topic

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.

Share this post


Link to post
Share on other sites



You could put your attach in a loop, waiting for success...

Do
    $oIE_new  = _IEAttach($oWinHandle, "HWND")
    Sleep(1000)
Until IsObj($oIE_new)

You can also use _IEDocReadHtml($oIE_new) to test the content of the document. It is likely being populated using asynchronous methods, so the DOM thinks that it is ready, but the server is still pushing info to it.

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

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