I have a radio element <input type="radio" name="gender" value="male" />
below is my cypress code
cy.getAllByRole("radio").first().click()
how do I get the value attribute of the radio element? something like this
const radioValue = cy.getAllByRole("radio").first().getValue() //"male"
CodePudding user response:
You can try this:
cy.getAllByRole('radio')
.first()
.invoke('val')
.then((val) => {
cy.log(val) //logs male
})