From 05dc11a9e2ec3e7f77ac68c55cf673a5f167a1bf Mon Sep 17 00:00:00 2001 From: Igor Ohrimenko Date: Fri, 20 Dec 2019 12:17:21 +0200 Subject: [PATCH] [Happy Path] Check application readiness before opening the link by the "DialogWindow.waitDialogAndOpenLink" method (#15553) * Check application readiness before opening the link by the "DialogWindow.waitDialogAndOpenLink" method Signed-off-by: Ihor Okhrimenko --- tests/e2e/pageobjects/ide/DialogWindow.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/e2e/pageobjects/ide/DialogWindow.ts b/tests/e2e/pageobjects/ide/DialogWindow.ts index 8fa75ed889..1cc419a879 100644 --- a/tests/e2e/pageobjects/ide/DialogWindow.ts +++ b/tests/e2e/pageobjects/ide/DialogWindow.ts @@ -13,13 +13,15 @@ import { DriverHelper } from '../../utils/DriverHelper'; import { By } from 'selenium-webdriver'; import { Logger } from '../../utils/Logger'; import { TestConstants } from '../../TestConstants'; +import { Ide } from './Ide'; @injectable() export class DialogWindow { private static readonly DIALOG_BODY_XPATH_LOCATOR: string = '//div[@id=\'theia-dialog-shell\']//div[@class=\'dialogBlock\']'; private static readonly CLOSE_BUTTON_XPATH_LOCATOR: string = `${DialogWindow.DIALOG_BODY_XPATH_LOCATOR}//button[text()='close']`; - constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { } + constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper, + @inject(CLASSES.Ide) private readonly ide: Ide) { } async dialogDisplayes(): Promise { Logger.debug('DialogWindow.dialogDisplayes'); @@ -73,6 +75,7 @@ export class DialogWindow { Logger.debug('DialogWindow.waitDialogAndOpenLink'); await this.waitDialog(timeout, dialogText); + await this.ide.waitApllicationIsReady(await this.getApplicationUrlFromDialog(dialogText)); await this.clickToOpenLinkButton(); await this.waitDialogDissappearance(); } @@ -83,4 +86,17 @@ export class DialogWindow { await this.driverHelper.waitDisappearanceWithTimeout(By.xpath(DialogWindow.CLOSE_BUTTON_XPATH_LOCATOR)); } + async getApplicationUrlFromDialog(dialogWindowText: string) { + const notificationTextLocator: By = By.xpath(`${DialogWindow.DIALOG_BODY_XPATH_LOCATOR}//span[contains(text(), '${dialogWindowText}')]`); + + let dialogWindow = await this.driverHelper.waitAndGetText(notificationTextLocator); + let regexp: RegExp = new RegExp('^.*(https?://.*)$'); + + if (!regexp.test(dialogWindow)) { + throw new Error('Cannot obtaine url from notification message'); + } + + return dialogWindow.split(regexp)[1]; + } + }