关闭在水豚测试动画 [英] Turn off animations in Capybara tests

查看:125
本文介绍了关闭在水豚测试动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多的动画我的网页,这确实减慢我的水豚测试,因为水豚往往要等到元素被动画的,因为它开始时隐藏的。

I have a lot of animations on my page, which really slows down my tests in capybara because capybara often have to wait until a element has been animated, as it starts out hidden.

我发现这个解决方案对所有基于jQuery的动画:

I found this solution for all jQuery based animations:


<%= javascript_tag'$ .fx.off = TRUE;'如果Rails.env.test? %GT;

不过我使用引导Twitter的引导,最动画是由CSS 3发(用JavaScript后备)。所以我的问题是,有没有办法把CSS 3切换和动画在测试中?

However i use twitter bootstrap and most animations from bootstrap is made by CSS 3 (with javascript fallback). So my question is, is there a way to turn of CSS 3 transitions and animations in tests?

推荐答案

您可以尝试创造一些过渡复位,并将其应用于特定的元素。

You can try to create some transition reset and apply it on a specific element.

.reset-transition {
    -webkit-transition: none;
    -moz-transition: none;
    -ms-transition: none;
    -o-transition: none;
    transition: none;
}

您还可以将其适用于所有并把引导后,这个CSS

You can also apply it to ALL and place this css after Bootstrap

* {
    -webkit-transition: none;
    -moz-transition: none;
    -ms-transition: none;
    -o-transition: none;
    transition: none;
}

您可以使其更加具体。

div, a, span, footer, header {
    -webkit-transition: none;
    -moz-transition: none;
    -ms-transition: none;
    -o-transition: none;
    transition: none;
}

这篇关于关闭在水豚测试动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆