2017-09-19 1 views
-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(); 
}); 

答えて

0

分度器5と角度2/4の後、非同期動作が分度器で変更されます。あなたは、あなたのテスト

async login(name: string, pwd: string) { 
    await this.username.sendKeys(name); 
    await this.password.sendKeys(pwd); 
    await this.loginButton.click(); 
    return browser.wait(protractor.ExpectedConditions.not(protractor.ExpectedConditions.urlContains('returnUrl'))); 
} 

を開始する前に、ブラウザに角度負荷まで待た角度伝えるためにasync ANS awaitフォームを使用し、その後、loginメソッドを呼び出している間、あなたはawait login()

を言うべき必要

関連する問題