Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, windows and java based applications. Get your 30 day free trial.
Discuss your Sahi Pro usage patterns, best practices, problems and solutions. Help others solve their problems and seek help from the community when needed. If you need specific support on your application, please email support @ sahipro.com
Discuss your Sahi Pro usage patterns, best practices, problems and solutions. Help others solve their problems and seek help from the community when needed. If you need specific support on your application, please email support @ sahipro.com
Working with suite (for executing multiple scripts sequentially)
Gayathri
Members
I had created a suite with 2 scripts. Script1 is to test for login and Script2 is to test for adding a new item to a grid (using 'Add' link). Both the scripts work fine, individually from the Sahi controller. However, when I executed the suite (using command prompt), it executes only the Script1 successfully and does not enter Script2.
Script2 goes as below:
function script2 ($taskName)
{
_click(_link("+ Add new task"));
_setValue(_textbox("ctl00\$ContentPlaceHolder1\$txtTaskName"), $taskName);
}
Error I am receiving on the playback log is :
***************
Starting script
_click(_link("+ Add new task"));
Error: The parameter passed to _click was not found on the browser
at addTask (scripts/addTask.sah:3) at Jan 4, 2013 1:23:44 PM
Stopping script
***************
Question: What is the parameter it is expecting here -- while executing the suite ?? (while I am able to execute the same script individually)
Script2 goes as below:
function script2 ($taskName)
{
_click(_link("+ Add new task"));
_setValue(_textbox("ctl00\$ContentPlaceHolder1\$txtTaskName"), $taskName);
}
Error I am receiving on the playback log is :
***************
Starting script
_click(_link("+ Add new task"));
Error: The parameter passed to _click was not found on the browser
at addTask (scripts/addTask.sah:3) at Jan 4, 2013 1:23:44 PM
Stopping script
***************
Question: What is the parameter it is expecting here -- while executing the suite ?? (while I am able to execute the same script individually)
Answers
It seems that your second script has a different start URL. In your suite, please provide the start URL for the individual scripts like this(give a space after script name):
script1.sah gooole.com
script2.com fbhhh.com
Thanks,
Also, I tried giving both the relative and absolute URL and tested. But does not work on either case.
I tried it as
script1.sah google.com
script2.sah google.com/test.aspx
Any I still wrong?
Please check the script name on your suite is correct ?
Question : What is the parameter it is expecting here -- while executing the suite ?? (while I am able to execute the same script individually)
Answer : sahi could not find the object in the page loaded. hence it throws the error message that the parameter "_link("+Add new task")" is not right.
Now Are you sure the right page has been loaded when the script 2 is starting ?
From your scenario i understand the script2 expects the page after login.
Also you can try this create <main>.sah file
_include("script1.sah");
_include("script2.sah");
Run the main.sah file with the login url from the command line, it should work !!! Hope it goes well if I understand rt.. !!
Example:
My script2 reads as ----
function addTask ($taskName)
{
_click(_link("+ Add new task"));
_setValue(_textbox("ctl00\$ContentPlaceHolder1\$txtTaskName"), $taskName);
}
Error received is as below:
*****************************
Starting script
_click(_link("My Tasks"));
Error: The parameter passed to _click was not found on the browser
at addTask (scripts/addTask.sah:3) at Jan 7, 2013 12:36:33 PM
Stopping script
*****************************
My script3 reads as
//show report
_setValue(_textbox("ctl00\$ContentPlaceHolder1\$txtFromDate"), "1/1/2013");
Error received is as below:
*****************************
Starting script
_setValue(_textbox("ctl00\$ContentPlaceHolder1\$txtFromDate"), "1/1/2013");
Error: The first parameter passed to _setValue was not found on the browser at Jan 7, 2013 12:43:18 PM
Stopping script
*****************************
Question: In every case, the scripts (added post the first script in the suite) are expecting a parameter to be passed.
Please help.
Script 1 :- To login to application
function timeLoginTest ($username,$password)
{
_navigateTo("http://testurl"
_setValue(_textbox("txtUser"), $username);
_setValue(_password("txtPwd"), $password);
_click(_imageSubmitButton("Login"));
}
timeLoginTest ("username","password")
Script 2 : To add a task item
function addTask ($taskName)
{
_click(_link("+ Add new task"));
_setValue(_textbox("ctl00\$ContentPlaceHolder1\$txtTaskName"), $taskName);
_click(_submit("Save"));
}
addTask ("Learn Sahi")
Script 3: To show report
_click(_link("My Tasks"));
_setValue(_textbox("ctl00\$ContentPlaceHolder1\$txtFromDate"), "1/1/2013"); //selected only the from date for the report
_click(_button("Show"));
Suite file:
timeLoginTest.sah http://testurl
addTask.sah timetracker/Dashboard.aspx
showreport.sah
Before _click(_link("+ Add new task")); ADD the below step,
_navigateTo("http://timetracker/Dashboard.aspx"
Similarly do it for Script 3 with the Correct URL.
It runs successfully while you run it individually because may in that case your Start URL might be "timetracker/Dashboard.aspx" and in this case it is different. So Sahi could not find the object _link("+ Add new task").
Good Luck !!
Can you post the log ?
Error received on Script2 is as below:
*****************************
Starting script
_navigateTo("http://myipaddress/timetracker/Dashboard.aspx" at Jan 8, 2013 5:33:49 PM
Logging exception:
_click(_link("My Tasks"));
Error: The parameter passed to _click was not found on the browser at Jan 8, 2013 5:33:59 PM
*****************************
Question: The last statement in the above error description is displayed all the time - for whatever script I append after my first script (login). It is expecting a 'PARAMETER' to be passed.
Please help.
I understood that it could be due to automatic closure of browser after execution of the first script. I changed the browser session configuration as required and could execute all the scripts sequentially.
Thanks much.
To resolve this, check the 'Add' link and textbox names in the HTML source. Ensure they're correctly named and visible during execution to execute Script2 successfully.