Skip to content

Commit

Permalink
update common_page
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlemeshko committed Apr 4, 2020
1 parent 31f43fd commit faf71ff
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 35 deletions.
37 changes: 4 additions & 33 deletions test/functional/page_objects/common_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,37 +47,6 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
}

class CommonPage {
/**
* Navigates the browser window to provided URL
* @param url URL
* @param shouldAcceptAlert pass 'true' if browser alert should be accepted
*/
private static async navigateToUrlAndHandleAlert(url: string, shouldAcceptAlert: boolean) {
log.debug('Navigate to: ' + url);
try {
await browser.get(url);
} catch (navigationError) {
log.debug('Error navigating to url');
const alert = await browser.getAlert();
if (alert && alert.accept) {
if (shouldAcceptAlert) {
log.debug('Should accept alert');
try {
await alert.accept();
} catch (alertException) {
log.debug('Error accepting alert');
throw alertException;
}
} else {
log.debug('Will not accept alert');
throw navigationError;
}
} else {
throw navigationError;
}
}
}

/**
* Returns Kibana host URL
*/
Expand Down Expand Up @@ -136,7 +105,8 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
} else {
log.debug(`navigateToUrl ${appUrl}`);
await browser.get(appUrl);
// await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert);
const alert = await browser.getAlert();
await alert?.accept();
}

const currentUrl = shouldLoginIfPrompted
Expand Down Expand Up @@ -261,7 +231,8 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
// since we're using hash URLs, always reload first to force re-render
log.debug('navigate to: ' + appUrl);
await browser.get(appUrl);
// await CommonPage.navigateToUrlAndHandleAlert(appUrl, shouldAcceptAlert);
const alert = await browser.getAlert();
await alert?.accept();
await this.sleep(700);
log.debug('returned from get, calling refresh');
await browser.refresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ export default function({ getService, getPageObjects }: PluginFunctionalProvider
expect(await browser.getCurrentUrl()).to.eql(getKibanaUrl('/app/appleave1'));
});
it('allows navigation if user click confirm on the confirmation dialog', async () => {
const alert = await browser.getAlert();
await alert?.accept();
await PageObjects.common.navigateToApp('appleave1');
await appsMenu.clickLink('AppLeave 2');

Expand Down

0 comments on commit faf71ff

Please sign in to comment.