mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
smoke(electron): wait for page navigation to commit before using driver (#157106)
* smoke(electron): wait for page navigation to commit before using driver
* chore: only use window event in Electron
* chore: implement load event for web
* 💄
Co-authored-by: Benjamin Pasero <benjamin.pasero@gmail.com>
This commit is contained in:
parent
b41684837f
commit
5d796f32ea
|
@ -117,6 +117,7 @@ export class Application {
|
||||||
private async checkWindowReady(code: Code): Promise<void> {
|
private async checkWindowReady(code: Code): Promise<void> {
|
||||||
|
|
||||||
// We need a rendered workbench
|
// We need a rendered workbench
|
||||||
|
await measureAndLog(code.didFinishLoad(), 'Application#checkWindowReady: wait for navigation to be committed', this.logger);
|
||||||
await measureAndLog(code.waitForElement('.monaco-workbench'), 'Application#checkWindowReady: wait for .monaco-workbench element', this.logger);
|
await measureAndLog(code.waitForElement('.monaco-workbench'), 'Application#checkWindowReady: wait for .monaco-workbench element', this.logger);
|
||||||
|
|
||||||
// Remote but not web: wait for a remote connection state change
|
// Remote but not web: wait for a remote connection state change
|
||||||
|
|
|
@ -135,6 +135,10 @@ export class Code {
|
||||||
await this.driver.dispatchKeybinding(keybinding);
|
await this.driver.dispatchKeybinding(keybinding);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async didFinishLoad(): Promise<void> {
|
||||||
|
return this.driver.didFinishLoad();
|
||||||
|
}
|
||||||
|
|
||||||
async exit(): Promise<void> {
|
async exit(): Promise<void> {
|
||||||
return measureAndLog(new Promise<void>((resolve, reject) => {
|
return measureAndLog(new Promise<void>((resolve, reject) => {
|
||||||
const pid = this.mainProcess.pid!;
|
const pid = this.mainProcess.pid!;
|
||||||
|
|
|
@ -77,6 +77,20 @@ export class PlaywrightDriver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async didFinishLoad(): Promise<void> {
|
||||||
|
|
||||||
|
// Web: via `load` state
|
||||||
|
if (this.options.web) {
|
||||||
|
return this.page.waitForLoadState('load');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desktop: via `window` event
|
||||||
|
return new Promise<void>(resolve => {
|
||||||
|
// https://playwright.dev/docs/api/class-electronapplication#electron-application-event-window
|
||||||
|
(this.application as playwright.ElectronApplication).on('window', () => resolve());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private async takeScreenshot(name: string): Promise<void> {
|
private async takeScreenshot(name: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const persistPath = join(this.options.logsPath, `playwright-screenshot-${PlaywrightDriver.screenShotCounter++}-${name.replace(/\s+/g, '-')}.png`);
|
const persistPath = join(this.options.logsPath, `playwright-screenshot-${PlaywrightDriver.screenShotCounter++}-${name.replace(/\s+/g, '-')}.png`);
|
||||||
|
|
Loading…
Reference in a new issue