Skip to content

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

chore: update index.d.ts and index.js (#318)

Dmitry Gozmandd6ba432ab69
diff --git a/index.d.ts b/index.d.ts
index 8b3a05e394..f05630a9e4 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -1,9 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
-import * as chromium from './chromium';
-import * as firefox from './firefox';
-import * as webkit from './webkit';
-declare function pickBrowser(browser: 'chromium'): typeof chromium;
-declare function pickBrowser(browser: 'firefox'): typeof firefox;
-declare function pickBrowser(browser: 'webkit'): typeof webkit;
-export = pickBrowser;
\ No newline at end of file
+
+export * from './lib/api';
+export function playwright(browser: 'chromium'): import('./lib/api').Chromium;
+export function playwright(browser: 'firefox'): import('./lib/api').Firefox;
+export function playwright(browser: 'webkit'): import('./lib/api').WebKit;
diff --git a/index.js b/index.js
index 967fac7f93..e3d0c539d7 100644
--- a/index.js
+++ b/index.js
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
-module.exports = browser => {
+module.exports.playwright = browser => {
if (browser === 'chromium')
return require('./chromium');
if (browser === 'firefox')
diff --git a/src/api.ts b/src/api.ts
index ab1f736182..09d07907f1 100644
--- a/src/api.ts
+++ b/src/api.ts
@@ -12,12 +12,8 @@ export { Frame } from './frames';
export { Keyboard, Mouse } from './input';
export { JSHandle } from './javascript';
export { Request, Response } from './network';
-export { Page } from './page';
+export { Page, FileChooser } from './page';
export * from './chromium/crApi';
export * from './firefox/ffApi';
export * from './webkit/wkApi';
-
-export const Chromium = {};
-export const Firefox = {};
-export const WebKit = {};
diff --git a/src/chromium/crApi.ts b/src/chromium/crApi.ts
index aa9d91ea0b..b4670ab7e5 100644
--- a/src/chromium/crApi.ts
+++ b/src/chromium/crApi.ts
@@ -1,15 +1,14 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
-export { CRBrowser } from './crBrowser';
-export { CRSession } from './crConnection';
-export { CRPlaywright } from './crPlaywright';
-export { CRTarget } from './crTarget';
-export { CRAccessibility } from './features/crAccessibility';
-export { CRCoverage } from './features/crCoverage';
-export { CRInterception } from './features/crInterception';
-export { CROverrides } from './features/crOverrides';
-export { CRPDF } from './features/crPdf';
-export { CRPermissions } from './features/crPermissions';
-export { CRWorker, CRWorkers } from './features/crWorkers';
-
+export { CRBrowser as ChromiumBrowser } from './crBrowser';
+export { CRSession as ChromiumSession } from './crConnection';
+export { CRPlaywright as Chromium } from './crPlaywright';
+export { CRTarget as ChromiumTarget } from './crTarget';
+export { CRAccessibility as ChromiumAccessibility } from './features/crAccessibility';
+export { CRCoverage as ChromiumCoverage } from './features/crCoverage';
+export { CRInterception as ChromiumInterception } from './features/crInterception';
+export { CROverrides as ChromiumOverrides } from './features/crOverrides';
+export { CRPDF as ChromiumPDF } from './features/crPdf';
+export { CRPermissions as ChromiumPermissions } from './features/crPermissions';
+export { CRWorker as ChromiumWorker, CRWorkers as ChromiumWorkers } from './features/crWorkers';
diff --git a/src/firefox/ffApi.ts b/src/firefox/ffApi.ts
index 2e17ce942b..b7674659e9 100644
--- a/src/firefox/ffApi.ts
+++ b/src/firefox/ffApi.ts
@@ -1,8 +1,7 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
-export { FFInterception } from './features/ffInterception';
-export { FFPermissions } from './features/ffPermissions';
-export { FFBrowser } from './ffBrowser';
-export { FFPlaywright } from './ffPlaywright';
-
+export { FFInterception as FirefoxInterception } from './features/ffInterception';
+export { FFPermissions as FirefoxPermissions } from './features/ffPermissions';
+export { FFBrowser as FirefoxBrowser } from './ffBrowser';
+export { FFPlaywright as Firefox } from './ffPlaywright';
diff --git a/src/webkit/wkApi.ts b/src/webkit/wkApi.ts
index 166c2c5cc2..0a5562a2f1 100644
--- a/src/webkit/wkApi.ts
+++ b/src/webkit/wkApi.ts
@@ -1,5 +1,5 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
-export { WKBrowser } from './wkBrowser';
-export { WKPlaywright } from './wkPlaywright';
+export { WKBrowser as WebKitBrowser } from './wkBrowser';
+export { WKPlaywright as WebKit } from './wkPlaywright';