Angularjs 量角器间歇性故障模式关闭试验

Angularjs 量角器间歇性故障模式关闭试验,angularjs,google-chrome,phantomjs,protractor,Angularjs,Google Chrome,Phantomjs,Protractor,我有一系列测试,关闭模态并检查以确保模态消失。它们最初在Chrome中检查,在Chrome中它们间歇性地失败。这里有一个这样的例子(我在其他地方也采用了类似的方法): 模式间歇性超时且从不关闭(这会发出模式从不消失消息)。 稍后在我们的构建管道中,还将使用PhantomJS检查这一点。我试过上面代码的多个版本,其中一个(Chrome/PhantomJS)有问题 我怀疑这可能是某种时间错误的问题,它试图关闭一些尚不存在的东西。无论如何,这将是一次冒险,但这里有一些东西可以尝试: 等待关闭按钮,然

我有一系列测试,关闭模态并检查以确保模态消失。它们最初在Chrome中检查,在Chrome中它们间歇性地失败。这里有一个这样的例子(我在其他地方也采用了类似的方法):

模式间歇性超时且从不关闭(这会发出
模式从不消失
消息)。 稍后在我们的构建管道中,还将使用PhantomJS检查这一点。我试过上面代码的多个版本,其中一个(Chrome/PhantomJS)有问题


我怀疑这可能是某种时间错误的问题,它试图关闭一些尚不存在的东西。

无论如何,这将是一次冒险,但这里有一些东西可以尝试:

  • 等待关闭按钮,然后单击按钮:

    var EC = protractor.ExpectedConditions;
    page.ermAlertBox.click().then(function() { //this just opens the modal
        browser.wait(EC.presenceOf(page.ermModalEl), 30000, 'Modal never appeared');
        browser.executeScript("$('.erm-modal').removeClass('fade');");
    
        browser.wait(EC.elementToBeClickable(page.ermModalCloseBtn), 30000, 'Close button has not become clickable');
        page.ermModalCloseBtn.click().then(function () {
             browser.wait(EC.stalenessOf(page.ermModalEl), 30000, 'Modal never disappeared');
             expect(page.ermModalEl.isPresent()).toBe(false);
         });
    });
    
  • :

  • 检查而不是陈旧性:

    browser.wait(EC.invisibilityOf(page.ermModalEl), 30000, 'Modal never disappeared');
    
  • 在弹出窗口打开后立即引入:

    var EC = protractor.ExpectedConditions;
    page.ermAlertBox.click().then(function() { //this just opens the modal
        browser.sleep(1000);
    
        browser.wait(EC.presenceOf(page.ermModalEl), 30000, 'Modal never appeared');
        browser.executeScript("$('.erm-modal').removeClass('fade');");
    
        page.ermModalCloseBtn.click().then(function () {
             browser.wait(EC.stalenessOf(page.ermModalEl), 30000, 'Modal never disappeared');
             expect(page.ermModalEl.isPresent()).toBe(false);
         });
    });
    
  • 关闭同步并再次打开(如果这是正在测试的角度应用程序):

  • 禁用所有动画:请参见

  • (在您的案例中,问题减少50%)

或者,您可以尝试组合这些建议。

您确定“关闭”单击有效吗?可能是关闭按钮在被点击时没有完全/正确连接,因此没有做任何事情。
browser.wait(EC.invisibilityOf(page.ermModalEl), 30000, 'Modal never disappeared');
var EC = protractor.ExpectedConditions;
page.ermAlertBox.click().then(function() { //this just opens the modal
    browser.sleep(1000);

    browser.wait(EC.presenceOf(page.ermModalEl), 30000, 'Modal never appeared');
    browser.executeScript("$('.erm-modal').removeClass('fade');");

    page.ermModalCloseBtn.click().then(function () {
         browser.wait(EC.stalenessOf(page.ermModalEl), 30000, 'Modal never disappeared');
         expect(page.ermModalEl.isPresent()).toBe(false);
     });
});
var EC = protractor.ExpectedConditions;
browser.ignoreSynchronization = true;

page.ermAlertBox.click().then(function() { //this just opens the modal
    browser.wait(EC.presenceOf(page.ermModalEl), 30000, 'Modal never appeared');
    browser.executeScript("$('.erm-modal').removeClass('fade');");

    page.ermModalCloseBtn.click().then(function () {
         browser.wait(EC.stalenessOf(page.ermModalEl), 30000, 'Modal never disappeared');
         expect(page.ermModalEl.isPresent()).toBe(false);

         browser.ignoreSynchronization = false;
     });
});