Radio Button Elements
Overview
Radios can be interacted with by either
Watir::Radio
or
Watir::RadioSet
.
(RadioSet
was added in Watir 6.8)
These are accessed by calling Browser#radio
or Browser#radio_set
, respectively.
Creating a RadioCollection
is accomplished with Browser#radios
, but you should
always prefer working with a RadioSet
.
For all of the different ways of locating a Radio
element,
take a look at our Locating Elements Guide.
A RadioSet
is located by passing in a valid locator for any
of the Radio
elements included in the RadioSet
(so often using the :name
attribute locator).
Radio Buttons are special because only one button within a form with a specific name can be selected at a time. You can either identify the specific Radio button you want and interact with it, or you can identify the entire group with RadioSet and select the one you want by value or text.
They also inherit methods from standard Web Elements
Common or Special Methods
Radio#select
Radio#selected?
RadioSet#selected
RadioSet#selected?
RadioSet#select
RadioSet#text
RadioSet#value
Standard Setter Interface
This functionality was added in Watir 7 beta 2.
Radio#set
is the same behavior as the superclass Element
; if no arguments are passed
or true
is passed, it will click the link.
RadioSet#set
is an alias of #select
. It takes a String
or a Regexp
argument.
Watir will select the first Radio
that matches by value
, text
or label
attributes.