Question : Sahi, ReferenceError: "$Array2" is not defined.

Hi there,

I'm using Sahi the automated testing tool to test a web page. I've written this piece of code to check some links in the page appear in the right order.

var $Array1 = new Array("3 Face Blend on Mixed Walls", "Assimilation Blend Support", "Detect Loss of Blend Overflow");
var $links = document.links;  
for (var $i=0; $i<$links.length; $i++)
      ($Array2[$i]==$links[$i].innerHTML);                                         
_assertEquals($Array1, $Array2, "Seems that the two arrays are not the same.");

But I the "ReferenceError: "$Array2" is not defined".
I don't understand why. Can anyone see why?

Thank you,

Ana

Answer : Sahi, ReferenceError: "$Array2" is not defined.

($Array2[$i]==$links[$i].innerHTML);                            

should be

$Array2[$i]=$links[$i].innerHTML;
== is equal, = is assignment
                           
and you do not declare the Array
1:
2:
3:
4:
5:
6:
7:
var $Array2 = new Array(); 
var $Array1 = new Array("3 Face Blend on Mixed Walls", "Assimilation Blend Support", "Detect Loss of Blend Overflow");
var $links = document.links;  
for (var $i=0; $i<$links.length; $i++) {
  $Array2[$i]=$links[$i].innerHTML;
}                                         
_assertEquals($Array1, $Array2, "Seems that the two arrays are not the same.");
Random Solutions  
 
programming4us programming4us