Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(executablePath): throw unexpected platform error upon call (#3943)

Pavel Feldmanf1016c1fc158
diff --git a/src/client/browserType.ts b/src/client/browserType.ts
index 824a59804f..7e6fc9c751 100644
--- a/src/client/browserType.ts
+++ b/src/client/browserType.ts
@@ -54,6 +54,8 @@ export class BrowserType extends ChannelOwner<channels.BrowserTypeChannel, chann
}
executablePath(): string {
+ if (!this._initializer.executablePath)
+ throw new Error('Browser is not supported on current platform');
return this._initializer.executablePath;
}
diff --git a/src/server/browserType.ts b/src/server/browserType.ts
index 432fbae0af..7aaf61de97 100644
--- a/src/server/browserType.ts
+++ b/src/server/browserType.ts
@@ -39,7 +39,7 @@ type WebSocketNotPipe = { webSocketRegex: RegExp, stream: 'stdout' | 'stderr' };
export abstract class BrowserType {
private _name: string;
- private _executablePath: string | undefined;
+ private _executablePath: string;
private _webSocketNotPipe: WebSocketNotPipe | null;
private _browserDescriptor: browserPaths.BrowserDescriptor;
readonly _browserPath: string;
@@ -49,13 +49,11 @@ export abstract class BrowserType {
const browsersPath = browserPaths.browsersPath(packagePath);
this._browserDescriptor = browser;
this._browserPath = browserPaths.browserDirectory(browsersPath, browser);
- this._executablePath = browserPaths.executablePath(this._browserPath, browser);
+ this._executablePath = browserPaths.executablePath(this._browserPath, browser) || '';
this._webSocketNotPipe = webSocketOrPipe;
}
executablePath(): string {
- if (!this._executablePath)
- throw new Error('Browser is not supported on current platform');
return this._executablePath;
}