我正在使用Cucumber / Capybara编写一些功能级别的测试。
这是我的功能定义
Feature: User Signin
As a User
I want to signin
So i can use my app
Background:
Given user with "email" email and "password" password
Scenario: Signing in with correct credentials
When I go to sign in page
And I fill in "user_email" with "email"
And I fill in "user_password" with "password"
And I click "Sign in" button
Then I should go to the dashboard page
如何定义步骤以检查它是否转到特定页面?基本上我该如何定义以下步骤?
Then(/^I should go to the dashboard page$/) do
end
还有Cucumber / Capybara步骤定义的文档吗?
答案 0 :(得分:1)
有几种可能性:
使用current_path
或current_url
方法检查网页的路径/网址:
Then(/^I should go to the dashboard page$/) do
current_path.should == expected_path
# or current_path.should == expected_url
end
Then(/^I should go to the dashboard page$/) do
page.should have_css('#id_that_is_present_only_at_dashboard_page')
end
您也可以使用页面对象模式并执行以下操作:
current_path.should == DashboardPage.path