Paranthaman
Paranthaman

Reputation: 21

Why is _IELinkClickByText() not clicking this link?

I'm having trouble using _IELinkclickbytext(). I am trying to click a link :

<span class="actionLinks ">
<a class="actionItemName" href="analyze/addtoquickanalysis.do" title="Add to Quick Analysis">CPU <wbr></wbr>Util<wbr></wbr>izat<wbr></wbr>ion <wbr></wbr>%</a>
</span>

AutoIt code :

Local $sMyString = "CPU"
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")
    If StringInStr($sLinkText, $sMyString) Then
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

Where did I went wrong?

Upvotes: 1

Views: 364

Answers (1)

Erinne
Erinne

Reputation: 46

As far as I see the logic seems right to me. You can try to login what linktext you are actually getting

Local $sMyString = "CPU"
Local $oLinks = _IELinkGetCollection($oIE)
For $oLink In $oLinks
    Local $sLinkText = _IEPropertyGet($oLink, "innerText")

    ConsoleWrite('current link text' & $sLinkText & @CRLF)

    If StringInStr($sLinkText, $sMyString) Then
       ConsoleWrite('found proper link ' & $sLinkText & @CRLF)
        _IEAction($oLink, "click")
        ExitLoop
    EndIf
Next

In this way you will see what is the actual problem. Is the link missing from _IELinkGetCollection or something else is happening.

Upvotes: 1

Related Questions