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.

Handling checkboxes

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

I have a window with the following properties and checkboxes

Mandatory []
Read Only []
Hidden []

I need to check the ReadOnly checkbox.

Sahi reads these checkboxes as checkbox("gwt-uid-XX") (XX is a random number, incremented each time the window is opened like 53, 60, 67 etc) . So it does not work in the run-time.

I've tried --- browser.checkbox().near(browser.div("Read Only[1]")).check();
or --- browser.check(browser.checkbox().near(browser.div("Read Only[1]")));
and it did not work.

Kindly let me know if there is any way to do this.

thanks in advance
-Diwakar

Comments

  • narayannarayan Administrators
    Could it be that the checkbox is inside the div? Try

    browser.checkbox().in(browser.div("Read Only[1]")).check();

    ?
  • No luck.

    Is it possible to use the keyboard shortcuts? If so, I could set focus on the previous item and use Tab to navigate to these checkboxes?

    thanks
    -Diwakar
  • narayannarayan Administrators
    If you highlight
    browser.div("Read Only[1]")
    does it highlight the expected element?
  • Yes it does.

    When I highlight 'Read Only', it highlights the text 'Read Only'
    when I highlight the checkbox near 'Read Only' , it highlights the checkbox.
  • narayannarayan Administrators
    Then it should be

    browser.checkbox().near(browser.div("Read Only")).check();

    Any reason you added [1] to it?
  • I didn't add [1] by myself, Sahi recorded it as Read Only [1]

    And no luck again, I have tried all possible ways of near(browser.div("Read Only")), I have tried with browser.row(), then I have tried browser.checkbox().in(browser.div(""))
  • narayannarayan Administrators
    It should be

    browser.check(browser.checkbox(0).near(browser.div("Read Only")));

    I did not notice that there was no identifier for checkbox.

    Regards,
    Narayan
  • Narayan,

    thanks a lot. it works!!!! :)

    regards
    -Diwakar
This discussion has been closed.