cancel
Showing results for 
Search instead for 
Did you mean: 

Array.splice() does not work

SOLVED
Occasional Contributor

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

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
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.

View solution in original post

1 REPLY 1
Highlighted
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.

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get properties of a web page element

See replies!

Compare images using the Region Checkpoint

See replies!

Compare HTML table with Excel file and correct data in Excel file

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!
Top Kudoed Authors