Jump to content

Stuck using _IELinkClickByIndex


Recommended Posts

Hi,

I am having trouble using _IELinkClickByIndex.

In my code below, near the end, when I use _IELinkClickByIndex it clicks the link I need which creates a pop-up however the script just hangs, it seems to just get stuck or be looping when I use it.

Can anyone see whats wrong with my code?

Func Navigate()

_IELinkGetCollection($oIE)
Local $oLinks = _IELinkGetCollection($oIE)
Local $iNumLinks = @extended

   For $oLink In $oLinks


      If StringInStr($oLink.href, "loadFaultTracker.do") Then

         _IEAction($oLink, "click")
         ExitLoop
      EndIf
   Next





_IELoadWait($oIE)

Local $sMyString = "Launch application"
Local $oLinks = _IELinkGetCollection($oIE)
   For $oLink In $oLinks
      Local $sLinkText = _IEPropertyGet($oLink, "innerText")
      If StringInStr($sLinkText, $sMyString) Then

         _IEAction($oLink, "click")
         ExitLoop
         EndIf
   Next

      _IELoadWait($oIE)
      Sleep(2000)









Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
Local $oFrame = 0
   For $i = 0 To ($iNumFrames - 1)
      $oFrame = _IEFrameGetCollection($oIE, $i)
      ;~    MsgBox(0, "", $oFrame.id)
      $sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF
      $o_form = _IEFormGetObjByName($oFrame, "MainForm")

      $oQuery = _IEFormElementGetObjByName($o_form, "faultrec_type_single")
      _IEFormElementSetValue($oQuery, "LLU")

      Sleep(500)


      $oQuery = _IEFormElementGetObjByName($o_form, "fault_id")
      _IEFormElementSetValue($oQuery, "1-25084694984")
      Sleep(500)

      $oQuery = _IEFormElementGetObjByName($o_form, "btnApplyFilter")


      _IEAction($oQuery, "click")
      Sleep(3000)
;~  _IELinkClickByIndex($o_form, 203)
   Next
   ;~ MsgBox($MB_SYSTEMMODAL, "Frames Info", $sTxt)


Local $oFrames = _IEFrameGetCollection($oIE)
Local $iNumFrames = @extended
Local $sTxt = $iNumFrames & " frames found" & @CRLF & @CRLF
Local $oFrame = 0
   For $i = 0 To ($iNumFrames - 1)
      $oFrame = _IEFrameGetCollection($oIE, $i)
      $sTxt &= _IEPropertyGet($oFrame, "innertext") & @CRLF

      $o_form = _IEFormGetObjByName($oFrame, "MainForm")
      ;~ _IELinkClickByIndex($o_form, 203)
      ExitLoop
   Next



_IELinkClickByIndex($o_form, 203)

Global $sText = _IEBodyReadText($oIE)

;~ MsgBox($MB_SYSTEMMODAL, "Body Text", $sText)

;~ ClipPut($sText)
;~ _IEQuit($oIE)
EndFunc
Link to comment
Share on other sites

There are ways around that.  The .click, is not going to return until the new window is closed (script will wait)...you can create a second script to click, or focus on the element, and controlsend {enter}.

Edited by jdelaney
IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Link to comment
Share on other sites

See the second example for _IEAction

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

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...