mdcastle Posted May 1, 2012 Share Posted May 1, 2012 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") Link to comment Share on other sites More sharing options...
czardas Posted May 1, 2012 Share Posted May 1, 2012 (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 May 1, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
mdcastle Posted May 1, 2012 Author Share Posted May 1, 2012 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 Link to comment Share on other sites More sharing options...
czardas Posted May 1, 2012 Share Posted May 1, 2012 I haven't tested your code, but it looks like you got it nailed. operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now