以下测试产生不一致的结果;有时会通过,有时会失败,并显示以下错误消息:
× 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.presenceOf
与browser.wait
一起使用,但这会引发No element found using locator
错误。