0

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 ?

Selenium IDE

Janp95
  • 534
  • 8
  • 27

1 Answers1

0

If you are only trying to get the locator for the radiobutton, you can use this locator

css=input.radio-input

Let me know if you have any more questions.

Rodel Bernal
  • 323
  • 2
  • 13
  • I would locate elements with the selenium IDE. As you can see it works good with above function. The only thing is that the IDE record two locaters. I would that selenium IDE record only the one with re radio= prefix. – Janp95 Jun 10 '16 at 11:24