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

Working with suite (for executing multiple scripts sequentially)

GayathriGayathri Members
edited January 2013 in Sahi - Open Source
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)

Answers

  • Hi,
    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,
  • It is not a different URL. It is the same URL as the first one.
    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?
  • Hi Gayathri,

    Please check the script name on your suite is correct ?
  • Hi,

    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.. !!
  • GayathriGayathri Members
    edited January 2013
    As mentioned, I created the main.sah file and am still getting the same error. Also, the problem is not just with the script2 I had mentioned above. I created script3 as well and executed the suite. I am receiving the same error.

    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.
  • Can you please post the code of your Scripts and suite file ?
  • GayathriGayathri Members
    edited January 2013
    Find below the scripts and the suite that I had created. 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
  • edited January 2013
    In Script 2:

    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 !!
  • I tried this as well. But does not work.
  • What error are you getting ?
    Can you post the log ?
  • I have included 'try - catch' to capture exceptions.

    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.
  • Looks like your id is dynamic, use some static property also try to use _in, _near..
  • GayathriGayathri Members
    edited January 2013
    I guess, the problem reported was no way related to the error mentioned.

    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.
  • Moon757Moon757 Members
    edited October 2023

    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.

Sign In or Register to comment.