goku200 Posted August 28, 2021 Share Posted August 28, 2021 (edited) I have a script that I have created that loops through an html table with pagination. The html table has 10 links that start with link1, link2, link3, etc.. The script clicks on each of these links. After link11 is clicked, the script then proceeds to click on the "Next" button in the pagination and the process repeats again for each link on the 2nd page, 3rd page, 4th page, etc....However, when it reaches page 12 it loops fine until it completes the last link in the page. Any help is greatly appreciated. I receive the following error: Array variable has incorrect number of subscripts or subscript dimension range exceeded. Edited February 19, 2022 by goku200 Link to comment Share on other sites More sharing options...
pseakins Posted August 28, 2021 Share Posted August 28, 2021 Are you aware that you have a nested for-next loop with both loops controlled by the same variable $i. ? This can only lead to disaster. I can't make out where your subscript error comes from, you have not reported which line is generating the error. Phil Seakins Link to comment Share on other sites More sharing options...
JockoDundee Posted August 28, 2021 Share Posted August 28, 2021 6 minutes ago, pseakins said: This can only lead to disaster. Saw something similar once Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
goku200 Posted August 28, 2021 Author Share Posted August 28, 2021 I went ahead and corrected the code to only include the one loop. $test = _WD_ElementAction($sSession, $aArray2[$i], 'click') The error occurs on this line: $test = _WD_ElementAction($sSession, $aArray2[$i], 'click') Link to comment Share on other sites More sharing options...
JockoDundee Posted August 28, 2021 Share Posted August 28, 2021 1 hour ago, goku200 said: $test = _WD_ElementAction($sSession, $aArray2[$i], 'click') Your acting as if $aArray2 will have at least as many rows as $aArray1. Because $i is iterating based on $aArray1 size, but being used to reference $aArray2. Code hard, but don’t hard code... Link to comment Share on other sites More sharing options...
goku200 Posted August 28, 2021 Author Share Posted August 28, 2021 (edited) I changed it to: $test = _WD_ElementAction($sSession, $aArray1[$i],'click') Edited August 28, 2021 by goku200 Link to comment Share on other sites More sharing options...
goku200 Posted August 28, 2021 Author Share Posted August 28, 2021 When I changed it to $aArray1[$i], the script clicks on the link but when it goes back it does not click on the next link… $test = _WD_ElementAction($sSession, $aArray1[$i],'click') Link to comment Share on other sites More sharing options...
Danp2 Posted August 28, 2021 Share Posted August 28, 2021 Quote _WD_ExecuteScript($sSession, 'return history.back()') Did you try using _WD_Action here? Quote $aArray1[$i] = _WD_ElementAction($sSession, $aArray1[$i], 'text') Local $aArray2 = _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, ".//td[2]/a", $aArray1, True) I'm not sure how this is supposed to work. If $aArray1[$i] already holds an element ID, why are you replacing it with the element's text and then attempting to use it as a starting element? I suggest that you repost your revised script so that we can better assist you. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
goku200 Posted August 28, 2021 Author Share Posted August 28, 2021 (edited) Thank you @Danp2 Here is the code again with the corrections that I've made. Edited February 19, 2022 by goku200 Link to comment Share on other sites More sharing options...
Solution Danp2 Posted August 28, 2021 Solution Share Posted August 28, 2021 Here's my feedback -- You've got a While loop in NextPage that shouldn't be there The While loop should be in your main script Inside this While loop, you should -- Load $aArray1 with the desired links Call the LoopPagination function to process the links Call the NextPage function to switch to the next page Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
goku200 Posted August 28, 2021 Author Share Posted August 28, 2021 (edited) Thanks @Danp2. I got it to work. Had to work through the logic 🙂. Appreciate the assistance Edited August 28, 2021 by goku200 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