【发布时间】:2018-07-03 13:15:19
【问题描述】:
在我的 Rails 4 应用程序中,我有一个表单供用户设置新密码。 我想用 Capybara 对此进行测试并测试输入字段的顺序,因为我需要确保它们在 UI 中始终处于特定顺序。
在我的用户界面中:
input[@id = "user_current_password"]
input[@id = "user_password"]
input[@id = "user_password_confirmation"]
我的测试现在看起来像:
it 'changing the expired password' do
render
expect(rendered).to have_content("Update Password")
expect(rendered).to have_content("Current Password:")
expect(rendered).to have_content("New Password:")
expect(rendered).to have_content("Confirm New Password:")
expect_submit_button("Change Password")
# Boxes order
current_password = page.has_xpath?('//input[@id = "user_current_password"]')
new_password = page.has_xpath?('//input[@id = "user_password"]')
confirm_new_password = page.has_xpath?('//input[@id = "user_password_confirmation"]')
end
我需要添加一种方法来检查输入字段的顺序是否始终相同。因此,如果由于某种原因订单更改,我看到测试失败。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 capybara rspec-rails