Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Capybara::Session with akephalos driver it should behave like session with javascript support all JS specs Node#reload #8

Open
Nerian opened this Issue · 5 comments

2 participants

@Nerian
Owner

https://github.com/jnicklas/capybara/blob/master/lib/capybara/spec/session/javascript.rb#L52

5) Capybara::Session with akephalos driver it should behave like session with javascript support all JS specs Node#reload with automatic reload should reload the current context of the node automatically
   Failure/Error: node.text.should == 'RELOADED'
     expected: "RELOADED"
          got: "waiting to be reloaded" (using ==)


6) Capybara::Session with akephalos driver it should behave like session with javascript support all JS specs Node#reload with automatic reload should reload a parent node automatically
   Failure/Error: node.text.should == 'RELOADED'
     expected: "RELOADED"
          got: "waiting to be reloaded" (using ==)


7) Capybara::Session with akephalos driver it should behave like session with javascript support all JS specs Node#reload with automatic reload should reload a node automatically when using find
   Failure/Error: node.find(:css, 'a').text.should == 'RELOADED'
   Capybara::ElementNotFound:
     Unable to find css "a"
@rb2k

Just to add a little bit more info:
The general idea of the test isn't actually a site reload (aka "F5") but basically to trigger this javascript code when clicking on an 'a' element:

$('#reload-link').click(function() {
setTimeout(function() {
  $('#reload-me').replaceWith('<div id="reload-me"><em><a>RELOADED</a></em>$
}, 250) 
});

While akephalos goes to the site and finds the element, the javascript doesn't seem to be triggered. At least the #reload-me div doesn't get replaced

@rb2k

Just giving it a try and doing this:

clicknode = @session.find('//a[@id="reload-link"]')
clicknode.native.fire_event("click")

Didn't work either

@Nerian
Owner

Mmmm, I wonder where is '/with_js' defined.

It is not here:
https://github.com/jnicklas/capybara/blob/master/lib/capybara/spec/test_app.rb

@Nerian
Owner

Actually the page is doing all that JS stuff. The problem is that the node instance that we have in the test is not being reloaded.

it "should reload the current context of the node automatically" do
  @session.visit('/with_js')
  node = @session.find(:css, '#reload-me')   <-------- We get a reference to a node      
  @session.click_link('Reload!')          <-------- We change that node
  sleep(0.3)
  node.text.should == 'RELOADED'     <-------- But those changes are not being reflected upon this particular instance
end

This test do pass:

it "should reload the current context of the node" do
  @session.visit('/with_js')
  node = @session.find(:css, '#reload-me')
  @session.click_link('Reload!')
  sleep(0.3)
  node.reload.text.should == 'RELOADED'
  node.text.should == 'RELOADED'
end

And this too:

it "should reload the current context of the node automatically" do
  @session.visit('/with_js')
  node = @session.find(:css, '#reload-me')      
  @session.click_link('Reload!')
  sleep(0.3)
  node = @session.find(:css, '#reload-me')
  node.text.should == 'RELOADED'
end

So the question is, how the **** reload that node :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.