can't select the YES option - forms

How do i make Watir select a specific radio button? I have 4 radio buttons, and i want it to select the second one:
//this will select the first option
ie.radio(:name, "radio1").set()
I can even set the second option for another radio button doing the following (for a different radio button):
ie.radio(:value => '1').set
however, i have the following radio button:
<input type=radio name='myRadio' id='myRadio-0' value='0' tabindex=8 ><span class=smalll>0. No</span>
<input type=radio name='myRadio' id='myRadio-1' value='1' tabindex=8 ><span
class=smalll>1. Yes</span>
I want to select the the "YES" option here, but no matter what i try, i can't. How do i get around this? I've tried the following:
ie.radio(:value => '1').set
ie.radio(:name, "myRadio-1").set
ie.radio(:name, "myRadio").set
any ideas?

In your example you've used name twice, even though "myRadio-1" is the id of the element, not the name. If that was a typo just in this post and not in your actual code, I would assume that one of the two radio buttons not provided (of the four total) has a conflicting name/id, etc.
For HTML:
<input type=radio name='myRadio' id='myRadio-1' value='1' tabindex=8 >
I would use:
#browser.radio(:id => "myRadio-1").set

Typically radio buttons are in a group. In the examples I've seen, people set the one radio out of the group rather than focus on a radio button.

Related

Check checkbox if following label value is correct

I got a user administration and want to check the checkbox before the label with 'test'. The checkbox and label are seperate from eachother. I can't use //input[#type='checkbox'])[3] because the checkbox and label can appear on a different row.
checkbox user
checkbox bla
checkbox trying
checkbox test
html of checkbox: <input type="checkbox" class="ant-checkbox-input ng-valid ng-dirty ng-touched">
html users: <app-userprofile-title _ngcontent-ads-c205="" _nghost-ads-c77="" class="ng-star-inserted">test</app-userprofile-title>
Try using this Xpath
//input[#type='checkbox']//*[contains(., 'test')]

How do I validate multiple checkboxes, using Statamic forms?

I'm using Statamic CMS
I've got a checkbox group with two checkboxes, I'd like both of them to be checked before the form will submit.
Setting the field as 'required' half works. The form will error if nothing is checked, but it submits if one of the boxes is ticked.
I can see under the validation tab, there's a list of additional rules. But I'm not sure which rule to use.
If it helps, this is what the HTML checkbox group looks like:
<div>
<label>Contact permissions</label>
<span>Please tick both checkboxes</span>
<label>
<input type="checkbox" name="checkboxes[]" value="gdpr" />
Please contact me with the details I've provided
</label>
<label>
<input type="checkbox" name="checkboxes[]" value="terms" />
I agree with the terms and conditions
</label>
</div>
I'm using the {{ fields }} tag to generate the HTML
Within the CMS, under the validation tab, there's a link to the Laravel docs. As I want to validate two checkboxes, I think I need the required_with: rule, but I can't get it to work...
required_with: is looking for two values, the example shows this:
required_with:foo,bar,..
The values of the checkboxes are, value="gdpr" and value="terms" so I (wrongly) assume this should work...
required_with:gdpr,terms
After saving the changes and testing the form, it still submits? Even though only one of the checkboxes might be ticked...
What is the correct syntax/values to use to get this to work?
:) foo,bar in the docs are field names in your form. What you're doing with gdpr,terms are values.
Plus, since both your buttons are named checkboxes[], the form is validating that if either one is selected, then it should be passed. Hopefully this helps!

How to render a Mask checkbox with Typo3 Fluid?

I've created a content element with Mask for Typo3 where the editor can select the payment options provided. In the fluid template however, an integer with a bitmask is returned and not each individual option.
The default rendering suggested by mask is:
{f:if(condition: data.tx_mask_ue_payment_accepted, then: 'On', else: 'Off')}
The result of data.tx_mask_ue_payment_accepted can vary from 0 (nothing selected) to 511 (all 9 options selected). Has anyone managed to smoothly implement the checkbox with a for-loop or anything proper and if so how?
Many thanks in advance!
I use bitmask in a couple of areas for my current FE plugin and haven't found a better way than to map the field-value-pairs in your controller action prior to displaying the form.
For this I implemented two methods which will convert the current bitmask value to individual boolean values (and vice versa). I bind those values to an array and display it in a fluid for loop as checkboxes (not using extbase direct property mapping).
Maybe this gets somebody in the right direction, even if its no copy&paste ready solution.
Fluid:
<input type="checkbox" name="tx_myext[checkbox][0]" value="1" id="checkbox0" class="checkbox" {f:if(condition:'{return.checkbox.0} == "1"',then:'checked="checked"',else:'')}>
<input type="checkbox" name="tx_myext[checkbox][1]" value="1" id="checkbox1" class="checkbox" {f:if(condition:'{return.checkbox.1} == "1"',then:'checked="checked"',else:'')}>
As you can see we get an array "return" back that contains the values from the transmitted form. If the values exists we set the checkbox to "checked".

Best usability when label applies to two form elements?

I have a 'time select' form that is two select option elements, one for the hour and one for the minute (with 15 min granularity).
I only want 1 label saying 'choose time' as I think its obvious its hour and minute. Normally I associate a label with an input like so:
<label for="something">Label Text</label>
<input id="something" />
So what should I do in this case where the label relates to two elements?
Thanks
I'd label both inputs (hours, minutes, associated explicitly like you have), use one of the CSS techniques to hide them visually (but keep them in the DOM so they are available to AT). Then wrap everything in a fieldset and add a legend to the fieldset for "choose time".
Like this:
<fieldset>
<legend>Choose Time</legend>
<label for="hour">Hour</label>
<input id="hour" />
<label for="minute">Minute</label>
<input id="minute" />
</fieldset>

value for select in Selenium IDE

Is there a way to select an item based on the label containing a set of characters? I can't select by index as that will change, and the items being generated in the select have some random numbers appended at the end. I'd like the basically say if the label contains "this."
is that possible?
Thanks!
Sure, example in XPath:
//*[contains(text(), 'this')]
Or CSS:
select:contains('This')
Another example
<label for="blah">
<input name="blah" id="blah" type="checkbox" />
Store Locator Plus
</label>
My target to get the checkbox:
//label[contains(text(),'Store Locator Plus')]//input[#type="checkbox"]
To check it I use the command "check", the target noted above, and a value of "On", which forces the checkbox to be marked (versus using click which will toggle it on/off).