-
I need to select option of We have option to pick using text by: |
Beta Was this translation helpful? Give feedback.
Answered by
bahmutov
Mar 31, 2021
Replies: 1 comment 1 reply
-
See how to do this in https://glebbahmutov.com/cypress-examples/6.8.0/recipes/select-value-by-id.html // let's find the option with the given test-id
const optionid = 'pick-oranges'
cy.get('[data-testid=select-example]')
.find(`option[data-testid=${optionid}]`)
.invoke('attr', 'value')
.then((value) => {
// now that we know the value of the <option>
cy.get('[data-testid=select-example]').select(value)
})
// confirm the selected option
cy.get('[data-testid=select-example] option:selected').should(
'have.text',
'Oranges',
) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
bahmutov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See how to do this in https://glebbahmutov.com/cypress-examples/6.8.0/recipes/select-value-by-id.html