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.
How to write the test case results into Excel/CSV File??
Hi, I am trying to write the results as "Passed" or "Failed' into excel file after i am done executing the function. For example.
Sc_No Sc_Name Result
1 Login Passed/Failed
2 User Info Passed/Failed
Since I am getting the data from the db, I am not using excel file to input data in sahi. All i want is to report results in excel file as "Passed" or "Failed" like above. Is there anyway i can do that?
Here's my code that i came up with.
//declared the variable to get the db from the excel sheet
var dba =_getDB("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=C:\\sahi_pro\\userdata\\Scripts\\Report.xls;readOnly=false", "", "");
//calling the login function
function Login($username, $password){
if (_exists(_textbox("username")))
{
_setValue(_textbox("username"), $username);
_setValue(_password("password"), $password);
_click(_submit("Login"));
//updating the excel sheet as Passed
dba.update("update [Sheet1$] set Result='Passed' where Sc_Name=Login");
}
}
After running that function, it executes the function but doesn't write it in the excel file?
Is there anything that i am missing?
Any help would be appreciated.
Thanks
Ashok
Sc_No Sc_Name Result
1 Login Passed/Failed
2 User Info Passed/Failed
Since I am getting the data from the db, I am not using excel file to input data in sahi. All i want is to report results in excel file as "Passed" or "Failed" like above. Is there anyway i can do that?
Here's my code that i came up with.
//declared the variable to get the db from the excel sheet
var dba =_getDB("sun.jdbc.odbc.JdbcOdbcDriver", "jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=C:\\sahi_pro\\userdata\\Scripts\\Report.xls;readOnly=false", "", "");
//calling the login function
function Login($username, $password){
if (_exists(_textbox("username")))
{
_setValue(_textbox("username"), $username);
_setValue(_password("password"), $password);
_click(_submit("Login"));
//updating the excel sheet as Passed
dba.update("update [Sheet1$] set Result='Passed' where Sc_Name=Login");
}
}
After running that function, it executes the function but doesn't write it in the excel file?
Is there anything that i am missing?
Any help would be appreciated.
Thanks
Ashok
Comments
In the update statement, you need to quote Login.
dkulkarni
It worked with that one. I forgot to put the ' ' in that one.
Anyway another question related to the same problem. I have the following table in excel sheet
S_No Sc_Name Result Date Time
1 Login Passed/Failed 06/20/2011 10:30
2 Login Passed/Failed 06/20/2011 10:30
Now instead of updating the same column, i want to get the date and time and log the result into next column.
So when i tried declaring the variables and putting $date, it doesn't work.
dba.update("update [Sheet1$] set date=$date where Sc_Name='Login'");
Can you please help with this??
Thanks
Ashok
That will not work because $date will be considered as a string.
Try this:
This, however will update every row with Sc_Name = Login. You might want to use a unique identifier if you are trying to update a row at a time.
Regards,
dkulkarni
S_No Sc_Name Result Date Time
1 Login Passed/Failed 06/20/2011 10:30
2 Login Passed/Failed 06/20/2011 10:31
.
.
My code is:
dba.update("update [Sheet1$] set Date ='" + $date + "' where Sc_Name=Login");
dba.update("update [Sheet1$] set Time ='" + $time + "' where Run_Date='" + $date + "'");
dba.update("update [Sheet1$] set Result ='passed' where Date='" + $date + "'");
However, since i need to write sc_name for every new column, i would need a unique value such as 1,2,3......
So is there anyway we can define unique variable and use that to write new data in the excel sheet?
May be insert values can help? Can you please suggest the right solution?
Thanks you very much again.
Ashok
Yes, it will work with Microsoft Excel 2010.
Are you facing any issue working with Excel sheet?
Regards
Sumitra
TestCase Key Word Argument1 Argument2 Argument3
loadSahi "login.sah"
Test Case 1 login "benjadmin" "password" Passed/Failed
>>> how can i write the result passed or failed into my excel file??