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.

Check Box Status

pampam Members
edited November -1 in Sahi - Open Source
Hi,

I am trying to automate a scenario where the script should only check a checkbox if it is not checked. I am not able to specify the exact id of the checkbox since it is dynamic. I am trying to reference it using DOM relation. Below is the script for that. The script executes fine if the check box is not checked but if the checkbox is checked it fails where as it should simply go to the next step. Can somebody help? Thanks.

click(_link("Edit Membership..."));
_click(_image("ExpandRepository",_near(_link("/Tabs__ctl0_MembershipSplitter_tmpl0_EditMembershipDialog_tmpl_EditMembershipTreen/"))));
if (_condition(_checkbox(0, _near(_row("Repository User"))).checked == false))
{
_check(_checkbox(0, _near(_row(“Repository User"))));
}
_click(_span("Save[1]”);
_click(_span("Save[2]”);

Comments

  • Hi. If the result you want is for the checkbox to end up checked you can replace your if statement with..

    _check(_checkbox(0, _near(_row(“Repository User"))));

    If it's not checked _check will check the box, If it is checked _check does nothing.

    _check(checkBoxOrRadioElement)
    Checks the given checkbox or radio element. If already checked, this API does not do anything.

    Hope that helps.
Sign In or Register to comment.