Skip to content

Commit

Permalink
[TS_SELENIUM] Increase logging of tests steps (#14686)
Browse files Browse the repository at this point in the history
Signed-off-by: Ihor Okhrimenko <iokhrime@redhat.com>
  • Loading branch information
Ohrimenko1988 committed Sep 27, 2019
1 parent c51519e commit 0c68ea2
Show file tree
Hide file tree
Showing 22 changed files with 450 additions and 59 deletions.
25 changes: 23 additions & 2 deletions e2e/pageobjects/dashboard/Dashboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { By } from 'selenium-webdriver';
import { DriverHelper } from '../../utils/DriverHelper';
import { TestConstants } from '../../TestConstants';
import { Workspaces } from './Workspaces';
import { Logger } from '../../utils/Logger';

@injectable()
export class Dashboard {
Expand All @@ -27,6 +28,8 @@ export class Dashboard {
@inject(CLASSES.Workspaces) private readonly workspaces: Workspaces) { }

async stopWorkspaceByUI(workspaceName: string) {
Logger.debug(`Dashboard.stopWorkspaceByUI "${workspaceName}"`);

await this.openDashboard();
await this.clickWorkspacesButton();
await this.workspaces.waitPage();
Expand All @@ -37,6 +40,8 @@ export class Dashboard {
}

async deleteWorkspaceByUI(workspaceName: string) {
Logger.debug(`Dashboard.deleteWorkspaceByUI "${workspaceName}"`);

await this.openDashboard();
await this.clickWorkspacesButton();
await this.workspaces.waitPage();
Expand All @@ -49,39 +54,55 @@ export class Dashboard {
}

async openDashboard() {
await this.driverHelper.getDriver().navigate().to(TestConstants.TS_SELENIUM_BASE_URL);
await this.waitPage();
Logger.debug('Dashboard.openDashboard');

await this.driverHelper.getDriver().navigate().to(TestConstants.TS_SELENIUM_BASE_URL);
await this.waitPage();

}

async waitPage(timeout: number = TestConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) {
Logger.debug('Dashboard.waitPage');

await this.driverHelper.waitVisibility(By.css(Dashboard.DASHBOARD_BUTTON_CSS), timeout);
await this.driverHelper.waitVisibility(By.css(Dashboard.WORKSPACES_BUTTON_CSS), timeout);
await this.driverHelper.waitVisibility(By.css(Dashboard.STACKS_BUTTON_CSS), timeout);
await this.driverHelper.waitVisibility(By.css(Dashboard.FACTORIES_BUTTON_CSS), timeout);
}

async clickDashboardButton(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('Dashboard.clickDashboardButton');

await this.driverHelper.waitAndClick(By.css(Dashboard.DASHBOARD_BUTTON_CSS), timeout);
}

async clickWorkspacesButton(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('Dashboard.clickWorkspacesButton');

await this.driverHelper.waitAndClick(By.css(Dashboard.WORKSPACES_BUTTON_CSS), timeout);
}

async clickStacksdButton(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('Dashboard.clickStacksdButton');

await this.driverHelper.waitAndClick(By.css(Dashboard.STACKS_BUTTON_CSS), timeout);
}

async clickFactoriesButton(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('Dashboard.clickFactoriesButton');

await this.driverHelper.waitAndClick(By.css(Dashboard.FACTORIES_BUTTON_CSS), timeout);
}

async waitLoader(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('Dashboard.waitLoader');

await this.driverHelper.waitVisibility(By.css(Dashboard.LOADER_PAGE_CSS), timeout);
}

async waitLoaderDisappearance(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('Dashboard.waitLoaderDisappearance');

await this.driverHelper.waitDisappearance(By.css(Dashboard.LOADER_PAGE_CSS), timeout);
}

Expand Down
45 changes: 45 additions & 0 deletions e2e/pageobjects/dashboard/NewWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { Dashboard } from './Dashboard';
import { Workspaces } from './Workspaces';
import { WorkspaceDetails } from './workspace-details/WorkspaceDetails';
import { ITestWorkspaceUtil, Ide, WorkspaceStatus } from '../..';
import { Logger } from '../../utils/Logger';


@injectable()
Expand All @@ -40,6 +41,8 @@ export class NewWorkspace {
@inject(CLASSES.WorkspaceDetails) private readonly workspaceDetails: WorkspaceDetails) { }

async createAndRunWorkspace(namespace: string, workspaceName: string, dataStackId: string) {
Logger.debug(`NewWorkspace.createAndRunWorkspace "${namespace}/${workspaceName}" stackID: "${dataStackId}"`);

await this.prepareWorkspace(workspaceName, dataStackId);
await this.clickOnCreateAndOpenButton();

Expand All @@ -49,45 +52,61 @@ export class NewWorkspace {
}

async waitPageAbsence(timeout: number = TestConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) {
Logger.debug('NewWorkspace.waitPageAbsence');

await this.driverHelper.waitDisappearanceWithTimeout(By.css(NewWorkspace.NAME_FIELD_CSS), timeout);
await this.driverHelper.waitDisappearanceWithTimeout(By.css(NewWorkspace.TITLE_CSS), timeout);
}

async createWorkspaceAndProceedEditing(workspaceName: string, dataStackId: string) {
Logger.debug(`NewWorkspace.createWorkspaceAndProceedEditing "${workspaceName}" stackID: "${dataStackId}"`);

await this.prepareWorkspace(workspaceName, dataStackId);
await this.selectCreateWorkspaceAndProceedEditing();

await this.workspaceDetails.waitPage(workspaceName);
}

async createAndOpenWorkspace(workspaceName: string, dataStackId: string) {
Logger.debug(`NewWorkspace.createAndOpenWorkspace "${workspaceName}" stackID: "${dataStackId}"`);

await this.prepareWorkspace(workspaceName, dataStackId);
await this.clickOnCreateAndOpenButton();
}

async confirmProjectAdding(sampleName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug(`NewWorkspace.confirmProjectAdding "${sampleName}"`);

await this.clickOnAddButton(timeout);
await this.waitProjectAdding(sampleName, timeout);
}

async waitProjectSourceForm(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('NewWorkspace.waitProjectSourceForm');

await this.driverHelper.waitVisibility(By.css(NewWorkspace.PROJECT_SOURCE_FORM_CSS), timeout);
}

async selectStack(dataStackId: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug(`NewWorkspace.selectStack datastackID: "${dataStackId}"`);

const stackLocator: By = By.css(this.getStackCssLocator(dataStackId));

await this.driverHelper.waitAndClick(stackLocator, timeout);
await this.waitStackSelection(dataStackId, timeout);
}

async waitStackSelection(dataStackId: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug(`NewWorkspace.waitStackSelection datastackID: "${dataStackId}"`);

const selectedStackLocator: By = By.css(this.getSelectedStackCssLocator(dataStackId));

await this.driverHelper.waitAndClick(selectedStackLocator, timeout);
}

async openPageByUI() {
Logger.debug('NewWorkspace.openPageByUI');

await this.dashboard.waitPage();
await this.dashboard.clickWorkspacesButton();
await this.workspaces.clickAddWorkspaceButton();
Expand All @@ -96,16 +115,22 @@ export class NewWorkspace {
}

async waitPage(timeout: number = TestConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) {
Logger.debug('NewWorkspace.waitPage');

await this.driverHelper.waitVisibility(By.css(NewWorkspace.NAME_FIELD_CSS), timeout);
await this.driverHelper.waitVisibility(By.css(NewWorkspace.TITLE_CSS), timeout);
await this.waitLoaderAbsence(timeout);
}

async waitLoaderAbsence(timeout: number = TestConstants.TS_SELENIUM_LOAD_PAGE_TIMEOUT) {
Logger.debug('NewWorkspace.waitLoaderAbsence');

await this.driverHelper.waitPresence(By.css(NewWorkspace.HIDDEN_LOADER_CSS), timeout);
}

async selectCreateWorkspaceAndProceedEditing(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('NewWorkspace.selectCreateWorkspaceAndProceedEditing');

const createAndProceedEditingButtonLocator: By = By.xpath('//span[text()=\'Create & Proceed Editing\']');

// open drop down list
Expand All @@ -116,25 +141,33 @@ export class NewWorkspace {
}

async typeWorkspaceName(workspaceName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug(`NewWorkspace.typeWorkspaceName "${workspaceName}"`);

const workspaceNameFieldLocator: By = By.css(NewWorkspace.NAME_FIELD_CSS);

await this.driverHelper.enterValue(workspaceNameFieldLocator, workspaceName, timeout);
}

async clickOnChe7Stack(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('NewWorkspace.clickOnChe7Stack');

const che7StackLocator: By = By.css(NewWorkspace.CHE_7_STACK_CSS);

await this.driverHelper.waitAndClick(che7StackLocator, timeout);
await this.waitChe7StackSelected(timeout);
}

async waitChe7StackSelected(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('NewWorkspace.waitChe7StackSelected');

const che7SelectedStackLocator: By = By.css(NewWorkspace.SELECTED_CHE_7_STACK_CSS);

await this.driverHelper.waitVisibility(che7SelectedStackLocator, timeout);
}

async clickOnCreateAndOpenButton(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('NewWorkspace.clickOnCreateAndOpenButton');

const ideFrameLocator: By = By.xpath('//ide-iframe[@id=\'ide-iframe-window\' and @aria-hidden=\'false\']');

await this.driverHelper.waitAndClick(By.xpath(NewWorkspace.CREATE_AND_OPEN_BUTTON_XPATH), timeout);
Expand All @@ -144,38 +177,50 @@ export class NewWorkspace {
}

async clickOnAddOrImportProjectButton(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('NewWorkspace.clickOnAddOrImportProjectButton');

const addOrImportProjectButtonLocator: By = By.css(NewWorkspace.ADD_OR_IMPORT_PROJECT_BUTTON_CSS);

await this.driverHelper.waitAndClick(addOrImportProjectButtonLocator, timeout);
await this.waitProjectSourceForm(timeout);
}

async waitSampleCheckboxEnabling(sampleName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug(`NewWorkspace.waitSampleCheckboxEnabling "${sampleName}"`);

const enabledSampleCheckboxLocator: By = By.css(`#sample-${sampleName}>md-checkbox[aria-checked='true']`);

await this.driverHelper.waitVisibility(enabledSampleCheckboxLocator, timeout);
}

async enableSampleCheckbox(sampleName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug(`NewWorkspace.enableSampleCheckbox "${sampleName}"`);

const sampleCheckboxLocator: By = By.xpath(`(//*[@id='sample-${sampleName}']//md-checkbox//div)[1]`);

await this.driverHelper.waitAndClick(sampleCheckboxLocator, timeout);
await this.waitSampleCheckboxEnabling(sampleName, timeout);
}

async waitProjectAdding(projectName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug(`NewWorkspace.waitProjectAdding "${projectName}"`);

const addedProjectLocator: By = By.css(`#project-source-selector toggle-single-button#${projectName}`);

await this.driverHelper.waitVisibility(addedProjectLocator, timeout);
}

async waitProjectAbsence(projectName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug(`NewWorkspace.waitProjectAbsence "${projectName}"`);

const addedProjectLocator: By = By.css(`#project-source-selector toggle-single-button#${projectName}`);

await this.driverHelper.waitDisappearance(addedProjectLocator, timeout);
}

async clickOnAddButton(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('NewWorkspace.clickOnAddButton');

await this.driverHelper.waitAndClick(By.css(NewWorkspace.ADD_BUTTON_CSS), timeout);
}

Expand Down
25 changes: 23 additions & 2 deletions e2e/pageobjects/dashboard/Workspaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { injectable, inject } from 'inversify';
import { DriverHelper } from '../../utils/DriverHelper';
import { CLASSES } from '../../inversify.types';
import { By } from 'selenium-webdriver';
import { Logger } from '../../utils/Logger';


@injectable()
Expand All @@ -22,58 +23,78 @@ export class Workspaces {
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }

async waitPage(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('Workspaces.waitPage');

await this.driverHelper.waitVisibility(By.css(Workspaces.ADD_WORKSPACE_BUTTON_CSS), timeout);
}

async clickAddWorkspaceButton(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug('Workspaces.clickAddWorkspaceButton');

await this.driverHelper.waitAndClick(By.css(Workspaces.ADD_WORKSPACE_BUTTON_CSS), timeout);
}

async waitWorkspaceListItem(workspaceName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug(`Workspaces.waitWorkspaceListItem "${workspaceName}"`);

const workspaceListItemLocator: By = By.css(this.getWorkspaceListItemLocator(workspaceName));

await this.driverHelper.waitVisibility(workspaceListItemLocator, timeout);
}

async clickOnStopWorkspaceButton(workspaceName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
Logger.debug(`Workspaces.clickOnStopWorkspaceButton "${workspaceName}"`);

const stopWorkspaceButtonLocator: By = By.css(`#ws-name-${workspaceName} .workspace-status[uib-tooltip="Stop workspace"]`);

await this.driverHelper.waitAndClick(stopWorkspaceButtonLocator, timeout);
}

async waitWorkspaceWithRunningStatus(workspaceName: string, timeout: number = TestConstants.TS_SELENIUM_START_WORKSPACE_TIMEOUT) {
Logger.debug(`Workspaces.waitWorkspaceWithRunningStatus "${workspaceName}"`);

const runningStatusLocator: By = By.css(this.getWorkspaceStatusCssLocator(workspaceName, 'RUNNING'));

await this.driverHelper.waitVisibility(runningStatusLocator, timeout);
}

async waitWorkspaceWithStoppedStatus(workspaceName: string, timeout: number = TestConstants.TS_SELENIUM_START_WORKSPACE_TIMEOUT) {
Logger.debug(`Workspaces.waitWorkspaceWithStoppedStatus "${workspaceName}"`);

const stoppedStatusLocator: By = By.css(this.getWorkspaceStatusCssLocator(workspaceName, 'STOPPED'));

await this.driverHelper.waitVisibility(stoppedStatusLocator, timeout);
}

async clickWorkspaceListItem(workspaceName: string, timeout: number = TestConstants.TS_SELENIUM_START_WORKSPACE_TIMEOUT) {
var namespace : string = TestConstants.TS_SELENIUM_USERNAME;
Logger.debug(`Workspaces.clickWorkspaceListItem "${workspaceName}"`);

var namespace: string = TestConstants.TS_SELENIUM_USERNAME;
const workspaceListItemLocator: By = By.css(`div[id='ws-full-name-${namespace}/${workspaceName}']`);

await this.driverHelper.waitAndClick(workspaceListItemLocator, timeout);
}

async clickDeleteButtonOnWorkspaceDetails(timeout: number = TestConstants.TS_SELENIUM_START_WORKSPACE_TIMEOUT) {
Logger.debug('Workspaces.clickDeleteButtonOnWorkspaceDetails');

const deleteButtonOnWorkspaceDetailsLocator: By = By.css('che-button-danger[che-button-title=\'Delete\']');

await this.driverHelper.waitAndClick(deleteButtonOnWorkspaceDetailsLocator, timeout);
}

async waitWorkspaceListItemAbcence(workspaceName: string, timeout: number = TestConstants.TS_SELENIUM_START_WORKSPACE_TIMEOUT) {
var namespace : string = TestConstants.TS_SELENIUM_USERNAME;
Logger.debug(`Workspaces.waitWorkspaceListItemAbcence "${workspaceName}"`);

var namespace: string = TestConstants.TS_SELENIUM_USERNAME;
const workspaceListItemLocator: By = By.css(`div[id='ws-full-name-${namespace}/${workspaceName}']`);

await this.driverHelper.waitDisappearance(workspaceListItemLocator, timeout);
}

async clickConfirmDeletionButton(timeout: number = TestConstants.TS_SELENIUM_START_WORKSPACE_TIMEOUT) {
Logger.debug('Workspaces.clickConfirmDeletionButton');

await this.driverHelper.waitAndClick(By.css('#ok-dialog-button'), timeout);
}

Expand Down
Loading

0 comments on commit 0c68ea2

Please sign in to comment.