Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add trailing 0 to Happy path tests screencast png's #14292

Merged
merged 12 commits into from
Aug 22, 2019
11 changes: 0 additions & 11 deletions e2e/driver/CheReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,6 @@ class CheReporter extends mocha.reporters.Spec {
}
});

runner.on('test end', async function (test: mocha.Test) {
Ohrimenko1988 marked this conversation as resolved.
Show resolved Hide resolved
if (!TestConstants.TS_SELENIUM_EXECUTION_SCREENCAST) {
return;
}

const currentMethodIndex: number = methodIndex;
let iterationIndex: number = 10000;

await screenCatcher.catchMethodScreen(test.title, currentMethodIndex, iterationIndex);
});

runner.on('end', async function (test: mocha.Test) {
// ensure that fired events done
await driver.get().sleep(5000);
Expand Down
9 changes: 6 additions & 3 deletions e2e/utils/ScreenCatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ export class ScreenCatcher {

const date: Date = new Date();
const timeStamp: string = `(${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}:${date.getMilliseconds()})`;
const screenshotPath: string = `${screenshotDir}/${screenshotIndex}-${methodName}-${timeStamp}.png`;

await this.catcheScreen(screenshotPath);
// add trailing 0 to have screenshots list normally sorted by name, e.g. 00000009, 00000010, ...
const formattedIndex: string = new Intl.NumberFormat('en-us', {minimumIntegerDigits: 8}).format(screenshotIndex).replace(/,/g, "");
const screenshotPath: string = `${screenshotDir}/${formattedIndex}-${methodName}-${timeStamp}.png`;

await this.catchScreen(screenshotPath);
}

async catcheScreen(screenshotPath: string) {
async catchScreen(screenshotPath: string) {
const screenshot: string = await this.driverHelper.getDriver().takeScreenshot();
const screenshotStream = fs.createWriteStream(screenshotPath);
screenshotStream.write(new Buffer(screenshot, 'base64'));
Expand Down