Solved

Sahi scripting for testing web pages

Posted on 2010-08-24
1
1,112 Views
Last Modified: 2012-05-10
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($Array1, $retVal); GET ERROR MSG FROM THIS LINE
if($check == false)
      Packages.java.lang.System.out.println("Projects' names don't come in the right order.");
else
      Packages.java.lang.System.out.println("Projects' 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
0
Comment
Question by:ana-redondo-lopez
1 Comment
 
LVL 3

Accepted Solution

by:
gremwell earned 500 total points
ID: 33509391
$retVal is defined only within the scope of getLinks() function. Also, it appears you not do invoke this function anywhere in your code. You may want to replace the indicated line with something like:

var $Array2 = getLinks();
var $check = java.util.Arrays.equals($Array1, $Array2);
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now