1
我正在測試我用黃瓜/水豚創建的應用程序。它看起來沒有看到我正在使用的x-tag。它看起來像Cucumber不會使用x-tag正確渲染頁面。有沒有辦法解決這個問題?我認爲這是問題所在,因爲當我將輸入字段放在xlogin.js之外並放入正文或id = login的div時,它確實有效。黃瓜/水豚測試x標籤
身體:
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="js/jquery/jqueryMobile/jquery.mobile-1.2.0.css" />
<link rel="stylesheet" href="components/login/login.css"/>
<link rel="stylesheet" href="master.css"/>
</head>
<body>
<div id="login" data-role="page" class="ui-tass-page">
<x-login></x-login>
</div>
<div id="main" data-role="page" class="ui-tass-page">
</div>
<script src="js/x-tag.js"></script>
<script src="components/login/login.js"></script>
<script src="js/jquery/jquery-1.8.2.js"></script>
<script src="js/jquery/jqueryMobile/jquery.mobile-1.2.0.js"></script>
</body>
特點:
Feature: log in
In order to get access to the app's functionality
As a user
I want to log in
Scenario: happy flow
Given I am on the index.html#login page
Then I should be on the index.html page
When I give my username
And I give my password
And I click on login
Then I should go to the main page
And the username and password are saved
步驟:
When /^I give my username$/ do
fill_in 'username', :with => '[email protected]'
end
Given /^I am on the (.*?) page$/ do |uri|
visit uri
response = page.driver.response
response.status.should eql 200
response.status.should_not eql 401
end
Then /^I should be on the (.*?) page$/ do |uri|
current_url.include?(uri).should be true
end
輸出:
Scenario: happy flow # features/login.feature:6
Given I am on the index.html#login page # features/step_definitions/generic_steps.rb:1
Then I should be on the index.html page # features/step_definitions/generic_steps.rb:8
When I give my username # features/step_definitions/login_steps.rb:1
cannot fill in, no text field, text area or password field with id, name, or label 'username' found (Capybara::ElementNotFound)
(eval):2:in `fill_in'
./features/step_definitions/login_steps.rb:2:in `/^I give my username$/'
features/login.feature:9:in `When I give my username'