Skip to main content

RadioButtonGroupElement

Playwright element wrapper for <vaadin-radio-group>. Provides helpers to select by label/value and assert selected state.

Component Tag

vaadin-radio-group

Implements

  • HasLabelElement
  • HasEnabledElement
  • HasHelperElement
  • HasValidationPropertiesElement

Factory Methods

getByLabel

public static RadioButtonGroupElement getByLabel(Page page, String label)
Get the radio button group by its accessible label. Uses ARIA role RADIOGROUP.
page
Page
required
The Playwright page
label
String
required
The accessible label of the radio group
Returns: The matching RadioButtonGroupElement

Constructor

RadioButtonGroupElement

public RadioButtonGroupElement(Locator locator)
Create a new RadioButtonGroupElement.
locator
Locator
required
The locator for the <vaadin-radio-group> element

Methods

selectByLabel

public void selectByLabel(String label)
Select a radio button by its label text.
label
String
required
The label text of the radio button to select

selectByValue

public void selectByValue(String value)
Select a radio button by its value.
value
String
required
The value of the radio button to select

getRadioButtonByLabel

public RadioButtonElement getRadioButtonByLabel(String label)
Get a specific radio button by its label within the group.
label
String
required
The label text of the radio button
Returns: The matching RadioButtonElement

setValue

public void setValue(String value)
Set the selected value by label.
value
String
required
The label of the radio button to select

assertValue

public void assertValue(String value)
Assert the selected value by label.
value
String
Expected label of the selected radio button, or null/empty for no selection

Usage Examples

Basic Selection

RadioButtonGroupElement group = RadioButtonGroupElement.getByLabel(page, "Basic RadioButtonGroup");
group.assertVisible();
group.assertEnabled();
group.assertValue(null);

group.selectByLabel("Option 2");
group.assertValue("Option 2");

group.selectByLabel("Option 3");
group.assertValue("Option 3");

Pre-selected Value

RadioButtonGroupElement group = RadioButtonGroupElement.getByLabel(page, "Pre-selected Value");
group.assertVisible();
group.assertValue("Option 2");

Disabled State

RadioButtonGroupElement group = RadioButtonGroupElement.getByLabel(page, "Disabled RadioButtonGroup");
group.assertVisible();
group.assertDisabled();

Helper Text

RadioButtonGroupElement group = RadioButtonGroupElement.getByLabel(page, "Helper Text");
group.assertVisible();
group.assertHelperHasText("This is a helper text");

Build docs developers (and LLMs) love