Tests fail unless page object is accessed #205

Closed
willrjmarshall opened this Issue Nov 4, 2011 · 9 comments

Comments

Projects
None yet
8 participants

I'm having a strange issue using Capybara-webkit with Rspec 2.

I have a "before do" block that looks like this:

    before do
      visit "/"
      click_link "Log in"
      fill_in "Email", :with => user.email
      fill_in "Password", :with => "password" 
      click_button "Sign in"
    end

    it "should show me a link to my profile on the home page" do
      visit "/"
      page.should have_content "My profile"
    end

This fails, as the login is not completed (although it should work).

However, if I access the page object at the end of the before block, e.g.

page.should_not have_content "NOTONTHEPAGE"

Then the login succeeds and this test passes.

It looks like Capybara-webkit requests aren't actually being run until the page object is accessed...

Papipo commented Nov 28, 2011

Have you tried to click on a link to the homepage instead of using visit() in the example?

It happened to me in the past, that if you use visit() after signing in, the session is lost.

This is happening to me too. I need to 'touch' my Scenarios as a first step when a Background block is present. I have been using "And I should be logged in" as my 'touch'. Has anyone found a solution or an alternative to visit()? Thanks -G

Owner

jferris commented Nov 9, 2012

Can you guys retry on the latest master? We've fixed a number of async issues.

rmehner commented Nov 12, 2012

Had the same problem, tested with master. Now the test just hangs without ever coming back. Any way to give you more information to help you fix this problem?

Collaborator

mhoran commented Nov 12, 2012

Could you provide us with a failing scenario, including fixture HTML? I tried reproducing this bug but was unsuccessful.

rmehner commented Nov 19, 2012

@mhoran will try, but currently this is deep down within the app. Will try to extract it to a rails sample app that reproduces the error. Fun weekend project.

It does not seem to be related to the timeout handling: We had the problem, then we never ran into a timeout with a JS file that couldn't be loaded. Timeout didn't fire causing capybara-webkit to hang. But this is a different issue.

@willrjmarshall I think this is no longer issue. Current capybara-webkit version waits till the expectations are met unless capybara timeout is not reached.

Can someone confirm this is no longer an issue?

I'll close this issue due to inactivity. Please re-open it if you're still experiencing these issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment