ana-redondo-lopez
asked on
Sahi scripting for testing web pages
Hi there,
I'm writing a short script in Sahi (very similar to javaScript) to check that a series of links from a web page appear in the right order.
I have created an array storing the links' names in the order they appear. I'd like to create a second array with Sahi that searches the page gathering links names into another array.
Then I compare these two arrays. Code as follows:
var $Array1 = new Array("3 Face Blend on Mixed Walls", "Assimilation Blend Support", "Detect Loss of Blend Overflow");
function getLinks(){
var $retVal = new Array();
var $links = document.links;
for (var $i=0; $i<$links.length; $i++){
$retVal[$i] = $links[$i].innerHTML; //getText or some other function?
} //links.getElementById("") .innerHTML ;
return $retVal;
}
//importPackage(java.util. Arrays)
var $check = java.util.Arrays.equals($A rray1, $retVal); GET ERROR MSG FROM THIS LINE
if($check == false)
Packages.java.lang.System. out.printl n("Project s' names don't come in the right order.");
else
Packages.java.lang.System. out.printl n("Project s' names come in the right order.");
Whenever I try to run it I get the message "ReferenceError: "$retVal" is not defined" from the line indicated above. It seems that the for loop is not populating the $retVal array. Any ideas?
Thank you,
Ana
I'm writing a short script in Sahi (very similar to javaScript) to check that a series of links from a web page appear in the right order.
I have created an array storing the links' names in the order they appear. I'd like to create a second array with Sahi that searches the page gathering links names into another array.
Then I compare these two arrays. Code as follows:
var $Array1 = new Array("3 Face Blend on Mixed Walls", "Assimilation Blend Support", "Detect Loss of Blend Overflow");
function getLinks(){
var $retVal = new Array();
var $links = document.links;
for (var $i=0; $i<$links.length; $i++){
$retVal[$i] = $links[$i].innerHTML; //getText or some other function?
} //links.getElementById("")
return $retVal;
}
//importPackage(java.util.
var $check = java.util.Arrays.equals($A
if($check == false)
Packages.java.lang.System.
else
Packages.java.lang.System.
Whenever I try to run it I get the message "ReferenceError: "$retVal" is not defined" from the line indicated above. It seems that the for loop is not populating the $retVal array. Any ideas?
Thank you,
Ana
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.