In one of our tests, we are testing the link (a
element) style changes after a mouse over. By default, the link has a black font without decoration, but on mouse over the font changes to blue and the link text becomes underlined. Here is the relevant test:
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 problem is that in about 1 out of 10 runs, it is failing with the following error messages:
Expected 'rgba(11, 51, 60, 1)' to equal 'rgba(42, 100, 150, 1)'.
Expected 'none' to equal 'underline'.
I suspect that it reads the css styles before they actually change.
What can I do to make the test more reliable and stable? Would appreciate any hints.
Aucun commentaire:
Enregistrer un commentaire