Skip to content

Conversation

matchai
Copy link
Contributor

@matchai matchai commented Sep 19, 2018

What:
Add methods to access a <select> element by its selected option's text value.

Why:
The first <option> is commonly used in <select> elements, like a placeholder attribute is used for text inputs. What the user sees is the text value of the first option, but it's not possible to access the <select> element given that text value. This PR provides methods to access the <select> element in that situation. Closes #104.

How:
queryBySelectText(), queryAllBySelectText(), getBySelectText(), and getAllBySelectText() were implemented.

Checklist:

  • Documentation
  • Tests
  • Ready to be merged
  • Added myself to contributors table

Thank you for making an excellent testing library. Happy to be contributing! 😄

Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is perfect. Thank you for this!!

@kentcdodds kentcdodds merged commit c07657d into testing-library:master Sep 19, 2018
@matchai matchai deleted the pr/add-getBySelectText branch September 19, 2018 03:49
<select>
<option value="">Japanese cars</option>
<option value="volvo">Toyota</option>
<option value="audi">Honda</option>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fun: Choose a BMW or a Toyota, get a Volvo. Choose a Honda, get an Audi. 😁

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops! Changed these values around and forgot to update the text. 😅

@kentcdodds
Copy link
Member

🎉 This PR is included in version 3.6.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to access <select> elements given their text value
3 participants