For all the checkboxes and radio buttons i create a locater builder:
LocatorBuilders.add('radio', function(e) {
var name = e.parentNode.parentNode.getAttribute('name');
var value = name + '_' + e.parentElement.getAttribute('value');
var result = 'radio=' + value;
return result;
});
And a locater strategy:
PageBot.prototype.locateElementByRadio = function(locatorString, inDocument, inWindow) {
var name = locatorString.split('_')[0];
var value = locatorString.split('_')[1];
var result = inDocument.querySelector('div[field=' + name +'] label[value=' + value +'] input');
return result;
}
HTML element:
<div class="radio" name="radio-example" style="">
<label class="radio-label" value="male" style="">
<input class="radio-input" style="" tabindex="1" type="radio">
<span class="option">Man</span>
</label>
</div>
This works perfect and in my selenium IDE is ee something like radio=new_yes But when i record a click on a radio i see two commands in selenium ide. One command with the locater builder and one command with a verry long xpath that belong to the label from the checkbox. How can i record only the input field from the checkbox? and not the label ?