Jump to content

Problem with _IEPropertyGet


Recommended Posts

#include <IE.au3>
$oIE = _IECreate("http://reapercorps.org")
$links=2
$sMyString1 = "Admin Area"
$sMyString2 = "File uploads: "
$oLinks = _IELinkGetCollection($oIE)

do
For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString1) Then
        _IEAction($oLink, "click")
        $Links-=1
        ExitLoop
    EndIf
    
    If StringInStr($sLinkText, $sMyString2) Then
        _IEAction($oLink, "click")
        $Links-=1
        ExitLoop
    EndIf
    
Next
until $Links=0

It will click admin area, then error.

--> IE.au3 V2.4-0 Error from function _IEPropertyGet, $_IEStatus_InvalidObjectType

This logic seems right to me, but obviously it isn't...

tolle indicium

Link to comment
Share on other sites

Suggestion....

#1 Add an error handler

$MyErrorHandler = _IEErrorHandlerRegister()

#2 I'm not sure of the "innertext" on a link... that may not be correct, I dunno, Maybe the text can be used like...

If StringInStr($oLink, $sMyString1) Then

It is possible that not all links have "innertext" and that errors, as it should, but ??

Just some thoughts here

8)

NEWHeader1.png

Link to comment
Share on other sites

#include <IE.au3>
$oIE = _IECreate("http://reapercorps.org")
$links=2
$sMyString1 = "Admin Area"
$sMyString2 = "File uploads: "
$oLinks = _IELinkGetCollection($oIE)

do
For $oLink in $oLinks
    $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString1) Then
        _IEAction($oLink, "click")
        $Links-=1
        ExitLoop
    EndIf
    
    If StringInStr($sLinkText, $sMyString2) Then
        _IEAction($oLink, "click")
        $Links-=1
        ExitLoop
    EndIf
    
Next
until $Links=0

It will click admin area, then error.

This logic seems right to me, but obviously it isn't...

Once you click on one of the links and navigate away, the objects in the collection are no longer valid. So it should work the first time through, then fail on the second pass.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...