18 January 2026:


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 get the dynamic value from one function during the test run?

mohanmohan Members
edited July 2011 in Sahi - Open Source
Hi Narayan,

my scenario is ,i am creating one name and name id using one function .The scripts is ready with me , in the same scenario i have to delete the name using the created name id . how to get the name id and pass the value into some other screen during the test run. will get text work for me?

Comments

  • narayannarayan Administrators
    Use simple variables!

    var $username = getNameId();
    createUser($username);
    deleteUser($username);
  • mohanmohan Members
    edited July 2011
    hi narayan,

    thanks for your quick reply.The name ids are system generated.i cant assign a name id . i want to get the name id from text box after creating the name. will _gettext work for me.? each time i am going to run the same script for creating and deleting the name.any work around for this scenario?
  • narayannarayan Administrators
    Hi Mohan,

    For textbox you need

    var $id = _getValue(_textbox("myid"));

    I would suggest you go through Sahi's APIs and documentation. You should be able to get your answers there.

    Regards,
    Narayan
  • mohanmohan Members
    edited July 2011
    hi narayan,

    _getValue(_textbox("txtNameID"));

    it returns me null value . i am getting a value in one page of the application , and passing it in to another page ? sorry to disturb you again.. any one please help me on this .. we are creating a name in one page and we have a separte delete page for delete name ..all our screens are like the same..

    here is my code

    createName();
    var $id = _popup(/App.*/)._getValue(_textbox("param_602_Dyn"));
    var $i = _popup(/App.*/)._getValue(_textbox("txtNameID"));

    function createName(){

    _popup(/App.*/)._click(_span("Admin[1]"));
    _popup(/App.*/)._click(_span("Sys Parameter"));
    _popup(/App.*/)._setSelected(_select("lstModule"), "Names");
    _popup(/App.*/)._click(_textbox("param_602_Dyn"));
    _popup(/App.*/)._getValue(_textbox("param_602_Dyn"));
    _popup(/App.*/)._click(_span("Names"));
    _popup(/App.*/)._click(_span("Names Edit/Entry"));
    _popup(/App.*/)._setValue(_textbox("txtNID"), "A");
    _popup(/App.*/)._setValue(_textbox("txtNameID"), $id);
    _popup(/App.*/)._setValue(_textbox("custNames\$LastName"), "katie");
    _popup(/App.*/)._setValue(_textbox("custNames\$FirstName"), "holmes");
    _popup(/App.*/)._setValue(_textbox("adrMainAddress\$txtFrom"), "3 bank st");
    _popup(/App.*/)._highlight(_checkbox("adrMainAddress\$chkVerify"));
    _popup(/App.*/)._setValue(_checkbox("adrMainAddress\$chkVerify"), "true");
    _wait(3000);
    _wait(3000);
    _wait(3000);
    _popup(/App.*/)._click(_imageSubmitButton("Save"));
    _wait(3000);
    _click(_button("Yes"));
    _wait(3000);
    _click(_button("Ok"));
    _wait(3000);
    _wait(3000);
    _popup(/App.*/)._getValue(_textbox("txtNameID"));
    _popup(/App.*/)._click(_span("Expungement"));
    _click(_button("Yes"));
    _popup(/App.*/)._setValue(_textbox("txtID"), "A");
    _popup(/App.*/)._setValue(_textbox("txtNameType"), $i);
    _popup(/App.*/)._setValue(_textarea("txtReason"), "testing");
    _click(_button("Yes"));
    _popup(/App.*/)._click(_submit("Delete Name"));
    _click(_button("Ok"));


    }
  • mohanmohan Members
    <browser>
    function getValue($objDom)
    {
    var $someval = $objDom.value;
    return $someval;
    }
    </browser>

    var $currentPOnumber;
    _set($currentPOnumber, getValue(_textbox("main_grid2_1_textbox")));

    // Use $currentPOnumber else where in your script.


    I searched in Forum one of your answer worked for me.. Thanks a lot ... we love sahi...
This discussion has been closed.