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.

In run time how to select respective check box

rdnashirdnashi Members
edited November -1 in Sahi - Open Source
I'm leant little bit of Sahi.
But stuck in one scenario.

Say in leave approval page of Manager M1 has below records.
Name Type From To Duration reason checkbox
XYZ india 01/01/10 10/01/10 5 test <a checkbox>
ABC US 01/02/10 10/02/10 6 test <a checkbox>

Approve (button) , Reject (button)

So M1 has to select the checkbox of XYZ and click the Approve/Reject button.
The Sahi script recorded is :

_click(_checkbox("chkbox[1]"));
_click(_submit("Approve"));

If I ran the same script with different Manager M2 , the script fails because M2 might have different requests say :
Name Type From To Duration reason checkbox
XYZ india 01/01/10 10/01/10 5 test <a checkbox>

M2 has only one row. below scripts fails
_click(_checkbox("chkbox[1]"));
_click(_submit("Approve"));

If we take only Manager M1 page while playing the script the M1 requests might have changed so the XYZ user position is changed in the list. This case as well the script will fail


So how to tweak this script to select the checkbox of user XYZ irrespective of its position in the list?

Any light on this please?


Thanks
Ram

Comments

  • Hi rdnashi,

    You can use _near() API;

    For more information about _near() API:

    http://sahi.co.in/w/all-apis

    Try this:

    _click(_checkbox(0,_near(_cell("XYZ"))));

    Check if this helps you to solve your issue.

    Regards
    Sumitra
  • Many thanks for the quick reply.

    yes I can use _near and _under to identify the check box.

    Consider below example. I want to select check box of row XYZ, Paid , 01/03/10.
    Is it possible using these _near and _under API's ? and how?

    Name Type From To Duration reason checkbox
    XYZ Sick 01/01/10 10/01/10 5 test <a checkbox>
    XYZ Paid 01/02/10 10/02/10 6 test12 <a checkbox>
    XYZ Paid 01/03/10 2/03/10 2 test12 <a checkbox>

    Thanks
    Rdnashi
  • Hi rdnashi,

    Let me know if the XYZ remains constant for all the Managers?

    If you want to select check box of row XYZ, Paid , 01/03/10.You can use:

    _click(_checkbox(0,_near(_cell("XYZ[2]"))));

    Regards
    Sumitra
  • Hi,

    I think _click(_checkbox(0,_near(_cell("XYZ[2]")))); will select 2nd row check box.
    during runtime there might be more rows in the page say :

    Name Type From To Duration reason checkbox
    ABC Paid 01/03/10 10/03/10 5 test <a checkbox>
    XYZ Sick 01/01/10 10/01/10 5 test <a checkbox>
    XYZ Petar 01/02/10 10/02/10 6 test12 <a checkbox>
    XYZ Paid 01/02/10 10/02/10 6 test12 <a checkbox>
    ABC Sick 01/01/10 10/01/10 5 test <a checkbox>
    XYZ Paid 01/03/10 2/03/10 2 test12 <a checkbox>

    I want to select a check box where Name = XYZ , Type = Paid , From = 01/02/10.
    Yes The Name XYZ remains contant for any Manager.

    Thanks
    Rdnashi
Sign In or Register to comment.