Skip to content

Commit

Permalink
[TS_SELENIUM] Implement logic to be able to run tests with provided c…
Browse files Browse the repository at this point in the history
…hromedriver (#14185)


Signed-off-by: Ihor Okhrimenko <[email protected]>
  • Loading branch information
Ohrimenko1988 authored Aug 13, 2019
1 parent 1e03990 commit 4ca00ae
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 13 deletions.
7 changes: 6 additions & 1 deletion e2e/TestConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,5 +147,10 @@ export const TestConstants = {
/**
* Update Channel name on 'Create Operator Subscription' page on OCP, "nightly" or "stable".
*/
TS_OCP_UPDATE_CHANNEL_OPERATOR: process.env.TS_OCP_UPDATE_CHANNEL_OPERATOR || 'nightly'
TS_OCP_UPDATE_CHANNEL_OPERATOR: process.env.TS_OCP_UPDATE_CHANNEL_OPERATOR || 'nightly',

/**
* Remote driver URL.
*/
TS_SELENIUM_REMOTE_DRIVER_URL: process.env.TS_SELENIUM_REMOTE_DRIVER_URL || ''
};
1 change: 1 addition & 0 deletions e2e/driver/CheReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class CheReporter extends mocha.reporters.Spec {
TS_SELENIUM_REPORT_FOLDER: ${TestConstants.TS_SELENIUM_REPORT_FOLDER}
TS_SELENIUM_EXECUTION_SCREENCAST: ${TestConstants.TS_SELENIUM_EXECUTION_SCREENCAST}
DELETE_SCREENCAST_IF_TEST_PASS: ${TestConstants.DELETE_SCREENCAST_IF_TEST_PASS}
TS_SELENIUM_REMOTE_DRIVER_URL: ${TestConstants.TS_SELENIUM_REMOTE_DRIVER_URL}
########################################################
`;
Expand Down
39 changes: 27 additions & 12 deletions e2e/driver/ChromeDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,44 @@ export class ChromeDriver implements IDriver {
private readonly driver: ThenableWebDriver;

constructor() {
const isHeadless: boolean = TestConstants.TS_SELENIUM_HEADLESS;
const options: Options = this.getDriverOptions();
this.driver = this.getDriverBuilder(options).build();

this.driver
.manage()
.window()
.setSize(TestConstants.TS_SELENIUM_RESOLUTION_WIDTH, TestConstants.TS_SELENIUM_RESOLUTION_HEIGHT);
}

get(): ThenableWebDriver {
return this.driver;
}

private getDriverOptions(): Options {
let options: Options = new Options()
.addArguments('--no-sandbox')
.addArguments('--disable-web-security')
.addArguments('--allow-running-insecure-content');

if (isHeadless) {
// if 'true' run in 'headless' mode
if (TestConstants.TS_SELENIUM_HEADLESS) {
options = options.addArguments('headless');
}

this.driver = new Builder()
return options;
}

private getDriverBuilder(options: Options): Builder {
let builder: Builder = new Builder()
.forBrowser('chrome')
.setChromeOptions(options)
.build();
.setChromeOptions(options);

this.driver
.manage()
.window()
.setSize(TestConstants.TS_SELENIUM_RESOLUTION_WIDTH, TestConstants.TS_SELENIUM_RESOLUTION_HEIGHT);
}
// if 'true' run with remote driver
if (TestConstants.TS_SELENIUM_REMOTE_DRIVER_URL) {
builder = builder.usingServer(TestConstants.TS_SELENIUM_REMOTE_DRIVER_URL);
}

get(): ThenableWebDriver {
return this.driver;
return builder;
}

}

0 comments on commit 4ca00ae

Please sign in to comment.