Cannot check checkbox

26 views
Skip to first unread message

medv...@gmail.com

unread,
May 31, 2017, 6:23:56 AM5/31/17
to Geb User Mailing List
hi,

I need help by checking a checkbox.

tried to ".click" it and also check it with "<< Keys.ENTER" 

registerForm(required: false) { $("form", id: "registerForm") }
registerFormCheckbox (required: false) {registerForm.find("div", class:"col-xs-12 col-sm-12 pull-left").find("div", class:"checkbox check-box")[0].$("label", class:"check-label control-label ").$("svg", class:"ui-icon ui-icon--check")}

<div class="register-form-action row">
<div class="col-xs-12 col-sm-12 pull-left">
<span class="register-checkboxes">
<div class="checkbox check-box">
<input id="Ich stimme der Verarbeitung meiner personenbezogenen Daten gemäß der Datenschutzerklärung von abc zu.name="policytype="checkboxvalue="true"/>
<input type="hiddenname="_policyvalue="on"/>
<label class="check-label control-label for="Ich stimme der Verarbeitung meiner personenbezogenen Daten gemäß der Datenschutzerklärung von abc zu.">
Ich stimme der Verarbeitung meiner personenbezogenen Daten gemäß der Datenschutzerklärung von abc zu.
<span class="mandatory"/>
<span class="skip"/>
<svg class="ui-icon ui-icon--check">
<use xlink:href="#sprite-icons--check"/>
</svg>
</label>
</div>
</span>
</div>
<div class="col-xs-12 col-sm-12 pull-left">
</div>

but somehow it does not work. Any idea or hint?
thanks in advance!

antony...@vendigo.com

unread,
May 31, 2017, 9:47:55 AM5/31/17
to Geb User Mailing List
There are a few things wrong here:

1. Your selector is insanely long. If you ever change your HTML you are going to be fixing tests for years. Try to use the most minimal selectors you can.
2. There is a whole form-control shortcut section in the manual. http://gebish.herokuapp.com/manual/current/#form-control-shortcuts - You can reference form fields directly using their 'name' attributes. See below.

Try:

// in your 'content' block
registerForm { $('#registerForm') }

// in your test, just do:
registerForm.policy = true

Cheers,
Antony

medv...@gmail.com

unread,
Jun 1, 2017, 3:57:43 AM6/1/17
to Geb User Mailing List
Absolutely perfect solution, works great!
Thank you very much for your help Antony!

Best regards,
Roland
Reply all
Reply to author
Forward
0 new messages