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.

CTRL + Click checkbox

DonnaMooresDonnaMoores Members
edited November -1 in Sahi - Open Source
I have a control which is a table full of checkboxes and associated text.

To select multiple checkboxes I have to hold down the control key.

Is there a way to do this using Sahi.

Many thanks

Donna

Comments

  • You mean you have to press Ctrl key to check all your checkboxes ?
  • Yes, I need to hold the CTRL key down when I want to select multiple checkboxes

    Thank you.
  • Ok then,

    Sahi allows you reach your checkboxes thanks to the accessor : _checkbox("table") (if table is the name of your checkbox)
    Then you can check it by using _click() function

    So, a checkbox can be checked by :
    _click(_checkbox("table"));
    
    Regards,

    lepierrot
  • I think you are not quite understanding what I am after.

    I need to hold down the control key and select multiple checkboxes. Simply having multiple _click(_checkbox("table")); will only select one item at once for me.


    Many thanks for your help so far.
    Donna
  • Oops, obviously I didn't read very well your topic sorry...

    Maybe this will help you more :

    _keyPress( element, character, COMBO_KEY )
    _keyDown( element, character, COMBO_KEY )

    It will simulate CTRL if you replace COMBO_KEY by "CTRL"
    But I don't know how to simulate a click on it at the same time

    Regards,

    Pierre
  • Thank you.

    I had found the keypress function, but cant find how to put the click with it too..


    Thanks for your help.

    Watch this space. I will post an answer as soon as I have it!!!!!
  • Maybe you can find a solution with running 2 threads in the same time ... ?
    One with CTRL key pressed, and one with clicking on the checkbox ...
    Ok, it's a little bit a "mac gyver" solution....
  • FYI I think the example for "checkbox" in "Sahi APIs" should be:

    _click(_checkbox("ID")); NOT what it has now.

    RR
  • You might find an answer searching sahi\htdocs\spr\*.js for "Event". It looks like you would use "addEvent" for keypress "CTRL" and another "addEvent" for the mouse click. There is also "_simulateEvent" as an API but no docs. Good Luck!

    RR
  • pbpb Members
    Hi,

    Has anyone found a solution as to how to emulate the holding down of ctrl while performing _click??
  • It seems CTRL-ALT-dbl-click is similar, so model the function like below:

    Sahi.prototype.activateHotKey = function () {
    try {
    this.addEvent(document, "dblclick", Sahi.openControllerWindow);
    this.addEvent(document, "mousemove", this.mouseOver);
    if (this.isSafariLike()) {
    var prev = window.document.ondblclick;
    window.document.ondblclick = function(e) {
    if (prev != null) prev(e);
    this.openControllerWindow(e)
    };
    }
    } catch(ex) {
    this.handleException(ex);
    }
    }

    RR
  • _click(_button(“Click Me”), “CTRL”); // clicks with CTRL key pressed

    Source: h t t p : //sahi.co.in/w/_click
Sign In or Register to comment.