2020-01-09 14:49:22 -08:00
|
|
|
/**
|
|
|
|
* Copyright (c) Microsoft Corporation.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2021-01-29 16:00:56 -08:00
|
|
|
import * as path from 'path';
|
|
|
|
import { Tracer } from '../trace/tracer';
|
2020-12-09 15:06:57 -08:00
|
|
|
import * as browserPaths from '../utils/browserPaths';
|
|
|
|
import { Android } from './android/android';
|
|
|
|
import { AdbBackend } from './android/backendAdb';
|
2020-08-22 15:46:42 -07:00
|
|
|
import { Chromium } from './chromium/chromium';
|
2020-12-09 15:06:57 -08:00
|
|
|
import { Electron } from './electron/electron';
|
2020-08-23 17:05:58 -07:00
|
|
|
import { Firefox } from './firefox/firefox';
|
2020-09-02 16:15:43 -07:00
|
|
|
import { serverSelectors } from './selectors';
|
2021-01-29 16:00:56 -08:00
|
|
|
import { HarTracer } from './supplements/har/harTracer';
|
|
|
|
import { InspectorController } from './supplements/inspectorController';
|
2020-12-09 15:06:57 -08:00
|
|
|
import { WebKit } from './webkit/webkit';
|
2020-01-09 14:49:22 -08:00
|
|
|
|
2020-01-24 14:49:47 -08:00
|
|
|
export class Playwright {
|
2020-09-02 16:15:43 -07:00
|
|
|
readonly selectors = serverSelectors;
|
2020-07-24 16:36:00 -07:00
|
|
|
readonly chromium: Chromium;
|
2020-12-09 15:06:57 -08:00
|
|
|
readonly android: Android;
|
|
|
|
readonly electron: Electron;
|
2020-07-24 16:36:00 -07:00
|
|
|
readonly firefox: Firefox;
|
|
|
|
readonly webkit: WebKit;
|
2021-01-29 16:00:56 -08:00
|
|
|
readonly options = {
|
|
|
|
contextListeners: [
|
|
|
|
new InspectorController(),
|
|
|
|
new Tracer(),
|
|
|
|
new HarTracer()
|
|
|
|
]
|
|
|
|
};
|
2020-01-24 14:49:47 -08:00
|
|
|
|
2020-04-28 17:06:01 -07:00
|
|
|
constructor(packagePath: string, browsers: browserPaths.BrowserDescriptor[]) {
|
|
|
|
const chromium = browsers.find(browser => browser.name === 'chromium');
|
2021-01-29 16:00:56 -08:00
|
|
|
this.chromium = new Chromium(packagePath, chromium!, this.options);
|
2020-04-28 17:06:01 -07:00
|
|
|
|
|
|
|
const firefox = browsers.find(browser => browser.name === 'firefox');
|
2021-01-29 16:00:56 -08:00
|
|
|
this.firefox = new Firefox(packagePath, firefox!, this.options);
|
2020-04-28 17:06:01 -07:00
|
|
|
|
|
|
|
const webkit = browsers.find(browser => browser.name === 'webkit');
|
2021-01-29 16:00:56 -08:00
|
|
|
this.webkit = new WebKit(packagePath, webkit!, this.options);
|
2020-11-06 16:31:11 -08:00
|
|
|
|
2021-01-29 16:00:56 -08:00
|
|
|
this.electron = new Electron(this.options);
|
|
|
|
this.android = new Android(new AdbBackend(), this.options);
|
2020-01-24 14:49:47 -08:00
|
|
|
}
|
2020-01-09 14:49:22 -08:00
|
|
|
}
|
2021-01-29 16:00:56 -08:00
|
|
|
|
|
|
|
export function createPlaywright() {
|
|
|
|
return new Playwright(path.join(__dirname, '..', '..'), require('../../browsers.json')['browsers']);
|
|
|
|
}
|