Cucumber (rails 2) 未加载 jQuery
我有一个标有 @javascript
的黄瓜场景,我正在使用一些非常基本的内联 js 调用来测试它。我正在使用
Capybara.javascript_driver = :webkit
运行此操作如果我在页面上执行此操作,则在有问题的元素(具有 id="ajax_test_results",但现在不用担心 ajax)
document.getElementById('ajax_test_results').innerHTML = 'Replaced with basic js, ie not jquery, without waiting for pageLoad';
之后,它会起作用:如果我在测试中渲染页面,我可以看到 js 已运行并更新了内容。但是,如果我尝试用 jquery 做同样的事情
jQuery("#ajax_test_results").html("updated with basic jquery dom manipulation, without waiting for document.ready");
,那么它就不起作用。我认为 jquery 没有被加载,但我不知道如何调试它。
有人有什么想法吗?我看到这篇文章看起来很有希望 https://stackoverflow.com/questions /8428405/cucumber-tests-jquery-does-not-loaded-in-webdriver 但 config.assets.debug = true
导致错误对我来说 - 我认为这只是 Rails 3 。有 Rails 2 的等效版本吗?或者其他解决方案?
感谢您的任何建议 - 最大
I have a cucumber scenario tagged with @javascript
and i'm testing it with some really basic inline js calls. I'm running this using
Capybara.javascript_driver = :webkit
If i do this on the page, after the element in question (which has id="ajax_test_results", don't worry about the ajax though, for now)
document.getElementById('ajax_test_results').innerHTML = 'Replaced with basic js, ie not jquery, without waiting for pageLoad';
then it works: if i render out the page in my test i can see that the js has run and updated the content. However, if i try to do the same thing with jquery
jQuery("#ajax_test_results").html("updated with basic jquery dom manipulation, without waiting for document.ready");
then it doesn't work. I think that jquery isn't being loaded, but i don't know how to go about debugging it.
Any ideas anyone? I saw this post which looked hopeful https://stackoverflow.com/questions/8428405/cucumber-tests-jquery-does-not-loaded-in-webdriver but config.assets.debug = true
causes an error for me - i think it's rails 3 only. Is there a rails 2 equivalent? or some other solution?
Grateful for any advice - max
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了进行调试,您可以使用 console.log('message') 或警报语句。它将把您的消息输出到终端屏幕。您也可以使用:
然后您可以使用 page.evaluate_script 或 page.execute_script 方法进行调试。这很容易做到。
根据 jquery 问题,你可以尝试使用 $ 而不是 jQuery 吗?
亚历克斯.
For debugging you can use console.log('message') or alert statements. It will output your messages to the terminal screen. Also you can use:
then you can debug using page.evaluate_script or page.execute_script methods. It's quite easy to do it.
According jquery problem could you try to use $ instead of jQuery?
Alex.