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.

checkbox ticked or not?

tinchie8tinchie8 Members
edited November -1 in Sahi - Open Source
Hello,

I have a question for checkboxes? How do I know if a checkbox is already ticked or checked? do we have any function for this?? I only saw a _checkbox function but not sure how to check if ticked or not?

Thanks! Hope someone could help me.

Comments

  • narayannarayan Administrators
    _click(_checkbox("id")) will check/unckeck the checkbox.

    _assert(_checkbox("id").checked) will assert if _checkbox is checked.
  • Hi,

    I am using the latest build V3.5 and trying to uncheck a checkbox using the _uncheckbox api, but it doesnot seem to work.

    On running the script I get the Error as -
    ERROR
    ReferenceError: "_uncheckbox" is not defined. at Nov 17, 2011 10:52:25 A

    Here's my uncheckbox usage

    _uncheckbox("ctl00\$cpRoot\$chklCompanyTypes\$0");


    Please help me figure out the issue.


    Thanks in advance and apologies if its a stupid issue.

    Jasmine.
  • Hi Jasmine,

    There is no API called _uncheckbox();

    You can use: _uncheck(checkBoxElement); //Unchecks the given checkbox. If already unchecked, this API does not do anything.

    Also, _check(_checbox("checkboxId")); // will check it

    _click(_checkbox("checkboxId")); // will toggle checked state

    If you have to uncheck the checkbox then we you can make use of:

    _uncheck(checkBoxElement);

    Let me know if you face any problem.

    Regards
    Sumitra
  • Hi Sumitra,

    I figured that out after I posted the issue but thanks for the help.

    Regards,
    Jasmine
  • Hi Sumitra,

    I am trying to generate a separate report indicating the script and it status. Based on some of the posts I am using this code

    function onScriptEnd()
    {
    _writeToFile(_scriptName() + ": " + _scriptStatus() + "\n", "C:\\Documents and Settings\\iqureshi\\sahi\\userdata\\scripts\\allresults.txt", false);
    }

    onScriptEnd();


    but the newline doesnot seem to work.

    I even tried /r option but still eveything gets written in the same line.


    Please help

    Regards,
    Jasmine
  • Hi Jasmine,

    Try the following Scirpt,
    
    function onScriptEnd()
    {
    var $message=_scriptName()  + ": " + _scriptStatus() + "\r\n";
    _writeToFile($message,  "C:\\Documents and Settings\\iqureshi\\sahi\\userdata\\scripts\\allresults.txt", false);
    }
    

    let us know if the problem persists.

    Regards
    Theeran.
  • Thanks Theeran.

    It works.


    Regards,
    Jasmine
This discussion has been closed.