Jump to content
Sign in to follow this  
n0Lamers

Problem with _IEAttach (I think) on Vista

Recommended Posts

n0Lamers

I've written a script that is working as expected on XP SP2, but fails shortly after doing a second _IEAttach on Vista (first one succeeds). I use the #RequireAdmin at the top of my script (this got me past another problem I was experiencing only on Vista), so now I get the UAC prompt in the beginning. I'm not real concerned about the UAC prompt ATM. Here is the snippet I'm consistently experiencing issues with:

;The following four lines represent the same structure as an _IEAttach
;that occured earlier in the script.  The earlier structure worked on
;Vista, so I'm at a loss as to why this second set of practically identical
;statements won't work on Vista (only differences were the var names
;and window titles):
WinWait("Normal - ")
$handle = WinGetHandle("Normal - ")
$oNormal = _IEAttach($handle, "HWND")
_IELoadWait($oNormal)

;I've tried excluding and including the following sleep because I wasn't
;sure if _IELoadWait was actually waiting for *all* embedded content to
;be loaded/rendered.  It didn't seems to help or hurt the situtation on
;Vista, so I've commented it out for now for simplicity:
;Sleep(3000)

$oFrames = _IEFrameGetCollection ($oNormal)
$iNumFrames = @extended
For $i = 0 to ($iNumFrames - 1)
    $oFrame = _IEFrameGetCollection ($oNormal, $i)
    $sMyString = "Short Valid HyperLink"

    ;;;;;It fails at the following line on Vista with the "Variable
    ;;;;;must be of type 'Object'" error:
    $oLinks = _IELinkGetCollection($oFrame)
    For $oLink in $oLinks
        $sLinkText = _IEPropertyGet($oLink, "innerText")
        If StringInStr($sLinkText, $sMyString) Then
            _IEAction($oLink, "click")
            ExitLoop
        EndIf
    Next
Next

It may be helpful to note that the above snippet is showing a new _IEAttach latching onto a re-used window, but I'm getting and saving a new copy of the file handle before that _IEAttach. I did this to at least help the var-name readability logic a bit, and also possibly to establish a bit more peace-of-mind as far as to the "version" of the window I intended to refrence, because the re-used window has a completely different title and contents from when I performed the previous _IEAttach. It may not be necessary per se to do this, but even with re-acquiring the handle to the re-used window, the script runs as expected on XP SP2.

Any help is appreciated, thanks!

Share this post


Link to post
Share on other sites
DaleHohm

Please add _IEErrorHandlerRegister() near the top of your script. Then watch the colsole...

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
n0Lamers

Sorry it took awhile to get back, had problems involving temporary passwords to the forum, and also got sidetracked at work. After Dale's post I tried this several more times on a Vista machine and the error never occurred again (at least not in pop-up form, may have happened in a way hidden from eyesight, however) on Vista, but the script would still fail to execute to completion on Vista. So I installed and ran it using SciTE and the "_IEErrorHandlerRegister()" on both XP and Vista.

The weird thing is that the console on XP threw errors, but the console on Vista did not. This is weird to me at least because even though the console threw errors, the script executed to completion on XP as expected. And the same could not be said for Vista as I mentioned before. I was testing the script on two different platforms, but was using IE7 in both cases. I don't have the Vista machine with me right now, but if it helps the XP version of IE7 I tested the script with is 7.0.5730.13

The following are the console errors that were reported on XP:

--> IE.au3 V2.3-1 Warning from function _IEFormGetObjByName, $_IEStatus_NoMatch

--> IE.au3 V2.3-1 Error from function _IEFormElementGetObjByName, $_IEStatus_InvalidDataType

--> IE.au3 V2.3-1 Error from function _IEAction, $_IEStatus_InvalidDataType

--> IE.au3 V2.3-1 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch

The person who was the intended audience for the demo is still going through her evaluation process of various testing suites anyway, so there is no immediate need for a complete solution because she has neither ruled in favor, nor ruled out AutoIt. The script was only to serve the purpose of demoing AutoIt as a viable alternative to expensive testing suites, and it has more than proved this IMO for Web testing on XP using the IE.au3 UDFs. Automated IE testing seems to be one of the real challenges to get "just right" on the implementation side, possibly due to all the available versions of the browser that are out there and how those changes can affect DOM traversal, etc.

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  

×