问题
I've created test to simulate logging in facebook and twitter to register on my app. When I run the individual cucumber test, it passes. However, when I run the entire cucumber test, it fails at the facebook and twitter logging in.
Note: the point where it fails is the 2nd time the facebook and twitter scenario is used to login. The 1st time the feature used passed.
When running cucumber features.
Unable to find field "email" (Capybara::ElementNotFound)
./features/step_definitions/microsites/quiz/microsites_quiz_entrant_sign_in_facebook_steps.rb:13:in `/^I log in with my facebook email and password quiz$/'
./features/support/database_cleaner.rb:11:in `block in <top (required)>'
features/microsites/quiz/microsites_quiz_entrant_sign_in_facebook.feature:7:in `And I log in with my facebook email and password quiz'
Unable to find field "username_or_email" (Capybara::ElementNotFound)
./features/step_definitions/microsites/quiz/microsites_quiz_entrant_sign_in_twitter_steps.rb:13:in `/^I log in with my twitter email and password quiz$/'
./features/support/database_cleaner.rb:11:in `block in <top (required)>'
features/microsites/quiz/microsites_quiz_entrant_sign_in_twitter.feature:7:in `And I log in with my twitter email and password quiz'
Failing Scenarios:
cucumber features/microsites/quiz/microsites_quiz_entrant_sign_in_facebook.feature:3 # Scenario: Viewing quiz entrant sign in with facebook
cucumber features/microsites/quiz/microsites_quiz_entrant_sign_in_twitter.feature:3 # Scenario: Viewing quiz entrant sign in with twitter
Running individual cucumber test
Using the default profile...
Feature: Entrant Sign In Quiz with facebook
Scenario: Viewing quiz entrant sign in with facebook # features/microsites/quiz/microsites_quiz_entrant_sign_in_facebook.feature:3
Given there is a quiz entrant sign in page facebook # features/step_definitions/microsites/quiz/microsites_quiz_entrant_sign_in_facebook_steps.rb:1
When I visit the quiz entrant microsite sign in page facebook # features/step_definitions/microsites/quiz/microsites_quiz_entrant_sign_in_facebook_steps.rb:8
I, [2016-03-10T09:24:47.442080 #41761] INFO -- omniauth: (facebook) Setup endpoint detected, running now.
I, [2016-03-10T09:24:47.443293 #41761] INFO -- omniauth: (facebook) Request phase initiated.
Then I click on the social facebook login button # features/step_definitions/microsites/photo_upload/microsites_photo_upload_entrant_sign_in_facebook_steps.rb:14
I, [2016-03-10T09:24:50.419651 #41761] INFO -- omniauth: (facebook) Setup endpoint detected, running now.
I, [2016-03-10T09:24:50.420759 #41761] INFO -- omniauth: (facebook) Callback phase initiated.
And I log in with my facebook email and password quiz # features/step_definitions/microsites/quiz/microsites_quiz_entrant_sign_in_facebook_steps.rb:12
Then I complete the quiz entrant registration for facebook # features/step_definitions/microsites/quiz/microsites_quiz_entrant_sign_in_facebook_steps.rb:18
And I can click Enter to upload a photo entry # features/step_definitions/microsites/photo_upload/microsites_photo_upload_entrant_sign_in_facebook_steps.rb:33
1 scenario (1 passed)
6 steps (6 passed)
0m12.362s
Using the default profile...
Feature: Entrant Sign In Quiz with twitter
Scenario: Viewing quiz entrant sign in with twitter # features/microsites/quiz/microsites_quiz_entrant_sign_in_twitter.feature:3
Given there is a quiz entrant sign in page twitter # features/step_definitions/microsites/quiz/microsites_quiz_entrant_sign_in_twitter_steps.rb:1
When I visit the quiz entrant microsite sign in page twitter # features/step_definitions/microsites/quiz/microsites_quiz_entrant_sign_in_twitter_steps.rb:8
I, [2016-03-10T09:39:32.581672 #41900] INFO -- omniauth: (twitter) Setup endpoint detected, running now.
I, [2016-03-10T09:39:32.582803 #41900] INFO -- omniauth: (twitter) Request phase initiated.
Then I click on the social twitter login button # features/step_definitions/microsites/photo_upload/microsites_photo_upload_entrant_sign_in_twitter_steps.rb:14
I, [2016-03-10T09:39:36.825594 #41900] INFO -- omniauth: (twitter) Setup endpoint detected, running now.
I, [2016-03-10T09:39:36.829630 #41900] INFO -- omniauth: (twitter) Callback phase initiated.
And I log in with my twitter email and password quiz # features/step_definitions/microsites/quiz/microsites_quiz_entrant_sign_in_twitter_steps.rb:12
Then I complete the quiz entrant registration for twitter # features/step_definitions/microsites/quiz/microsites_quiz_entrant_sign_in_twitter_steps.rb:18
And I can click Enter to upload a photo entry # features/step_definitions/microsites/photo_upload/microsites_photo_upload_entrant_sign_in_facebook_steps.rb:33
1 scenario (1 passed)
6 steps (6 passed)
0m14.284s
回答1:
Found a gem that can used to log out of facebook
Capybara Facebook Macros
来源:https://stackoverflow.com/questions/35921003/cucumber-features-test-fail-but-single-cucumber-test-passes-facebook-and-twitter