Jump to content

Array variable has incorrect number of subscripts or subscript dimension range exceeded


Go to solution Solved by Danp2,

Recommended Posts

Posted (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 by goku200
Posted

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

Posted

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')

 

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

Posted

 

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')

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...