teamcapybara / capybara

Acceptance test framework for web applications
http://teamcapybara.github.io/capybara/
MIT License
10.02k stars 1.45k forks source link

have_content is failing when it shouldn't #1335

Closed TrevorHinesley closed 10 years ago

TrevorHinesley commented 10 years ago

Using Capybara 2.3.0

As you can see from this test failure (which only happens sometimes), have_content is just not working sometimes (compare the last line to what's expected to be found):

Failure/Error: page.should have_content("successfully updated!")
       expected to find text "successfully updated!" in "GAMETIME  
       DASHBOARD TEST EVENT Next Step: Add Game Scores to Completed 
       Tournament Games TOURNAMENT DETAILS FOR TEST TOURNAMENT Event 
       Website: http://127.0.0.1:37067/gametime/testing-event-1-recruittalk-fake-url 
       Tournament Website: http://127.0.0.1:37067/tournaments/tourney-test-uri 
       Registration Page: http://127.0.0.1:37067/gametime/registration?event=1 Below is 
       the information for your tournament. This info will be displayed on your tournament 
       page when coaches go to create their teams' accounts and when parents view the 
       brackets. Add details! CHOOSE/CREATE TOURNAMENT Test tournament EVENT 
       DETAILS EVENT MATCH LOCATIONS TOURNAMENT DETAILS TEAMS POOL 
       BRACKETS ENTER POOL MATCH LOCATIONS & TIMES ENTER POOL 
       SCORES TOURNAMENT BRACKET ENTER TOURNAMENT MATCH LOCATIONS 
       & TIMES ENTER TOURNAMENT SCORES SEND A MESSAGE Game A (Round 
       1) Super Team 15U vs Super Team 15U - 2 MATCH START DATE/TIME 
       COURT/LOCATION TEST LOCATION ABOUT | CONTACT | SUPPORT | PRIVACY 
       | TERMS | COLLEGES DIRECTORY Game A 
       successfully updated! OK"

# ./spec/features/gametime_spec.rb:298:in `block (3 levels) in <top (required)>'
abotalov commented 10 years ago

I think this is the duplicate of https://github.com/jnicklas/capybara/issues/1179

TrevorHinesley commented 10 years ago

I see. Is there a workaround? What's the resolution?

abotalov commented 10 years ago

This bug isn't yet fixed. The workaround is to increase wait time.

TrevorHinesley commented 10 years ago

Hmm alright thanks I'll give it a shot.

twalpole commented 10 years ago

Yes this appears to be a duplicate of #1179 however I wouldnt say a "workaround" is to increase the wait time, the solution to the test failing is to increase the wait time, or speed up your app. Whats happening is the page is finally changing between the time have_content stops checking for the correct text, and the time the error message is generated. So even if the error message was correct your test would still be failing occasionaly. unless you increase the wait time or speed up your app - Anyway - closing as a duplicate of #1179