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.
Selecting checkbox from among varying number of them with random names
Hi,
I have a number of checkboxes on a page whose number keeps on changing. Also their names keep on changing. The only way to identify a checkbox is the text (spandiv) appearing next to the checkbox. How can I identify the checkbox and select it?
one way I could figure out was that the distance between the checkbox and the spandiv text is constant. I could also calculate the distance between them. but is there any way to perform mouseclick on the basis of coordinate positions?(say i want to click at the location (55, 545) ).
Regards,
Pankaj Kumar.
I have a number of checkboxes on a page whose number keeps on changing. Also their names keep on changing. The only way to identify a checkbox is the text (spandiv) appearing next to the checkbox. How can I identify the checkbox and select it?
one way I could figure out was that the distance between the checkbox and the spandiv text is constant. I could also calculate the distance between them. but is there any way to perform mouseclick on the basis of coordinate positions?(say i want to click at the location (55, 545) ).
Regards,
Pankaj Kumar.
Comments
This is exactly what i was looking for.
However I am getting some object error with this code. But am trying to implement it. Will be back with more queries..:)
Thanks again.
Pankaj.
Please suggest.
Am still struggling to get through this but am getting an error saying previousSibling is null or not an object.
please help.
Regards,
Pankaj.
This is a snippet of the code for the checkbox and its associated text:
[code]
<li>
<input id="abc_123" type="checkbox" class="check" name="abc" value="123" />
<label for="abc_123" class="inline">
<a href="href value goes here" class="noLine thickbox" ><span class="">Text for the abc_123 checkbox</span></a>
</label>
</li>
[code]
now my problem is the numeric part of the id and the value for checkbox are dynamic and are decided at run time. I need to select the checkbox corresponding to the text "Text for the abc_123 checkbox".
I tried the code given but get the error "previousSibling is null or not an object. I also tried using nextSibling but in vain.
Please suggest.
Regards,
Pankaj.
Resolved the problem. The solution is specific. However I wanted to make a more generic function. The issue was appearing because of the DOM heirarchy...i have to check the parent/child, sibling-sibling relations etc...if anyone has got a more generic function please share..
Have a nice day!
Thanks and Regards,
Pankaj.