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.
Need Help: Problem in comparing values of two variables.
Hello All,
I am facing a issue in comparing values of two variables. One value is taken from an external file using _dataDrive. the other value is taken from a text field to which value is inserted using dataDrive.
The filed is designed to take values with only 15 numbers. and i am inserting different values using datadrive and then comparing the value in filed with the one that was inserted using datadrive.
i use a if condition to check between vlaues. value from _datadrive is shown correctly when i print it in log or use a alert statement.
The problem is with the value that i take back from text field and then store into a variable for comparison. it seems instead of the value, the insert statement is getting stored in variable.
below is my script.
Someone please look into it. it will be great help if anyone of you can find a solution for this.
_navigateTo("http://xx.xxx.xxx.xxx"
;
_setValue(_textbox("username"), "xxxxxxx");
_setValue(_password("password"), "xxxxxxx");
_click(_button("OK"));
_mouseOver(_image("Menu"));
_click(_div("Exports Neu"));
_wait(5000);
function doAdd($fieldval){
_setValue(_textbox("gschftsvrgng_rechnungs"), $fieldval); // sets the value in fieldval to named text field
$compare = _sahi.trim(_textbox("gschftsvrgng_rechnungs").value); // sets the value from gschftsvrgng_rechnungs to var compare
_log("printing compare after setting");
_log($compare);
_log("printing fieldval");
_log($fieldval);
_assertEqual($fieldval, _textbox("gschftsvrgng_rechnungs").value);
if ($fieldval == $compare)
{
$messagelog[$count++]= , [$fieldval] ];
writeText();
}
else
{
$messagelog[$count++]= , [$fieldval] ];
writeText();
}
_click(_image("next"));
_click(_button("Ok[1]"));
_click(_image("previous"));
}
var $data = _readCSVFile("path to file /Book1.csv");
_dataDrive(doAdd, $data);
function writeText() {
_writeToFile($messagelog , "file path /SahiReport22222.txt", false);
$messagelog[$count++]=[];
$count=0;
}
Sahi Log shows the following, i believe 4th line shows the mistake.
printing compare after setting at Jan 17, 2013 6:26:20 PM
_log("printing compare after setting"); at Jan 17, 2013 6:26:20 PM
500.060.000,00 at Jan 17, 2013 6:26:20 PM
_log(_sahi.trim(_textbox("gschftsvrgng_rechnungs").value)); at Jan 17, 2013 6:26:20 PM // here the value should be 500.060.000,00 .
printing first at Jan 17, 2013 6:26:21 PM
_log("printing first"); at Jan 17, 2013 6:26:21 PM
500.060.000,00045 at Jan 17, 2013 6:26:21 PM
_log("500.060.000,00045"); at Jan 17, 2013 6:26:21 PM
OS is Windows8.
Browser Firefox 17.0.1
Sahi (Build: 2011-07-19)
Regards,
Sreekanth
I am facing a issue in comparing values of two variables. One value is taken from an external file using _dataDrive. the other value is taken from a text field to which value is inserted using dataDrive.
The filed is designed to take values with only 15 numbers. and i am inserting different values using datadrive and then comparing the value in filed with the one that was inserted using datadrive.
i use a if condition to check between vlaues. value from _datadrive is shown correctly when i print it in log or use a alert statement.
The problem is with the value that i take back from text field and then store into a variable for comparison. it seems instead of the value, the insert statement is getting stored in variable.
below is my script.
Someone please look into it. it will be great help if anyone of you can find a solution for this.
_navigateTo("http://xx.xxx.xxx.xxx"
_setValue(_textbox("username"), "xxxxxxx");
_setValue(_password("password"), "xxxxxxx");
_click(_button("OK"));
_mouseOver(_image("Menu"));
_click(_div("Exports Neu"));
_wait(5000);
function doAdd($fieldval){
_setValue(_textbox("gschftsvrgng_rechnungs"), $fieldval); // sets the value in fieldval to named text field
$compare = _sahi.trim(_textbox("gschftsvrgng_rechnungs").value); // sets the value from gschftsvrgng_rechnungs to var compare
_log("printing compare after setting");
_log($compare);
_log("printing fieldval");
_log($fieldval);
_assertEqual($fieldval, _textbox("gschftsvrgng_rechnungs").value);
if ($fieldval == $compare)
{
$messagelog[$count++]= , [$fieldval] ];
writeText();
}
else
{
$messagelog[$count++]= , [$fieldval] ];
writeText();
}
_click(_image("next"));
_click(_button("Ok[1]"));
_click(_image("previous"));
}
var $data = _readCSVFile("path to file /Book1.csv");
_dataDrive(doAdd, $data);
function writeText() {
_writeToFile($messagelog , "file path /SahiReport22222.txt", false);
$messagelog[$count++]=[];
$count=0;
}
Sahi Log shows the following, i believe 4th line shows the mistake.
printing compare after setting at Jan 17, 2013 6:26:20 PM
_log("printing compare after setting"); at Jan 17, 2013 6:26:20 PM
500.060.000,00 at Jan 17, 2013 6:26:20 PM
_log(_sahi.trim(_textbox("gschftsvrgng_rechnungs").value)); at Jan 17, 2013 6:26:20 PM // here the value should be 500.060.000,00 .
printing first at Jan 17, 2013 6:26:21 PM
_log("printing first"); at Jan 17, 2013 6:26:21 PM
500.060.000,00045 at Jan 17, 2013 6:26:21 PM
_log("500.060.000,00045"); at Jan 17, 2013 6:26:21 PM
OS is Windows8.
Browser Firefox 17.0.1
Sahi (Build: 2011-07-19)
Regards,
Sreekanth
This discussion has been closed.
Answers
Found out the problem,
Should have used _getValue when taking back the value.