HTTP请求期间的量角器测试产生不一致的结果

时间:2019-04-26 08:21:35

标签: angular protractor e2e-testing angular-e2e

以下测试产生不一致的结果;有时会通过,有时会失败,并显示以下错误消息:

× Should show progress bar during request
  - Expected false to be true, 'Progress bar must shown during login'.

测试:

it('Should show progress bar during request', () => {
    passwordResetRequestPage.populateForm('john.doe@domain.com');

    // Disable synchronisation to not wait for HTTP call to be complete
    // because the progress bar will be hidden at the end of the HTTP call.
    browser.ignoreSynchronization = true;

    passwordResetRequestPage.getSubmitButton().click();

    expect(passwordResetRequestPage.getProgressBar().isPresent())
        .toBe(true, 'Progress bar must shown during login');

    browser.ignoreSynchronization = false;
});

页面对象中的方法:

getSubmitButton(): ElementFinder {
    return element(by.css('button[type=submit]'));
}

getProgressBar(): ElementFinder {
    return element(by.tagName('mat-progress-bar'));
}

populateForm(email: string) {
    const emailInput = element(by.css('input[formcontrolname=email]'));
    emailInput.clear();
    emailInput.sendKeys(email);

    // Move focus away from inputs
    element(by.tagName('mat-card-title')).click();
}

当我未启用ignoreSynchronization时,测试始终会失败。

我尝试将ExpectedConditions.presenceOfbrowser.wait一起使用,但这会引发No element found using locator错误。

0 个答案:

没有答案