New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add <datalist> support to cy.select #445
Comments
On second thought, |
how can i select input datatalist in cypress, i've tried everything way i can but cypress's not same to be support it. Sorry for my bad english |
This is a case where you don't need to do things exactly like a user would. So you don't need to open the datalist and 'select' an option to get it to work. If you want to test an input with a datalist, you generally want to test 2 things:
So you can break it up similarly. If you have the following html: <input list="fruit" />
<datalist id="fruit">
<option>Apple</option>
<option>Banana</option>
<option>Cantaloupe</option>
</datalist> You can test it like this: cy.get('#fruit option').should('have.length', 3)
.first().should('have.text', 'Apple')
.next().should('have.text', 'Banana')
// ... etc ...
cy.get('input').type('Apple') For testing the options, you query them directly and make assertions. For 'selecting' an option, you Edited by @jennifer-shehane - replaced |
I created a new issue in our docs to document datalist testing here: cypress-io/cypress-documentation#824. Our documentation is open source and contributions are welcome. 😄 I also updated @chrisbreiding example above to use |
<datalist>
elements are similar to<select>
elements and it would be a natural extension ofcy.select()
to support them.The text was updated successfully, but these errors were encountered: