-1
問題があります。 app.e2e-spec.tsでは、ログインページに移動します。ファイルには、それが呼び出すメソッド があります。サインインボタンをクリックすると、ダッシュボードページのタイトルが返されます。ログインが失敗したかのように。しかし、彼はメッセージを取得します:このページロケータ分度器が見つかりません
should be able to login
- Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds. This may be because the current page is not an Angular application. Please see the FAQ for more details: https://github.com/angular/protractor/blob/master/docs/timeouts.md#waiting-for-angular
While waiting for element with locator - Locator: By(css selector, h2)
要素は次のようになります。
<h2 _ngcontent-c5 = ""> Dashboard API </h2>
app.e2e-spec.ts
it('should show login page',() => {
page.navigateToHome();
page.maximizeWindow();
expect(page.getLoginBoxTitle()).toEqual('Sign In');
});
it('should be able to login',() => {
page.navigateToHome();
page.login();
expect(page.getPageTitle()).toEqual('Dashboard API');
page.navigateToDashboard();
});
app.po.ts
login() {
element(by.name('username')).sendKeys('[email protected]');
element(by.name('password')).sendKeys('test123');
element(by.buttonText('SignIn')).click();
}
loginIfNotLoggedIn() {
if (element.all(by.css('.login-box')).length > 0) {
this.login();
} else {
console.info('Already logged in');
}
}
getLoginBoxTitle() {
return element(by.css('h2')).getText();
}
getPageTitle() {
return element
.all(by.css('h2'))
.last()
.getText();
}
ダッシュボード.e2e-spec.ts
it('should get api status',() => {
login.browserSleep();
page.navigateToDashboard();
login.loginIfNotLoggedIn();
page.getStatusAPI();
page.navigateToApplications();
});