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.
unable to click radiobutton with "near" and the text next to the radio
Hi!
First: I got Ideas from here: "Unable to select radio buttons." here "Problem with dynamic web page" here "How to find value of radio type with the help of lable ?" and here "How to click button of an attribute value. Dont understand the syntax"
I hava a page with several radiobuttons and checkboxes build with icefaces. The part I will take as example here consists of 3 radiobuttons under eachother in a "vertical line". Next to each radiobutton is a span acting as a label for the radiobutton.
It looks like this with () being a radiobutton:
() Normal
() Cito
() Notfall
The code firebug shows me is:
<div class="box-1">
<h3 id="addh2">
<span id="mFrm:addtext2" class="iceOutTxt">priorität</span>
</h3>
<span>
<input id="mFrm:priorityChecks:_0" type="radio" value="1" onkeypress="Ice.util.radioCheckboxEnter(form,this,event);" onfocus="setFocus(this.id);" onclick=";setFocus('');iceSubmitPartial(form, this, event);" onblur="setFocus('');" name="mFrm:priorityChecks" checked="checked">
<label class="iceSelOneRb" for="mFrm:priorityChecks:_0"></label>
</span>
<span id="mFrm:ot1" class="iceOutTxt">Normal</span>
<div id="mFrm:j_id334" class="icePnlGrp"></div>
<span>
<input id="mFrm:priorityChecks:_1" type="radio" value="2" onkeypress="Ice.util.radioCheckboxEnter(form,this,event);" onfocus="setFocus(this.id);" onclick=";setFocus('');iceSubmitPartial(form, this, event);" onblur="setFocus('');" name="mFrm:priorityChecks">
<label class="iceSelOneRb" for="mFrm:priorityChecks:_1"></label>
</span>
<span id="mFrm:ot2" class="iceOutTxt">Cito</span>
<div id="mFrm:j_id335" class="icePnlGrp"></div>
<span>
<input id="mFrm:priorityChecks:_2" type="radio" value="4" onkeypress="Ice.util.radioCheckboxEnter(form,this,event);" onfocus="setFocus(this.id);" onclick=";setFocus('');iceSubmitPartial(form, this, event);" onblur="setFocus('');" name="mFrm:priorityChecks">
<label class="iceSelOneRb" for="mFrm:priorityChecks:_2"></label>
</span>
<span id="mFrm:ot3" class="iceOutTxt">Notfall</span>
</div>
There are several "boxes" like this on the page.
I got several variants running and clicking, but NONE without any 0, 1 or 2 where 0 is the upper one (Normal), 1 is the middle one (Cito) and 2 is the bottom one where an 0,1,2 can be the automatically given sahi index [number] or the blank number meaning the first, second, third element next to ... Also, I can click by ID and by value "number". I don't want to depend on the radio buttons in that particular order. => I want to be able to check the one "next to Cito", no matter if Cito is the first, second or third one.
Following this example:
browser.link("delete").near(browser.cell("user1")).click();
I expected
browser.radio( "mFrm:priorityChecks" ).near( browser.span("Cito") ).click();
to check the radio button next to Cito, the middle one. But it checks the above one next to "Normal". I read anywhere about near and a table. Does near don't work like this *without* a table?
With
browser.radio( 0 ).near( browser.span("Cito") ).check(); I can select the upper one
browser.radio( 1 ).near( browser.span("Cito") ).check(); I can select the middle one
browser.radio( 2 ).near( browser.span("Cito") ).check(); I can select the bottom one
whereas I expected this behaviour
browser.radio( 0 ).near( browser.span("Normal") ).check(); I can select the upper one
browser.radio( 0 ).near( browser.span("Cito") ).check(); I can select the middle one
browser.radio( 0 ).near( browser.span("Notfall") ).check(); I can select the bottom one
or, similar:
browser.radio( "mFrm:priorityChecks" ).near( browser.span("Normal") ).click();
browser.radio( "mFrm:priorityChecks" ).near( browser.span("Cito") ).click();
browser.radio( "mFrm:priorityChecks" ).near( browser.span("Notfall") ).click();
Some more ideas, but RegEx with / is also not clear to me ...
browser.radio( "/.*priorityChecks.*/" ).near( browser.span("Cito") ).click();// nothing
browser.radio( "/priorityChecks/" ).near( browser.span("Cito") ).click();// nothing
Is there someting I just don't see? A completely different approach? To select the radiobutton next to "Cito" no matter where it stands in that list?
This is on Windows 7 with Firefox 11 (yes, an old one, 13 is constantly crashing like someone else mentioned on the forum here) and sahi (within Twist). The sahi controller from within Twist does not show the sahi version number, but I found this: com.thoughtworks.twist.driver.sahi_3.0.0.12641-3bffc171c71291.
First: I got Ideas from here: "Unable to select radio buttons." here "Problem with dynamic web page" here "How to find value of radio type with the help of lable ?" and here "How to click button of an attribute value. Dont understand the syntax"
I hava a page with several radiobuttons and checkboxes build with icefaces. The part I will take as example here consists of 3 radiobuttons under eachother in a "vertical line". Next to each radiobutton is a span acting as a label for the radiobutton.
It looks like this with () being a radiobutton:
() Normal
() Cito
() Notfall
The code firebug shows me is:
<div class="box-1">
<h3 id="addh2">
<span id="mFrm:addtext2" class="iceOutTxt">priorität</span>
</h3>
<span>
<input id="mFrm:priorityChecks:_0" type="radio" value="1" onkeypress="Ice.util.radioCheckboxEnter(form,this,event);" onfocus="setFocus(this.id);" onclick=";setFocus('');iceSubmitPartial(form, this, event);" onblur="setFocus('');" name="mFrm:priorityChecks" checked="checked">
<label class="iceSelOneRb" for="mFrm:priorityChecks:_0"></label>
</span>
<span id="mFrm:ot1" class="iceOutTxt">Normal</span>
<div id="mFrm:j_id334" class="icePnlGrp"></div>
<span>
<input id="mFrm:priorityChecks:_1" type="radio" value="2" onkeypress="Ice.util.radioCheckboxEnter(form,this,event);" onfocus="setFocus(this.id);" onclick=";setFocus('');iceSubmitPartial(form, this, event);" onblur="setFocus('');" name="mFrm:priorityChecks">
<label class="iceSelOneRb" for="mFrm:priorityChecks:_1"></label>
</span>
<span id="mFrm:ot2" class="iceOutTxt">Cito</span>
<div id="mFrm:j_id335" class="icePnlGrp"></div>
<span>
<input id="mFrm:priorityChecks:_2" type="radio" value="4" onkeypress="Ice.util.radioCheckboxEnter(form,this,event);" onfocus="setFocus(this.id);" onclick=";setFocus('');iceSubmitPartial(form, this, event);" onblur="setFocus('');" name="mFrm:priorityChecks">
<label class="iceSelOneRb" for="mFrm:priorityChecks:_2"></label>
</span>
<span id="mFrm:ot3" class="iceOutTxt">Notfall</span>
</div>
There are several "boxes" like this on the page.
I got several variants running and clicking, but NONE without any 0, 1 or 2 where 0 is the upper one (Normal), 1 is the middle one (Cito) and 2 is the bottom one where an 0,1,2 can be the automatically given sahi index [number] or the blank number meaning the first, second, third element next to ... Also, I can click by ID and by value "number". I don't want to depend on the radio buttons in that particular order. => I want to be able to check the one "next to Cito", no matter if Cito is the first, second or third one.
Following this example:
browser.link("delete").near(browser.cell("user1")).click();
I expected
browser.radio( "mFrm:priorityChecks" ).near( browser.span("Cito") ).click();
to check the radio button next to Cito, the middle one. But it checks the above one next to "Normal". I read anywhere about near and a table. Does near don't work like this *without* a table?
With
browser.radio( 0 ).near( browser.span("Cito") ).check(); I can select the upper one
browser.radio( 1 ).near( browser.span("Cito") ).check(); I can select the middle one
browser.radio( 2 ).near( browser.span("Cito") ).check(); I can select the bottom one
whereas I expected this behaviour
browser.radio( 0 ).near( browser.span("Normal") ).check(); I can select the upper one
browser.radio( 0 ).near( browser.span("Cito") ).check(); I can select the middle one
browser.radio( 0 ).near( browser.span("Notfall") ).check(); I can select the bottom one
or, similar:
browser.radio( "mFrm:priorityChecks" ).near( browser.span("Normal") ).click();
browser.radio( "mFrm:priorityChecks" ).near( browser.span("Cito") ).click();
browser.radio( "mFrm:priorityChecks" ).near( browser.span("Notfall") ).click();
Some more ideas, but RegEx with / is also not clear to me ...
browser.radio( "/.*priorityChecks.*/" ).near( browser.span("Cito") ).click();// nothing
browser.radio( "/priorityChecks/" ).near( browser.span("Cito") ).click();// nothing
Is there someting I just don't see? A completely different approach? To select the radiobutton next to "Cito" no matter where it stands in that list?
This is on Windows 7 with Firefox 11 (yes, an old one, 13 is constantly crashing like someone else mentioned on the forum here) and sahi (within Twist). The sahi controller from within Twist does not show the sahi version number, but I found this: com.thoughtworks.twist.driver.sahi_3.0.0.12641-3bffc171c71291.
Comments
Please have a look at the browser APIs available with Sahi and try to use _check(checkBoxOrRadioElement) instead of click.
This might work.
Thanks,
Vivek
thank you for that promising idea, but unfortunately it seems to behave similar to my previous attempts:
1) browser.check( browser.span("Cito") );// nothing
2) browser.check( browser.radio( "mFrm:priorityChecks" ).near( browser.span("Cito") ) );// checks "Normal"
3) browser.check( browser.radio( 0 ).near( browser.span("Cito") ) );// checks "Normal"
4) browser.check( browser.radio( "/mFrm:priorityChecks/" ).near( browser.span("Cito") ) );// checks "Normal"
5) browser.check( browser.radio( "/.*mFrm:priorityChecks.*/" ).near( browser.span("Cito") ) );// checks "Normal"
6) browser.check( browser.radio( "mFrm:priorityChecks[1]" ).near( browser.span("Cito") ) );// checks "Cito"
7) browser.check( browser.radio( "mFrm:priorityChecks[2]" ).near( browser.span("Cito") ) );// checks "Notfall"
8) browser.check( browser.radio( 1 ).near( browser.span("Cito") ) );// checks "Cito"
9) browser.check( browser.radio( 2 ).near( browser.span("Cito") ) );// checks "Notfall"
Still no luck without 0,1,2 relating to first, second, third ...
Especially this one is puzzling to me:
6) browser.check( browser.radio( "mFrm:priorityChecks[1]" ).near( browser.span("Cito") ) );
together with 4), 5) and this one:
browser.radio( "mFrm:priorityChecks" ).near( browser.span("Cito") ).click();
seems to me like the "Sahi API Examples"
Quote:
Let us look at the second textbox, which is near Ruby For Rails:
This is identified as _textbox("q[1]"). This can be a problem, because if a new row is added before Ruby, the index of this textbox would change. To fix this, Sahi uses an _near API. The same textbox can be identified as
_textbox("q", _near(_cell("Ruby for Rails")))
This accessor will not break even if you add another row before Ruby or another column before the textbox.
End Quote
One difference I see is, mine is not a cell / a table. Therefore my thoughts "near" might not be meant to work *without* a real tr/td table?!
Thank you