I am trying to check and uncheck checkboxes based on following requirements:
- If a particular text is present, I need to check the checkbox for it.
-
If some other text has checkbox set, I need to uncheck that checkbox
<table class="adm"> <tbody> <tr class="action"> <td width="20px"> <input class="checkbox" type="checkbox" name="checkbox1"> </td> <td> <span class="label"> <script id="start"></script> Action1 <script id="end"></script> </span> <p class="desc"> <script id="start"></script> Description1 <script id="end"></script> </p> </td> </tr> </tbody> </table> <table class="adm"> <tbody> <tr class="action"> <td width="20px"> <input class="checkbox" type="checkbox" name="checkbox2"> </td> <td> <span class="label"> <script id="start"></script> Action2 <script id="end"></script> </span> <p class="desc"> <script id="start"></script> Description2 <script id="end"></script> </p> </td> </tr> </tbody> </table>
And there are 5 checkbox classes like the one above. So , I need to check :
- Find "Action1" -> check it's checkbox.
- If "Action2" has checkbox set -> uncheck that checkbox.
So, need to set checkbox as per requirements and uncheck all other checkboxes.
I found this to check/uncheck all checkboxes:
checkbox_class = /checkbox/
@browser.checkboxes(:class => checkbox_class).each do |checkbox|
if(!checkbox.checked?)
p "checkbox not set"
checkbox.set
else
p "checkbox set"
checkbox.clear
end
end
But I am unable to cater this as per my requirements, tried this:
checkbox_class = /checkbox/
action_class = /label/
@browser.checkboxes(:class => checkbox_class).each do |checkbox|
if(!@browser.span(:class=>action_class,:text=>"some_action").checkbox.checked?)
p "checkbox not set"
checkbox.set
else
p "checkbox set"
checkbox.clear
end
end
Aucun commentaire:
Enregistrer un commentaire