18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Values of an array seem to be getting overwritten.
Greetings!
I am having some issue with my code where array elements seem to be getting overwritten. I am trying to pull the rows of text from a table on a page and compare it with the text from a table on another page to ensure they're equal. Here is a sample row of data from each table. Note the difference in the word "Occupants" vs. "Occupant."
2nd row of table on page 1
====================
edit up down Occupants No No Yes
2nd row of table on page 2
====================
edit up down Occupant No No Yes
Here's the code I have within a function:
goToPage($page1);
var $oldRowData = _collect("_row", "/.*/", _in(_table("report"))); // creates an array consisting of each row in the table on page 1
_log(_getText($oldRowData[1])); // value logged is "edit up down Occupants No No Yes"
goToPage($page2);
var $newRowData = _collect("_row", "/.*/", _in(_table("report"))); // creates an array consisting of each row in the table on page 2
// notice below how $oldRowData[1] suddenly has the same value as $newRowData[1]
_log(_getText($oldRowData[1])); // value logged is "edit up down Occupant No No Yes"
_log(_getText($newRowData[1])); // value logged is "edit up down Occupant No No Yes"
// The assertions below end up TRUE because $oldRowData was overwritten somehow with the values of $newRowData.
// The assertions should really be FALSE based on the actual data in the UI.
_assertEqual($oldRowData, $newRowData); // compare arrays to check row data.
_assertEqual($oldRowData[1], $newRowData[1]); // compare individual elements to check row data.
Here is my browser, OS, Sahi environment info:
Browser
UserAgent :
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
Name :
Google Chrome
Version :
5.0 (Windows NT 6.1; WOW64)
Native XmlHTTPRequest :
true
Is Java enabled :
true
Is cookie enabled :
true
Operating System
Name :
Windows 7
Version :
6.1
Architecture :
x86
Is process list available :
true
Is CertUtil available :
true
Java
Java Installed Directory :
C:\Program Files (x86)\Java\jre7
JRE Version :
1.7.0_51
Is keytool available :
true
Thank you for your help.
I am having some issue with my code where array elements seem to be getting overwritten. I am trying to pull the rows of text from a table on a page and compare it with the text from a table on another page to ensure they're equal. Here is a sample row of data from each table. Note the difference in the word "Occupants" vs. "Occupant."
2nd row of table on page 1
====================
edit up down Occupants No No Yes
2nd row of table on page 2
====================
edit up down Occupant No No Yes
Here's the code I have within a function:
goToPage($page1);
var $oldRowData = _collect("_row", "/.*/", _in(_table("report"))); // creates an array consisting of each row in the table on page 1
_log(_getText($oldRowData[1])); // value logged is "edit up down Occupants No No Yes"
goToPage($page2);
var $newRowData = _collect("_row", "/.*/", _in(_table("report"))); // creates an array consisting of each row in the table on page 2
// notice below how $oldRowData[1] suddenly has the same value as $newRowData[1]
_log(_getText($oldRowData[1])); // value logged is "edit up down Occupant No No Yes"
_log(_getText($newRowData[1])); // value logged is "edit up down Occupant No No Yes"
// The assertions below end up TRUE because $oldRowData was overwritten somehow with the values of $newRowData.
// The assertions should really be FALSE based on the actual data in the UI.
_assertEqual($oldRowData, $newRowData); // compare arrays to check row data.
_assertEqual($oldRowData[1], $newRowData[1]); // compare individual elements to check row data.
Here is my browser, OS, Sahi environment info:
Browser
UserAgent :
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.125 Safari/537.36
Name :
Google Chrome
Version :
5.0 (Windows NT 6.1; WOW64)
Native XmlHTTPRequest :
true
Is Java enabled :
true
Is cookie enabled :
true
Operating System
Name :
Windows 7
Version :
6.1
Architecture :
x86
Is process list available :
true
Is CertUtil available :
true
Java
Java Installed Directory :
C:\Program Files (x86)\Java\jre7
JRE Version :
1.7.0_51
Is keytool available :
true
Thank you for your help.
Answers