Dan*_*son 2 javascript twitter-bootstrap angularjs protractor
我正在尝试量角器测试是否当前可以看到确认记录删除的引导模式窗口.
要删除的记录显示在角度ng-repeat中,因此我必须从那里激活删除按钮.
如果我测试isPresent测试总是传递true,因为它在DOM中查找模态窗口,它将始终存在.但是,isDisplayed当我期望为真时,测试总是返回false.
这是一些代码......
// Use the .all repeater to search the array of presented records
element.all(by.repeater('entries in presentData')).then(function(presentData) {
// get the first record and open the options menu
presentData[0].element(by.css('.dropdown-toggle')).click();
// In that first record click the delete button
presentData[0].element(by.css('.delete-link')).click();
browser.waitForAngular();
// Remove the 'fade' class from the Bootstrap modal, I heard animations can cause some issues for testing
browser.executeScript("$('.modal').removeClass('fade');");
// Expect that the .modal-dialog is true
expect(element(by.className('modal-dialog')).isDisplayed()).toBe(true);
});
Run Code Online (Sandbox Code Playgroud)
我已经尝试了各种其他stackoverflow和github问题的各种组合,但到目前为止我没有任何工作.
任何你可能会流下的光都会非常感激!
将评论转化为答案.
如果加上browser.sleep(5000)之前的最后期待的作品则是一个时机的问题,您可能需要合并为活动等待这里说明它包括waitReady.js脚本,加入require('./waitReady.js');你的onPrepare块,然后替换最后一个期望与:
var elm = element(by.className('modal-dialog');
expect(elm.waitReady()).toBeTruthy();
Run Code Online (Sandbox Code Playgroud)
期望将等待元素出现,然后等待它可见.
使用waitReady.js脚本将节省你在这些情况下使用的睡眠.
你可能也会尝试另一个browser.waitForAngular();,browser.executeScript并希望Protractor知道如何等待JS注入.