让 Selenium 与 Bootstrap 模态褪色一起玩的建议? [英] Suggestions for getting Selenium to play nice with Bootstrap modal fade?

查看:21
本文介绍了让 Selenium 与 Bootstrap 模态褪色一起玩的建议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力以 BDD 的方式生活.我正在使用 Cucumber(带有 Selenium)并且恰好在我的应用程序中使用 Twitter Bootstrap 模式.

I'm working to live life the BDD way. I'm using Cucumber (with Selenium) and happen to be using Twitter Bootstrap modals in my application.

在运行 Cucumber 测试时,我收到 "Selenium::WebDriver::Error::MoveTargetOutOfBoundsError" 错误.经过大量搜索、调试和普遍绝望后,我得出结论,这与在我的引导模式中使用 "fade" 参数有关.如果我使用 "fade",则会抛出错误:

While running Cucumber tests, I was getting a "Selenium::WebDriver::Error::MoveTargetOutOfBoundsError" error. After much searching, debugging and general despair, I have concluded that it has to do with the use of the "fade" parameter in my Bootstrap modals. If I use "fade", the error is thrown:

<div class="modal hide fade" id="info-share-edit-modal" style="display: none;">
  .
  .
  .
</div>

如果我去掉 "fade",那么 Selenium 就充满了快乐,我的测试也清晰了:

If I remove "fade", then Selenium is full of happiness and my tests clear:

<div class="modal hide" id="info-share-edit-modal" style="display: none;">
  .
  .
  .
</div>

所以,我现在正在从我的各种模式中删除 "fade".但是,这让我很伤心,因为我喜欢淡入淡出效果.

So, I am now removing "fade" from my various modals. But, this makes me sad because I like the fade effect.

有没有其他人在使用 Selenium 和 Bootstrap 模式中的淡入淡出时遇到过问题?如果是这样,是否有一些巧妙的方法可以让两者很好地协同工作?

Has anyone else experienced problems using Selenium with fade in Bootstrap modals? If so, is there some clever way of getting the two to work nicely together?

顺便说一下(不确定是否重要),我是 Rails 3.2.3、Firefox 13.0.1 和 Ubuntu 12.04LTS.

By the way (not sure if it matters), I'm Rails 3.2.3, Firefox 13.0.1, and Ubuntu 12.04LTS.

推荐答案

我做了一个快速测试,插入一个 WebDriverWait 来查看模态的不透明度.它似乎有效,但时间会证明(至少对我而言)这是一个间歇性问题.这是我在 Java 中的实现.

I did a quick test with inserting a WebDriverWait that takes a look at the opacity of the modal. It seems to work, but time will tell as (at least for me) it's an intermittent problem. Here's my implementation in Java.

//Ensure the modal is done animating
new WebDriverWait(driver, 5).until(
    new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver webDriver) {         
            return webDriver.findElement(By.id("videoModal")).getCssValue("opacity").equals("1");
        }
    }
);

这篇关于让 Selenium 与 Bootstrap 模态褪色一起玩的建议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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