Create "Get Started" page object in E2E typescript selenium tests (#16213)
Signed-off-by: Ihor Okhrimenko <iokhrime@redhat.com>7.20.x
parent
0d51cb4bd2
commit
f3d5a89bd0
|
|
@ -54,6 +54,7 @@ import { ITokenHandler } from './utils/requestHandlers/tokens/ITokenHandler';
|
|||
import { CheApiRequestHandler } from './utils/requestHandlers/CheApiRequestHandler';
|
||||
import { CheGitApi } from './utils/VCS/CheGitApi';
|
||||
import { GitHubUtil } from './utils/VCS/github/GitHubUtil';
|
||||
import { GetStarted } from './pageobjects/dashboard/GetStarted';
|
||||
|
||||
const e2eContainer: Container = new Container({ defaultScope: 'Transient' });
|
||||
|
||||
|
|
@ -105,5 +106,6 @@ e2eContainer.bind<PreferencesHandler>(CLASSES.PreferencesHandler).to(Preferences
|
|||
e2eContainer.bind<CheApiRequestHandler>(CLASSES.CheApiRequestHandler).to(CheApiRequestHandler);
|
||||
e2eContainer.bind<CheGitApi>(CLASSES.CheGitApi).to(CheGitApi);
|
||||
e2eContainer.bind<GitHubUtil>(CLASSES.GitHubUtil).to(GitHubUtil);
|
||||
e2eContainer.bind<GetStarted>(CLASSES.GetStarted).to(GetStarted);
|
||||
|
||||
export { e2eContainer };
|
||||
|
|
|
|||
|
|
@ -50,7 +50,8 @@ const CLASSES = {
|
|||
TestWorkspaceUtil: 'TestWorkspaceUtil',
|
||||
NotificationCenter: 'NotificationCenter',
|
||||
PreferencesHandler: 'PreferencesHandler',
|
||||
CheApiRequestHandler: 'CheApiRequestHandler'
|
||||
CheApiRequestHandler: 'CheApiRequestHandler',
|
||||
GetStarted: 'GetStarted'
|
||||
};
|
||||
|
||||
export { TYPES, CLASSES };
|
||||
|
|
|
|||
|
|
@ -0,0 +1,90 @@
|
|||
/*********************************************************************
|
||||
* Copyright (c) 2019 Red Hat, Inc.
|
||||
*
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
**********************************************************************/
|
||||
|
||||
import { injectable, inject } from 'inversify';
|
||||
import { CLASSES } from '../../inversify.types';
|
||||
import { DriverHelper } from '../../utils/DriverHelper';
|
||||
import { TestConstants } from '../../TestConstants';
|
||||
import { By } from 'selenium-webdriver';
|
||||
import { Logger } from '../../utils/Logger';
|
||||
|
||||
@injectable()
|
||||
export class GetStarted {
|
||||
constructor(@inject(CLASSES.DriverHelper) private readonly driverHelper: DriverHelper) { }
|
||||
|
||||
async waitTitleContains(expectedText: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
|
||||
Logger.debug(`GetStarted.waitTitleContains text: "${expectedText}"`);
|
||||
|
||||
const pageTitleLocator: By = By.xpath(`//div[contains(@che-title, '${expectedText}')]`);
|
||||
|
||||
await this.driverHelper.waitVisibility(pageTitleLocator, timeout);
|
||||
}
|
||||
|
||||
async waitPage(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
|
||||
Logger.debug('GetStarted.waitPage');
|
||||
|
||||
await this.waitTitleContains('Getting Started', timeout);
|
||||
}
|
||||
|
||||
async waitSample(sampleName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
|
||||
Logger.debug(`GetStarted.waitSample sampleName: "${sampleName}"`);
|
||||
|
||||
const sampleLocator: By = this.getSampleLocator(sampleName);
|
||||
|
||||
await this.driverHelper.waitVisibility(sampleLocator, timeout);
|
||||
}
|
||||
|
||||
async clickOnSample(sampleName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
|
||||
Logger.debug(`GetStarted.clickOnSample sampleName: "${sampleName}"`);
|
||||
|
||||
const sampleLocator: By = this.getSampleLocator(sampleName);
|
||||
|
||||
await this.driverHelper.waitAndClick(sampleLocator, timeout);
|
||||
}
|
||||
|
||||
async selectSample(sampleName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
|
||||
Logger.debug(`GetStarted.selectSample sampleName: "${sampleName}"`);
|
||||
|
||||
await this.clickOnSample(sampleName, timeout);
|
||||
await this.waitSampleSelected(sampleName, timeout);
|
||||
}
|
||||
|
||||
async waitSampleSelected(sampleName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
|
||||
Logger.debug(`GetStarted.waitSampleSelected sampleName: "${sampleName}"`);
|
||||
|
||||
const selectedSampleLocator: By =
|
||||
By.xpath(`//div[contains(@class, 'get-started-template') and contains(@class, 'selected')]//span[text()='${sampleName}']`);
|
||||
|
||||
await this.driverHelper.waitVisibility(selectedSampleLocator, timeout);
|
||||
}
|
||||
|
||||
async waitSampleUnselected(sampleName: string, timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
|
||||
Logger.debug(`GetStarted.waitSampleUnselected sampleName: "${sampleName}"`);
|
||||
|
||||
const unselectedSampleLocator: By =
|
||||
By.xpath(`//div[contains(@class, 'get-started-template') and not(contains(@class, 'selected'))]//span[text()='${sampleName}']`);
|
||||
|
||||
await this.driverHelper.waitVisibility(unselectedSampleLocator, timeout);
|
||||
}
|
||||
|
||||
async clickCreateAndOpenButton(timeout: number = TestConstants.TS_SELENIUM_DEFAULT_TIMEOUT) {
|
||||
Logger.debug('GetStarted.clickCreateAndOpenButton');
|
||||
const createAndOpenButtonXpath: string = '(//che-button-save-flat[@che-button-title=\'Create & Open\'][@aria-disabled=\'false\']/button)[1]';
|
||||
|
||||
await this.driverHelper.waitAndClick(createAndOpenButtonXpath, timeout);
|
||||
}
|
||||
|
||||
private getSampleLocator(sampleName: string): By {
|
||||
Logger.trace(`GetStarted.getSampleLocator sampleName: ${sampleName}`);
|
||||
|
||||
return By.xpath(`//div[contains(@class, 'get-started-template')]//span[text()='${sampleName}']`);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue