Jump to content

Recommended Posts

Posted

I want to get all the links on a webpage and search until I find a string - when the string is found I want to click the link. If the string isn't found on that page I want to click an image to go to the next page and do the search again. I've got so far but i'm struggling with the syntax. Any help would be greatly appreciated.

The code below works well as long as the string is on the first page!

$sMyString = String($ReadCell)
  $oLinks = _IELinkGetCollection($OpenIE)
  For $oLink in $oLinks
   $sLinkText = _IEPropertyGet($oLink, "innertext")
   If StringInStr($sLinkText, $sMyString) Then
    _IEAction($oLink, "click")
    ExitLoop
   Else
    ContinueLoop
   EndIf
  Next

I click the image to go to the next page with this:

_IEImgClick($OpenIE, "next", "alt")
Posted (edited)

Well if the code is working up until the point you navigate to the next page then the problem is likely connected to that. It could just be that you need to reorganize your code. Perhaps put the page navigation inside the loop, or call a function to run the loop each time you load a new page. It's hard to figure it out from what you have posted.

Edited by czardas
Posted

Thanks czardas for the heads up.. I solved it with this.

Do
  $oLinks = _IELinkGetCollection($OpenIE)
  For $oLink in $oLinks
   $sLinkText = _IEPropertyGet($oLink, "innertext")
   If StringInStr($sLinkText, $sMyString) Then
    _IEAction($oLink, "click")
    ExitLoop 2
   Else
    ContinueLoop
   EndIf
  Next
  _IEImgClick($OpenIE, "next", "alt")
  Until WinExists("Supplier Setup Confirmation - Windows Internet Explorer") = 1

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
×
×
  • Create New...