开发者

Capybara/Selenium/Cucumber is not running javascript on document ready

I'm trying to write some integration tests for my Rails app using Cucumber, with Capybara. The main page of my application, however,d oes not load with any data in it - as soon as the page is loaded, it triggers a javascript that retrieves the data to insert into the page:

jQuery(docume开发者_运维问答nt).ready(function() {
  pullUpdates();
});

The pullUpdates function lives in my application.js file.

Now, the trick is, if I simply run the application, this works fine. When I run cucumber, it opens the page in Firefox via selenium, but the data never loads. I tried extending the timeout first, so it waits a good thirty seconds now for the data to load - it never does. In fact, I've gone in and looked at the server log, and my javascript never seems to be even making the ajax call.

I found the capybara-firebug gem, next, thinking that perhaps I could just look and see what was happening in javascript on the client side - but it doesn't open firefox when the page opens, so it doesn't catch any of those javascript errors int he first place. I opened the Error console in firefox itself, nad I think htere is errors, but I cannot read them, because they are immediately eaten by selenium's attempts to check if the object it's looking for has shown up yet.

I imagine this is something simple, stupid, and my fault. But, I don't see how to diagnose it - its not hitting the server, the problem is on the client side somewhere. Can I force Capybara to leave the page open after it errors out, so that I can go back and read the error logs? Is there a better way to troubleshoot this?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜