[ML] Docs screenshots - support to set window size per screenshot (#135111)

This PR enhances the service method that takes screenshots for the docs to specify the browser window size.
This commit is contained in:
Robert Oskamp 2022-06-24 15:42:59 +02:00 committed by GitHub
parent 14c640573c
commit 68143891fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

View file

@ -173,5 +173,10 @@ export function MachineLearningAnomaliesTableProvider({ getService }: FtrProvide
async scrollTableIntoView() {
await testSubjects.scrollIntoView('mlAnomaliesTable');
},
async scrollRowIntoView(rowIndex: number) {
const rowSubj = await this.getRowSubjByRowIndex(rowIndex);
await testSubjects.scrollIntoView(rowSubj);
},
};
}

View file

@ -109,8 +109,14 @@ export default function ({ getService }: FtrProviderContext) {
await ml.anomalyExplorer.scrollChartsContainerIntoView();
await ml.anomaliesTable.ensureDetailsOpen(0);
await ml.anomaliesTable.scrollRowIntoView(0);
await ml.testExecution.logTestStep('take screenshot');
await mlScreenshots.takeScreenshot('ml-population-anomaly', screenshotDirectories);
await mlScreenshots.takeScreenshot(
'ml-population-anomaly',
screenshotDirectories,
1500,
1300
);
});
});
}

View file

@ -8,12 +8,18 @@
import { FtrProviderContext } from '../ftr_provider_context';
export function MachineLearningScreenshotsProvider({ getService }: FtrProviderContext) {
const browser = getService('browser');
const ml = getService('ml');
const screenshot = getService('screenshots');
const DEFAULT_WIDTH = 1920;
const DEFAULT_HEIGHT = 1080;
return {
async takeScreenshot(name: string, subDirectories: string[]) {
async takeScreenshot(name: string, subDirectories: string[], width?: number, height?: number) {
await browser.setWindowSize(width ?? DEFAULT_WIDTH, height ?? DEFAULT_HEIGHT);
await screenshot.take(`${name}_new`, undefined, subDirectories);
await browser.setWindowSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
},
async removeFocusFromElement() {