18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
radio and checkbox test for "checked" - is it buggy or is it me? (java version)
Hi!
I get to my radios and checkboxes by a newly given hard coded ID.
So I'm rewriting my tests and wondered, that sometimes an in fact checked radio would return false - like it's not checked.
To narrow down the buggy behaviour, I wrote just one method with one line of code which asserts that a radio is checked.
That line is: assertTrue(browser.radio("/x-auto-.*/").in(browser.div("ID_starnet_labor_treatment_type_curative")).checked());
The HTML of that radio is:
<div __gwtcellbasedwidgetimpldispatchingfocus="true" __gwtcellbasedwidgetimpldispatchingblur="true" id="ID_starnet_labor_treatment_type_curative" style="margin: 2px; position: relative;">
<div class="GA53JIRCNQ">
<input type="radio" checked="" id="x-auto-28" tabindex="0">
<label class="GA53JIRCHQ" for="x-auto-28">Kurativ</label>
</div>
</div>
Then I wrote a test in which I go to that radio and then do nothing but repeatedly calling that one assertion 50 times.
The last time I did that, the first 24 times the assertion is successful, and the 25th time it fails.
I do nothing in between, don't touch the mouse, nothing else, just repeatedly calling that step.
Sometimes it fails earlier, sometimes it fails later, sometimes it does not fail at all.
I'm using a default selected radio button for this test, "see" while it's performing the first 24 assertions that it is in fact checked , and when it is failing it is also still checked (screenshot).
I don't get this.
This happens with all radios and checkboxes I'm checking sometimes.
The line for the checkboxes is almost the same:
assertTrue(browser.checkbox("/x-auto-.*/").in(browser.div(OrderAdditionalIds.ID_ORDER_ADDITIONAL_LIMITED_CLAIM)).checked());
I'm running twist 13.1.1.13123-ef0d33de19d067, with bundled sahi : Twist Sahi 3.0.1.13123-ef0d33de19d067 com.thoughtworks.twist.sahi.feature.group ThoughtWorks Studios
I don't know if that version corresponds to the sahi versions from this site.
Thank you, Tanja
I get to my radios and checkboxes by a newly given hard coded ID.
So I'm rewriting my tests and wondered, that sometimes an in fact checked radio would return false - like it's not checked.
To narrow down the buggy behaviour, I wrote just one method with one line of code which asserts that a radio is checked.
That line is: assertTrue(browser.radio("/x-auto-.*/").in(browser.div("ID_starnet_labor_treatment_type_curative")).checked());
The HTML of that radio is:
<div __gwtcellbasedwidgetimpldispatchingfocus="true" __gwtcellbasedwidgetimpldispatchingblur="true" id="ID_starnet_labor_treatment_type_curative" style="margin: 2px; position: relative;">
<div class="GA53JIRCNQ">
<input type="radio" checked="" id="x-auto-28" tabindex="0">
<label class="GA53JIRCHQ" for="x-auto-28">Kurativ</label>
</div>
</div>
Then I wrote a test in which I go to that radio and then do nothing but repeatedly calling that one assertion 50 times.
The last time I did that, the first 24 times the assertion is successful, and the 25th time it fails.
I do nothing in between, don't touch the mouse, nothing else, just repeatedly calling that step.
Sometimes it fails earlier, sometimes it fails later, sometimes it does not fail at all.
I'm using a default selected radio button for this test, "see" while it's performing the first 24 assertions that it is in fact checked , and when it is failing it is also still checked (screenshot).
I don't get this.
This happens with all radios and checkboxes I'm checking sometimes.
The line for the checkboxes is almost the same:
assertTrue(browser.checkbox("/x-auto-.*/").in(browser.div(OrderAdditionalIds.ID_ORDER_ADDITIONAL_LIMITED_CLAIM)).checked());
I'm running twist 13.1.1.13123-ef0d33de19d067, with bundled sahi : Twist Sahi 3.0.1.13123-ef0d33de19d067 com.thoughtworks.twist.sahi.feature.group ThoughtWorks Studios
I don't know if that version corresponds to the sahi versions from this site.
Thank you, Tanja
Answers
Try using the following code to check for the checked property of the checkbox:
Regards