internet-explorerautomationautoitscite

Clicking a specific href in AutoIT


Trying to automate the clicking of the 'Unshipped' widget from the Amazon Seller Central Home Page with AutoIT. Here's what my function looks like, I tried to follow the one in the Wiki for getting a collection of links then looping through them, but doesn't seem to work for me.

#include <IE.au3>
#include <MsgBoxConstants.au3>


Navigate("Unshipped")

Func Navigate($sNavigate)
    Local $oIE = "https://sellercentral.amazon.com/hz/home"
    Local $oLinks = _IELinkGetCollection($oIE)

    Local $iNumLinks = @extended

Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
For $oLink In $oLinks
    $sTxt &= $oLink.href & @CRLF
Next
MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt)

EndFunc

Solution

  • I can't log into the Amazon seller central home page but this should work. I tested it on the login page and it worked fine. Just make sure that you are using a global variable/the same IE window so that you stay logged in. In this example where you run your login function you want to make sure you are using global variable $g_oIE not $oIE.

    #include <IE.au3>
    #include <MsgBoxConstants.au3>
    
    ;start IE with a Global variable
    Global $g_oIE = _IECreate()
    
    ;run your login fuction here using the global variable $g_oIE and check to make sure you are logged in.
    
    ;should get your links (it uses the global IE variable)
    GetLinkCollection()
    
    Func GetLinkCollection()
        _IENavigate($g_oIE, "https://sellercentral.amazon.com/hz/home")
    
        Local $oLinks = _IELinkGetCollection($g_oIE)
    
        Local $iNumLinks = @extended
    
        Local $sTxt = $iNumLinks & " links found" & @CRLF & @CRLF
        For $oLink In $oLinks
            $sTxt &= $oLink.href & @CRLF
        Next
        MsgBox($MB_SYSTEMMODAL, "Link Info", $sTxt)
    
    EndFunc   ;==>GetLinkCollection