Reputation: 1652
I am testing part of our application which clears the cache for the user. Basically, the user clicks their user menu and then clicks the Clear Cache option. After this, a notification appears indicating that the cache has been cleared.
This option calls this method:
clearCache(): void {
this.Cache.clearAll();
this.localizedNotifications.notify('Cache cleared', 'info');
}
My protractor test is:
it('Click Clear Cache from User Menu', () => {
common.chooseUserMenuClearCache();
let popUpAlert = browser.switchTo().alert();
let alertText = popUpAlert.getText();
expect(alertText).toMatch('Cache cleared');
});
My test is returning that there is no alert open
. This notification displays for a second or two and then disappears on its own. So I am wondering what I can do differently to get this test to pass?
Upvotes: 0
Views: 486
Reputation: 1652
Instead of using browser.switchTo().alert()
I used browser.switchTo().activeElement()
and it worked.
Upvotes: 1