From 690838ce5b751dbdf63c8dd420200106c9959006 Mon Sep 17 00:00:00 2001 From: Yuan Gao Date: Tue, 14 Feb 2017 15:54:54 -0800 Subject: [PATCH] Make screenshot test more stable by waiting for ripple animation to finish --- e2e/components/button/button.e2e.ts | 12 ++++++++---- e2e/components/checkbox/checkbox.e2e.ts | 20 ++++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/e2e/components/button/button.e2e.ts b/e2e/components/button/button.e2e.ts index dd183358e118..2e96c4bbd9c3 100644 --- a/e2e/components/button/button.e2e.ts +++ b/e2e/components/button/button.e2e.ts @@ -1,4 +1,4 @@ -import {browser, by, element} from 'protractor'; +import {browser, by, element, ExpectedConditions} from 'protractor'; import {screenshot} from '../../screenshot'; @@ -9,12 +9,16 @@ describe('button', () => { it('should prevent click handlers from executing when disabled', () => { element(by.id('test-button')).click(); expect(element(by.id('click-counter')).getText()).toEqual('1'); - screenshot('clicked once'); + browser.wait(ExpectedConditions.not( + ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element'))))) + .then(() => screenshot('clicked once')); element(by.id('disable-toggle')).click(); element(by.id('test-button')).click(); expect(element(by.id('click-counter')).getText()).toEqual('1'); - screenshot('click disabled'); + browser.wait(ExpectedConditions.not( + ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element'))))) + .then(() => screenshot('click disabled')); }); }); -}); +}); \ No newline at end of file diff --git a/e2e/components/checkbox/checkbox.e2e.ts b/e2e/components/checkbox/checkbox.e2e.ts index b6b1a255b4a1..a4f71c116049 100644 --- a/e2e/components/checkbox/checkbox.e2e.ts +++ b/e2e/components/checkbox/checkbox.e2e.ts @@ -1,4 +1,4 @@ -import {browser, by, element, Key} from 'protractor'; +import {browser, by, element, Key, ExpectedConditions} from 'protractor'; import {screenshot} from '../../screenshot'; describe('checkbox', function () { @@ -17,14 +17,18 @@ describe('checkbox', function () { checkboxEl.click(); inputEl.getAttribute('checked').then((value: string) => { expect(value).toBeTruthy('Expect checkbox "checked" property to be true'); + browser.wait(ExpectedConditions.not( + ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element'))))) + .then(() => screenshot('checked')); }); - screenshot('checked'); checkboxEl.click(); inputEl.getAttribute('checked').then((value: string) => { expect(value).toBeFalsy('Expect checkbox "checked" property to be false'); + browser.wait(ExpectedConditions.not( + ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element'))))) + .then(() => screenshot('unchecked')); }); - screenshot('unchecked'); }); it('should toggle the checkbox when pressing space', () => { @@ -32,16 +36,20 @@ describe('checkbox', function () { inputEl.getAttribute('checked').then((value: string) => { expect(value).toBeFalsy('Expect checkbox "checked" property to be false'); - screenshot('start'); + browser.wait(ExpectedConditions.not( + ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element'))))) + .then(() => screenshot('start')); }); inputEl.sendKeys(Key.SPACE); inputEl.getAttribute('checked').then((value: string) => { expect(value).toBeTruthy('Expect checkbox "checked" property to be true'); - screenshot('pressed space'); + browser.wait(ExpectedConditions.not( + ExpectedConditions.presenceOf(element(by.css('div.mat-ripple-element'))))) + .then(() => screenshot('pressed space')); }); }); }); -}); +}); \ No newline at end of file