A particular test we are conducting involves examining the style changes of a link (a
element) after a mouse over.
Initially, the link is displayed with a black font and no decoration. However, upon hovering the mouse over it, the font color changes to blue and the text becomes underlined. Below is the test in question:
it("should change font style on mouse over", function () {
expect(scope.page.forgotPassword.getCssValue("color")).toEqual("rgba(11, 51, 60, 1)");
expect(scope.page.forgotPassword.getCssValue("text-decoration")).toEqual("none");
browser.actions().mouseMove(scope.page.forgotPassword).perform();
expect(scope.page.forgotPassword.getCssValue("color")).toEqual("rgba(42, 100, 150, 1)");
expect(scope.page.forgotPassword.getCssValue("text-decoration")).toEqual("underline");
});
The issue arises when approximately 1 out of 10 runs fail due to the following error messages:
Expected 'rgba(11, 51, 60, 1)' to equal 'rgba(42, 100, 150, 1)'.
Expected 'none' to equal 'underline'.
My suspicion is that the test reads the css styles before they have had a chance to change.
How can I enhance the reliability and stability of this test? Any assistance would be greatly appreciated.