So I have this issue which really driving me crazy. In the Angular app, after I click a save button, there is an toast message. While the toast is displayed, it overlaps the user menu with log out button. Eventually the toast is removed (also from the DOM) and I can log out. The problem is then in the first 'it' block it works good, it waits for the toast to disappear and the it clicks on the menu and log out. But when the second 'it' block runs, basically with the same code, it just brakes and gives the error Failed: element click intercepted: Element class="nav-link user-name" data-toggle="dropdown">...</a> is not clickable at point (1714, 31). Other element would receive the click: <div aria-live="polite" role="alertdialog" class="toast-message...
. Sometimes it even brakes in the first 'it' block.
This is the func I use:
async waitForToastToDisappear() {
let toast = element(by.xpath('//*[@id="toast-container"]/div'));
await browser.wait(ExpectedConditions.invisibilityOf(toast), 10000, 'Toast message did not completely disappear');
I also tried it with stalenessOf
, but it has the same effect.
And this is the actual test
beforeEach(async function() {
await login.loginToApp('sysadmin', 'sysadmin');
afterEach(async function() {
await login.loginOut();
it('should change the date, navigate to screen and add record', async function () {
await calendar.setDefaultTestDate();
await browser.get(screenUrl);
await browser.wait(ExpectedConditions.visibilityOf(firstTab), 10000, 'Tab not fully loaded');
await elem.first().sendKeys('12');
await element(by.css('div.btn.btn-primary.btn-sm')).click();
await page.clickElement(element(by.cssContainingText('.navbar-brand li a', 'Home')));
await page.waitForElement(element(by.css('.main-view')));
await page.waitForToastToDisappear();
It is maybe worth mention, that I also use the browser.waitForAngularEnabled(false);
in the loginToApp
for the login, since the login page is not Angular and I've read that it could result in some test flakiness, but I am not sure...