Suggestions for getting Selenium to play nice with Bootstrap modal fade?

后端 未结 7 1278
[愿得一人]
[愿得一人] 2021-02-05 19:45

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.

While running Cucumber tes

7条回答
  •  南旧
    南旧 (楼主)
    2021-02-05 20:00

    Improving on user1965252's answer, this worked for me. Just replace the-modal-id with your modal div id.

    new WebDriverWait(driver, TIME_OUT_IN_SECONDS).until(and(
            new ExpectedCondition() {
               @Override
               public Boolean apply(WebDriver webDriver) {
                   return webDriver.findElement(id("the-modal-id"))
                           .getCssValue("opacity").equals("0");
               }
            },
            numberOfElementsToBe(cssSelector("div.modal-backdrop"), 0)
    ));
    

提交回复
热议问题