At the moment I am trying to implement testing onto my already existing Signup page. There are a variety of required areas to fill out, two of them being a drop down for area location. The first is to select your country and then a subregion selector will appear for that country with the various states/regions to choose from. This seems to cause an issue I believe with RSpec, though unsure why. Here is my code below:
#Signup View
....
<p>
<%= f.label :country, "Country *", class: "input_title" %><br />
<%= f.country_select :country, {priority: %w(US CA), prompt: 'Please select a country'} %>
</p>
<p>
<%= f.label :state, "Region/State *", class: "input_title" %><br />
<%= render partial: '/users/subregion_select', locals: {parent_region: f.object.country} %>
</p>
....
#_spec.rb
require 'rails_helper'
RSpec.feature "Users can signup" do
scenario "with valid attributes" do
visit "/"
click_link "Signup"
fill_in "Username *", with: "TestUser"
fill_in "First Name *", with: "Joe"
fill_in "Last Name *", with: "Dayvie"
fill_in "Email *", with: "joe@dayvie.com"
fill_in "Confirm Email *", with: "joe@dayvie.com"
select "United States", from: "Country *", match: :first
select "Nevada", from: "Region/State *"
fill_in "City *", with: "Las Vegas"
fill_in "Create Password *", with: "password"
fill_in "Confirm Password *", with: "password"
click_button "Signup"
end
end
#Failure from Test
Failure/Error: select "Nevada", from: "Region/State *"
Capybara::ElementNotFound:
Unable to find select box "Region/State *"
I am assuming this occurs because the selection box appears; however, this should work since it does select a country correctly? Any information or help you may have is greatly appreciated, thank you!
Aucun commentaire:
Enregistrer un commentaire