I have an e2e protractor test in my angular application. I've just run the exact same test several times in a row and it passed about 5% of the time, failing with the error in the screenshot below.
The Test:
it('should open the cart with the cart button in the header', () => {
page.navigateTo('/calendar/day/(dmy:27-9-2018)');
page.cartButton().click();
expect(element(by.css('h2.cart-header')).isPresent()).toBe(true);
});
The chrome instance launched by protractor pauses shows that the button was clicked and the h2 element is present (see image at bottom).
What I have tried
- I have replaced the data in this component with mock data to eliminate async operations
- I have animations disabled
- I attempted to make this an async function:
... header', async () => { ... - I have tried await(ing) the element:
expect(await element(by.css('h2.cart... - I have tried to
browser.sleep(1000) - I have tried a variety of assertions like
.toBe(true),.toEqual(true), and.toBeTruthy()
What is causing this error, and how can I resolve it?
The element is present in the browser launched by protractor

