Then the radio button "value" should be selected

Asserts that a radio button, located by a CSS selector, is selected or is not selected. The step reads the checked state of the first element matched by the selector and fails with a descriptive message when the actual state does not match the expectation: Radio button "#gender-female" should NOT be selected but it is.

The selector can be any CSS expression that resolves to the radio input, such as an id (#gender-male), a class (.option-1), an attribute selector (input[value=premium]), or a test id ([data-testid=annual]). Adding not inverts the assertion. A closely related step lets you target the radio by its value attribute instead of a full selector, using the phrasing the radio button with value "..." should be selected; in that form webship-js builds the locator for you from the value. Both steps only assert state; to actually pick a radio button first, use I choose the radio button "...".

Accepted phrasings

Then the radio button "<selector>" should be selected
Then the radio button "<selector>" should not be selected
Then radio button "<selector>" should be selected
And the radio button "<selector>" should not be selected

Then the radio button with value "<value>" should be selected
Then the radio button with value "<value>" should not be selected

The leading the is optional. This is an assertion step, so it is normally used with Then or chained with And after another assertion.

Examples

Then the radio button "#gender-male" should be selected
Then the radio button "#gender-female" should not be selected
Then the radio button ".option-1" should be selected
Then the radio button with value "premium" should be selected

In a real scenario

Scenario: Blocking a member account from the people list
  Given I am a logged in user with the "Site admin" user
   When I go to "/admin/people"
    And I fill in "Normal user" for "Name or email contains"
    And I press "Filter"
   Then I should see "Normal user"
   When I click "Edit" in the "Normal user" row
    And I choose the radio button "#account-blocked"
   Then the radio button "#account-blocked" should be selected
    And the radio button "#account-active" should not be selected
   When I press the "Save" button
   Then I should see "The changes have been saved."

Related steps

Back to Field Steps