Check checkbox if following label value is correct - katalon-studio

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')]

Related

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!

Protractor how to validate checkbox state with Reactive Forms

how to validate checkbox state is checked or not in Reactive Forms:
<div class="form-group ng-star-inserted" id="no_empty-group"><label></label><span class="content"><label><input formcontrolname="no_empty" id="no_empty" type="checkbox" ng-reflect-name="no_empty" class="ng-valid ng-dirty ng-touched"> Don't send empty </label></span></div>
I do not see any changes on HTML if I check or un-check this checkbox.
Not sure how to validate in Protractor that checkbox is checked.
for elements of type="checkbox" this should work:
var checkbox = element(by.id('no_empty'));
expect(checkbox.isSelected()).toBe(false); // unchecked
checkbox.click();
expect(checkbox.isSelected()).toBe(true); // checked

Change the value selected from autocomplete

I am trying to update the value of an input field after the user chooses a selction from autocomplete. I am using typeahead js for autocomplete feature. Here is my jsfiddle
https://jsfiddle.net/aminur/jLa7x28y/7/
<div id="the-basics">
<input class="typeahead" type="text" placeholder="States of USA">
</div>
Once the user selects a state, I want to update the value of the input field to its short form. Like if the user selects Connecticut, I would like to update the display as CT. I tried using oninput, bind functions on the input tag. It didnt work. can you please help?

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).

can't select the YES option

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.