diff --git a/e2e/src/app.e2e-spec.ts b/e2e/src/app.e2e-spec.ts index b46290b09d..19ccf9b624 100644 --- a/e2e/src/app.e2e-spec.ts +++ b/e2e/src/app.e2e-spec.ts @@ -1,5 +1,5 @@ import { ProtractorPage } from './app.po'; -import { by, element } from 'protractor'; +import { browser, by, element, protractor } from 'protractor'; describe('protractor App', () => { let page: ProtractorPage; @@ -10,16 +10,18 @@ describe('protractor App', () => { it('should display translated title "DSpace Angular :: Home"', () => { page.navigateTo() + .then(() => page.waitUntilNotLoading()) .then(() => { - element(by.css('.main-content')).getAttribute('innerHTML').then((v) => process.stdout.write(v)); expect(page.getPageTitleText()).toEqual('DSpace Angular :: Home'); } - ); + ) + ; }); it('should contain a news section', () => { page.navigateTo() - .then(() => - page.getHomePageNewsText().then((text) => expect(text).toBeDefined())); + .then(() => page.waitUntilNotLoading()) + .then(() => page.getHomePageNewsText()) + .then((text) => expect(text).toBeDefined()); }); }); diff --git a/e2e/src/app.po.ts b/e2e/src/app.po.ts index 2ee9a86201..09a7990a77 100644 --- a/e2e/src/app.po.ts +++ b/e2e/src/app.po.ts @@ -1,4 +1,4 @@ -import { browser, element, by } from 'protractor'; +import { browser, element, by, protractor, promise } from 'protractor'; export class ProtractorPage { navigateTo() { @@ -13,4 +13,11 @@ export class ProtractorPage { getHomePageNewsText() { return element(by.css('ds-home-news')).getText(); } + + waitUntilNotLoading(): promise.Promise { + const loading = element(by.css('.loader')) + const EC = protractor.ExpectedConditions; + const notLoading = EC.not(EC.presenceOf(loading)); + return browser.wait(notLoading, 10000); + } } diff --git a/e2e/src/search-page/search-page.e2e-spec.ts b/e2e/src/search-page/search-page.e2e-spec.ts index 7e75f52b3b..09d6991df6 100644 --- a/e2e/src/search-page/search-page.e2e-spec.ts +++ b/e2e/src/search-page/search-page.e2e-spec.ts @@ -23,6 +23,7 @@ describe('protractor SearchPage', () => { .then(() => page.getRandomScopeOption()) .then((scopeString: string) => { page.navigateToSearchWithScopeParameter(scopeString) + .then(() => page.waitUntilNotLoading()) .then(() => page.getCurrentScope()) .then((s: string) => { expect(s).toEqual(scopeString); @@ -36,6 +37,7 @@ describe('protractor SearchPage', () => { .then((scopeString: string) => { page.setCurrentScope(scopeString) .then(() => page.submitSearchForm()) + .then(() => page.waitUntilNotLoading()) .then(() => () => { browser.wait(() => { return browser.getCurrentUrl().then((url: string) => { diff --git a/e2e/src/search-page/search-page.po.ts b/e2e/src/search-page/search-page.po.ts index 819e0ab96f..83a66a848b 100644 --- a/e2e/src/search-page/search-page.po.ts +++ b/e2e/src/search-page/search-page.po.ts @@ -46,4 +46,10 @@ export class ProtractorPage { }); } + waitUntilNotLoading(): promise.Promise { + const loading = element(by.css('.loader')); + const EC = protractor.ExpectedConditions; + const notLoading = EC.not(EC.presenceOf(loading)); + return browser.wait(notLoading, 10000); + } }