diff --git a/README.md b/README.md index 504ef70..b599008 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,7 @@ smart people at [Hashrocket](http://hashrocket.com/). - [Params Includes Submission Button Info](rails/params-includes-submission-button-info.md) - [Pretend Generations](rails/pretend-generations.md) - [Retrieve An Object If It Exists](rails/retrieve-an-object-if-it-exists.md) +- [Select A Select By Selector](rails/select-a-select-by-selector.md) - [Select Value For SQL Counts](rails/select-value-for-sql-counts.md) - [Show Pending Migrations](rails/show-pending-migrations.md) diff --git a/rails/select-a-select-by-selector.md b/rails/select-a-select-by-selector.md new file mode 100644 index 0000000..58f035e --- /dev/null +++ b/rails/select-a-select-by-selector.md @@ -0,0 +1,17 @@ +# Select A Select By Selector + +Generally when using Capybara to select from a `select` input, I reference it by its `name` +which rails associates with the label: + +```ruby +select("Charizard", from: "Pokemon") +``` + +However, not all forms are going to have a label paired with every `select` +input. We don't want to let our test coverage suffer, so we are going to +need a different way to select. Capybara allows us to chain `select` off a +`find` like so: + +```ruby +find('#pokemon_list').select('Charizard') +```