test: make sure test window is on top for focus tests (#45552)

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
trop[bot] 2025-02-11 10:02:12 +01:00 committed by GitHub
parent fc697735c4
commit 452d891be5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 3 deletions

View file

@ -122,6 +122,14 @@ export class ScreenCapture {
return this._expectImpl(findPoint(this.display.size), hexColor, true);
}
public async takeScreenshot (filePrefix: string) {
const frame = await this.captureFrame();
return await createArtifactWithRandomId(
(id) => `${filePrefix}-${id}.png`,
frame.toPNG()
);
}
private async captureFrame (): Promise<NativeImage> {
const sources = await desktopCapturer.getSources({
types: ['screen'],