Giter Club home page Giter Club logo

Comments (16)

ngauthier avatar ngauthier commented on September 24, 2024

Have you tried using page.has_content to ensure the modal window is there? Methods like that in capybara auto-retry if they come back false. It's a nice way of saying "sleep until this is true". It times out after a second.

Also, in Akephalos, they synchronize javascript because it's in HTML/Unit. You can also try setting jquery's async to false when you're in test mode (not ideal, but possible short-term solution).

-Nick

from capybara-webkit.

jemmyw avatar jemmyw commented on September 24, 2024

shouldn't def wait? in Capybara::Driver::Webkit be set to return true in order to tell capybara it needs to wait (and auto retry)? I changed it on mine and it started passing AJAX features that would otherwise fail.

from capybara-webkit.

jferris avatar jferris commented on September 24, 2024

It does seem like that wait should be set to true. Can you come up with a failing spec to force that?

from capybara-webkit.

jferris avatar jferris commented on September 24, 2024

This is fixed in 0.1.6.

from capybara-webkit.

otaviomedeiros avatar otaviomedeiros commented on September 24, 2024

This is happening with me. Only works if i use sleep 1.
Is there something better i can do?

My Gemfile

gem 'cucumber'
gem 'capybara'
gem 'capybara-webkit'

versions

capybara-webkit (0.5.0)
capybara (0.4.1.2)

from capybara-webkit.

ngauthier avatar ngauthier commented on September 24, 2024

@otaviomedeiros best thing to do is this sort of pattern:

click_button 'Do Stuff'
wait_until { page.has_content? "Stuff has completed!" }
assert things_on_page

Throwing in a wait_until based on the behavior of your code is the best and most reliable way to wait for something to finish.

from capybara-webkit.

otaviomedeiros avatar otaviomedeiros commented on September 24, 2024

It's working now.
Thanks a lot!

from capybara-webkit.

joemsak avatar joemsak commented on September 24, 2024

I get a Capybara::TimeoutError when I use "wait_until" -- I know 100% that the code works in the browser via localhost:3000

from capybara-webkit.

joemsak avatar joemsak commented on September 24, 2024

Here is a gist of all relevant code https://gist.github.com/d82b8d110c54c455069b

from capybara-webkit.

joemsak avatar joemsak commented on September 24, 2024

It fails here: https://gist.github.com/d82b8d110c54c455069b#file_test.rb at line 28:

Failure/Error: within('#product_0000000000004758') do
Capybara::ElementNotFound:
Unable to find '#product_0000000000004758'
# ./spec/requests/ads_spec.rb:28:in `block (3 levels) in <top (required)>'

Where it totally works in the browser (when I try "wait_until { page.has_content? 'Content' }" it times out, as noted

=== sorry for several double post ===

from capybara-webkit.

otaviomedeiros avatar otaviomedeiros commented on September 24, 2024

Have you sure that "choose 'Test CPC Product'" is sending the ajax request? The choose method is used with radio buttons. If 'Test CPC Product' was already selected before "choose 'Test CPC Product'", the ajax request won't be send.

from capybara-webkit.

joemsak avatar joemsak commented on September 24, 2024

It is not chosen on the page by default and the JS is supposed to fire on
the "change" trigger, so that... /should/ do it

That's exactly how it works in the browser...

By the way, when I do this:

choose 'Test CPC Product'
save_and_open_page

the radio button is empty... but I've seen that behavior before with
passing tests

On Tue, Jan 3, 2012 at 1:05 PM, otaviomedeiros <
[email protected]

wrote:

Have you sure that "choose 'Test CPC Product'" is sending the ajax
request? The choose method is used with radio buttons. If 'Test CPC
Product' was already selected before "choose 'Test CPC Product'", the ajax
request won't be send.


Reply to this email directly or view it on GitHub:
#7 (comment)

from capybara-webkit.

joemsak avatar joemsak commented on September 24, 2024

Tailing the test log, I confirm that the javascript doesn't trigger. At least, the GET /product_fields/:id does not appear when I expect it to

from capybara-webkit.

joemsak avatar joemsak commented on September 24, 2024

Ugh. I suck. I had 0.5.0 instead of 0.7.2 ----- Ignore me. >_<

from capybara-webkit.

taelor avatar taelor commented on September 24, 2024

What if you aren't making anything appear, but instead, just getting some json back and filling it into a text_area. How can you make that ajax process wait?

from capybara-webkit.

jferris avatar jferris commented on September 24, 2024

@taelor if you use have_css or have_xpath to check the contents of a textarea element, capybara will automatically wait and retry for a while to make sure the request is finished.

page.should have_css('textarea#comments', text: 'Hello')

from capybara-webkit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.