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.
Data Extraction
I know Sahi's main focus is Automation and Testing, however, I have come across a need to extract table data.
I figured out how to get the number of rows:
<browser>
function getRows(){
var Rows = _table($tableNo).rows.length;
return Rows;
}
</browser>
_set($rows, getRows());
I have devised a way to get each cell's text (I'm sure it could be improved):
function getTable($tableNo){
for (var $i=0; $i<$rows; $i++){ //for each row
for (var $p=0; $p<$cols; $p++){ //for each cell
_set($cellText, _getText(_cell(_table($tableNo), $i, $p)));
_set($row[$i], $row[$i] + $cellText + ',');
}
}
}
In my table on column is for color swab images (orange, red, blue, etc) the title of the image is the color. Each row's color swab may be different and the _image[#] isn't always accurate. Is there a way to find the image in a row?
How do I go about improving my getTable function and how
I figured out how to get the number of rows:
<browser>
function getRows(){
var Rows = _table($tableNo).rows.length;
return Rows;
}
</browser>
_set($rows, getRows());
I have devised a way to get each cell's text (I'm sure it could be improved):
function getTable($tableNo){
for (var $i=0; $i<$rows; $i++){ //for each row
for (var $p=0; $p<$cols; $p++){ //for each cell
_set($cellText, _getText(_cell(_table($tableNo), $i, $p)));
_set($row[$i], $row[$i] + $cellText + ',');
}
}
}
In my table on column is for color swab images (orange, red, blue, etc) the title of the image is the color. Each row's color swab may be different and the _image[#] isn't always accurate. Is there a way to find the image in a row?
How do I go about improving my getTable function and how
Comments
Have a look at this forum post to see new features for accessing tables http://sahi.co.in/forums/viewtopic.php?id=816.
You could do this to get all data in a table: First, collect the cell text into a 2D array on the browser, pass it back to the proxy and assign to $tableData using _set. And then work on $tableData.