Working with Radio Groups

Learn how to find and interact with a radio group using Selenium.

Iterate radio buttons in a radio group

So far, we have been focusing on identifying a specific web control by using one type of locator, i.e., findElement. We will now use another type of locator called findElements.

findElement is different from findElements in a sense because findElement returns one matched control, whereas findElements return a list of matched controls. This comes in handy when the controls are hard to locate like in the case of a radio group. An example of iterating through a radio group is given below:

  assert.equal(2, radios.length);
    radio.getAttribute("Value").then(function(radio_value) {
      if (radio_value == "female") {;

Get hands-on with 1200+ tech skills courses.