这个令人困惑。我有两个测试几乎完全相同的设置,其中一个运行完成,另一个等待量角器与页面同步。我已经知道设置browser.ignoreSynchronization
了。我的登录页面没有变形,所以我在之前将其关闭登录并在之后将其重新打开我已成功导航到第一个角度页面,如您所见在我的登录功能中:
public login(username: string, password: string, wait = true): Promise<void> {
util.isAngularSite(false); //turning it off here
this.go(); //gets login page
this.userNameInput.sendKeys(username);
this.passwordInput.sendKeys(password);
this.loginButton.click();
if (wait) {
return NewUserListPage.waitForPageLoad().then(() => {
return util.isAngularSite(true); //turning it back on here
});
} else {
return promise.fulfilled<void>();
}
}
而util.isAngularSite()
可能会更好,但就像这样:
isAngularSite(flag: boolean): Promise<void> {
browser.ignoreSynchronization = !flag;
return promise.fulfilled<void>();
}
除了一个函数调用之外,我的两个测试中的设置实际上是相同的。我知道这两个测试中显而易见的罪魁祸首似乎是差异,但我很难相信其他事情还没有发生。我无法弄清楚为什么一个人会等待角度超时,另一个工作得很好。想知道之前遇到过这种情况的人是否有解决方案(我不可能是唯一的解决方案)?这两个测试都是beforeAll()
。
这个给了我错误Failed: Timed out waiting for Protractor to synchronize with the page after 11 seconds.
//all the imports are exactly the same
import AllTheThings from "..."
describe("some tests", () => {
const adminUsername = browser.params.testdomain.username;
const password = browser.params.testdomain.password;
const domain = browser.params.testdomain.domain;
const servicesToAdd = [ServiceType.SomeTestServiceType];
let newUserName: string;
let newUserEmail: string;
beforeAll(() => {
LoginPage.login(adminUsername, password);
//add new user
NewUserListPage.selectAddUser();
UserAddPage.addNewRandomUser(false, false, false, servicesToAdd)
.then((name: string) => {
newUserName = name;
newUserEmail = util.generateEmailAddress(newUserName, domain);
});
NewUserListPage.waitForPageLoad();
});
这个成功了:
//all the imports are exactly the same
import AllTheThings from "..."
describe("some other tests", () => {
const adminUsername = browser.params.testdomain.username;
const password = browser.params.testdomain.password;
const domain = browser.params.someOtherDomainName;
const servicesToAdd = [ServiceType.SomeOtherServiceType];
let newUserName: string;
let newUserEmail: string;
beforeAll(() => {
LoginPage.login(adminUsername, password);
//add new user
NewUserListPage.selectAddUser();
UserAddPage.addUserToSpecificDomain(domain, false, false, false, servicesToAdd)
.then((name: string) => {
newUserName = name;
newUserEmail = util.generateEmailAddress(newUserName, domain);
});
NewUserListPage.waitForPageLoad();
});
stacktrace说它超时了While waiting for element with locator - Locator: By(link text, Add User)
这是我的添加用户按钮。在NewUserListPage.selectAddUser()
功能中单击此按钮。为什么一次测试而不是另一次测试超时?它也是一致的,同样的测试总是失败并且成功。有什么想法吗?