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.
Continue execution test while finding a failure
Hi everybody,
I'm doing data driven test, reading some data from a csv file, doing a logical test and depends on my result I write an OK or KO in another csv file with the value read. The problem I face is that I'm not able to tell Sahi when there is a KO for a data read to go to the next data and not spend time for the rest of steps concerning this data value. Here is an example of what i'm trying to do to be clear:
My script.sah
_navigateTo("http://www.3suisses.fr"
;
var $num_test=1;
// 1.Look for a product by reading the reference from a csv file
function test_searchReference($reference)
{
var $r;
_setValue(_textbox("searchTerms"), $reference);
_click(_imageSubmitButton("imagesubmit"));
if (_condition(_assertExists(_span("(1 résultat)")))==true)
{
_log("Référence OK","success");
$r = "OK";
}
else
{
_log("Référence KO","Failure");
$r = "KO";
}//fin else
return $r;
}
// 2. Second verification
function test_searchRemise($remise)
{
var $r;
if (_condition(_assertEqual($remise, _getText(_span("rem_black")))) == true)
{
_log("Remise OK","success");
$r = "OK";
}
else
{
_log("Remise KO","Failure");
$r = "KO";
}
return $r;
}
// ......and other verifications in functions
//Loop data1 from csv file
var $data = _readCSVFile("C:/Documents and Settings/hmouedder/Desktop/SquashAutomation/solde.csv");
var $value = new Array();
// test 1: Référence
$value[$pointer]=new Array();
$value[$pointer][0] = "Poc_" + $num_test; // TestSuite
$value[$pointer][1]= "E1"; // TestCase
$value[$pointer][2] = "Référence: " + $row[0];
try {
$value[$pointer][3] = test_searchReference($row[0]);
}
catch (e)
{
_logExceptionAsFailure(e);
}
//Write results into a csv file
_writeCSVFile($value,"C:/Documents and Settings/hmouedder/Desktop/SquashAutomation/solderesult.csv",true);
$pointer ++;
// And I do the same thing for each function
I got a result like this in csv file:
"Poc_2","E1","Référence: 10093695","OK"
"Poc_2","E2","Remise Vg: -50%","OK"
"Poc_2","E3","Prix barré Vg: 14.99 €","OK"
"Poc_2","E4","Prix après remise Vg: 7.49","OK"
"Poc_2","E5","Image Vg: 10093695_1.jpg","OK"
"Test_2","E6","Remise FP: -50%","OK"
"Poc_2","E7","Prix barré FP: 14.99 €","OK"
"Poc_2","E8","Prix après remise FP: 7.49","OK"
"Poc_3","E1","Référence: jhkfgfgf","KO"
//Here stop and not try to call the next function"
What I want is when it finds a failure and trace a "KO" to go to the next data.
Thank you for your help
I'm doing data driven test, reading some data from a csv file, doing a logical test and depends on my result I write an OK or KO in another csv file with the value read. The problem I face is that I'm not able to tell Sahi when there is a KO for a data read to go to the next data and not spend time for the rest of steps concerning this data value. Here is an example of what i'm trying to do to be clear:
My script.sah
_navigateTo("http://www.3suisses.fr"
var $num_test=1;
// 1.Look for a product by reading the reference from a csv file
function test_searchReference($reference)
{
var $r;
_setValue(_textbox("searchTerms"), $reference);
_click(_imageSubmitButton("imagesubmit"));
if (_condition(_assertExists(_span("(1 résultat)")))==true)
{
_log("Référence OK","success");
$r = "OK";
}
else
{
_log("Référence KO","Failure");
$r = "KO";
}//fin else
return $r;
}
// 2. Second verification
function test_searchRemise($remise)
{
var $r;
if (_condition(_assertEqual($remise, _getText(_span("rem_black")))) == true)
{
_log("Remise OK","success");
$r = "OK";
}
else
{
_log("Remise KO","Failure");
$r = "KO";
}
return $r;
}
// ......and other verifications in functions
//Loop data1 from csv file
var $data = _readCSVFile("C:/Documents and Settings/hmouedder/Desktop/SquashAutomation/solde.csv");
var $value = new Array();
// test 1: Référence
$value[$pointer]=new Array();
$value[$pointer][0] = "Poc_" + $num_test; // TestSuite
$value[$pointer][1]= "E1"; // TestCase
$value[$pointer][2] = "Référence: " + $row[0];
try {
$value[$pointer][3] = test_searchReference($row[0]);
}
catch (e)
{
_logExceptionAsFailure(e);
}
//Write results into a csv file
_writeCSVFile($value,"C:/Documents and Settings/hmouedder/Desktop/SquashAutomation/solderesult.csv",true);
$pointer ++;
// And I do the same thing for each function
I got a result like this in csv file:
"Poc_2","E1","Référence: 10093695","OK"
"Poc_2","E2","Remise Vg: -50%","OK"
"Poc_2","E3","Prix barré Vg: 14.99 €","OK"
"Poc_2","E4","Prix après remise Vg: 7.49","OK"
"Poc_2","E5","Image Vg: 10093695_1.jpg","OK"
"Test_2","E6","Remise FP: -50%","OK"
"Poc_2","E7","Prix barré FP: 14.99 €","OK"
"Poc_2","E8","Prix après remise FP: 7.49","OK"
"Poc_3","E1","Référence: jhkfgfgf","KO"
//Here stop and not try to call the next function"
What I want is when it finds a failure and trace a "KO" to go to the next data.
Thank you for your help