playwright.js 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. "use strict";
  2. var __defProp = Object.defineProperty;
  3. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  4. var __getOwnPropNames = Object.getOwnPropertyNames;
  5. var __hasOwnProp = Object.prototype.hasOwnProperty;
  6. var __export = (target, all) => {
  7. for (var name in all)
  8. __defProp(target, name, { get: all[name], enumerable: true });
  9. };
  10. var __copyProps = (to, from, except, desc) => {
  11. if (from && typeof from === "object" || typeof from === "function") {
  12. for (let key of __getOwnPropNames(from))
  13. if (!__hasOwnProp.call(to, key) && key !== except)
  14. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  15. }
  16. return to;
  17. };
  18. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  19. var playwright_exports = {};
  20. __export(playwright_exports, {
  21. Playwright: () => Playwright
  22. });
  23. module.exports = __toCommonJS(playwright_exports);
  24. var import_android = require("./android");
  25. var import_browser = require("./browser");
  26. var import_browserType = require("./browserType");
  27. var import_channelOwner = require("./channelOwner");
  28. var import_electron = require("./electron");
  29. var import_errors = require("./errors");
  30. var import_fetch = require("./fetch");
  31. var import_selectors = require("./selectors");
  32. class Playwright extends import_channelOwner.ChannelOwner {
  33. constructor(parent, type, guid, initializer) {
  34. super(parent, type, guid, initializer);
  35. this.request = new import_fetch.APIRequest(this);
  36. this.chromium = import_browserType.BrowserType.from(initializer.chromium);
  37. this.chromium._playwright = this;
  38. this.firefox = import_browserType.BrowserType.from(initializer.firefox);
  39. this.firefox._playwright = this;
  40. this.webkit = import_browserType.BrowserType.from(initializer.webkit);
  41. this.webkit._playwright = this;
  42. this._android = import_android.Android.from(initializer.android);
  43. this._android._playwright = this;
  44. this._electron = import_electron.Electron.from(initializer.electron);
  45. this._electron._playwright = this;
  46. this.devices = this._connection.localUtils()?.devices ?? {};
  47. this.selectors = new import_selectors.Selectors(this._connection._platform);
  48. this.errors = { TimeoutError: import_errors.TimeoutError };
  49. }
  50. static from(channel) {
  51. return channel._object;
  52. }
  53. _browserTypes() {
  54. return [this.chromium, this.firefox, this.webkit];
  55. }
  56. _preLaunchedBrowser() {
  57. const browser = import_browser.Browser.from(this._initializer.preLaunchedBrowser);
  58. browser._connectToBrowserType(this[browser._name], {}, void 0);
  59. return browser;
  60. }
  61. _allContexts() {
  62. return this._browserTypes().flatMap((type) => [...type._contexts]);
  63. }
  64. _allPages() {
  65. return this._allContexts().flatMap((context) => context.pages());
  66. }
  67. }
  68. // Annotate the CommonJS export names for ESM import in node:
  69. 0 && (module.exports = {
  70. Playwright
  71. });