14Aug/08Off
Q. How do I set a checkbox with a dynamic id attribute?
A. Use a regex match to populate a dynamic variable ...
Example html:
<form action="test_0019.html" method="get" accept-charset="utf-8"> <input id="cblRoles_3" type="checkbox" tabindex="47" name="cblRoles:3"/> <label for="cblRoles_3">Customer</label> <input id="cblRoles_4" type="checkbox" tabindex="48" name="cblRoles:4"/> <label for="cblRoles_4">Expedite</label>
Example watir:
dynamic_id = @b.html[/cblRoles_\d+>Expedite/].gsub(">Expedite","") @b.checkbox(:id,dynamic_id).set
7Aug/08Off
Q. How do I check/uncheck a checkbox?
A. Use a the .checkbox in conjunction with .set(true/false)
Example html:
<form> <input name="checkbox" type="checkbox" />I love just_add_watir ! </form>
Example watir to activate:
@b.checkbox(:name, "checkbox").set(true)
Example watir to deactivate:
@b.checkbox(:name, "checkbox").set(false)