angularjs - 让 Protractor 等到 UI Bootstrap 模态框消失(使用 cucumber js)

标签 angularjs twitter-bootstrap modal-dialog protractor cucumberjs

我有一个页面显示来自 UI Bootstrap 的模式框。我的 Protractor 测试然后单击模式中的一个按钮将其关闭,然后测试单击页面上的另一个按钮。

问题是在模态实际上消失之前没有任何东西等待,所以经常尝试单击页面上的按钮但由于模态背景仍然覆盖页面而失败。

目前我关闭模式的代码如下所示:

@When /^I click button in modal with class "([^"]*)"$/, (className, callback) ->
    element(By.css '.modal-dialog').
        element(By.css 'button.' + className).
        click().
        then(callback)

知道如何在触发回调之前等到模态消失吗?

最佳答案

一个肮脏的把戏,但它对我有用:明确调用 waitForAngular()并删除 fade Bootstrap 模态上的类。这将等待您的 Protractor 指令(例如:单击按钮以显示模态)并删除不需要的淡入淡出效果。

browser.waitForAngular();
browser.executeScript("$('.modal').removeClass('fade');");

关于angularjs - 让 Protractor 等到 UI Bootstrap 模态框消失(使用 cucumber js),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25553057/

相关文章:

javascript - 获取 Angular ngRepeat InnerHTML

javascript - 在 AngularJS 选项卡 View 中设置默认单选/输入/复选框值

angularjs - 从服务获取异步数据

css - 当使用附件固定且边距不起作用时,标题图像位于导航栏后面

html - Bootstrap 导航栏不工作,菜单一直隐藏

javascript - 填充对话框后添加行

html - Internet Explorer、z-index 和 "modality"

angularjs - Angular 自举崩溃的奇怪行为

html - 如何防止文本输入分成多行

javascript - thymeleaf 片段 - 用于确认对话框的 html 模式