Forum Discussion

KevinZesi's avatar
KevinZesi
Occasional Contributor
4 years ago
Solved

Array.splice() does not work

Hi everyone,

I got a new problem with TestComplete and JavaScript.

I want to remove an element in an array at index X and tried to use the splice method as it does exactly what I want to do.

My code looks something like this:

function someFunction()
{
    var myArray = page.EvaluateXPath(...);
    for (var i = 0; i < myArray.length; i++)
    {
        // do something...
        myArray.splice(i, 1); // remove element at index i if it matches criteria
        break;
    }
}

now during debugging/testing if everything works fine, TestComplete tells me that "myArray.splice is not a function" and stops the test.

 

Well... why does it not work? Obviously it is a function.

the splice function is mentioned here too (I know it's from 2016).

 

Can anyone help me with this? Or are there other methods since 2016?

 

 

Cheers,

Kevin

  • I found the solution / my error and post it here, just in case someone is interested.

     

    As it is stated here, you need to convert TestComplete arrays into native arrays.

1 Reply

  • KevinZesi's avatar
    KevinZesi
    Occasional Contributor

    I found the solution / my error and post it here, just in case someone is interested.

     

    As it is stated here, you need to convert TestComplete arrays into native arrays.