How to use setVideoRecordingOptions method in Playwright Internal

Best JavaScript code snippet using playwright-internal

Protocol.js

Source:Protocol.js Github

copy

Full Screen

1/* This Source Code Form is subject to the terms of the Mozilla Public2 * License, v. 2.0. If a copy of the MPL was not distributed with this3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */4const {t, checkScheme} = ChromeUtils.import('chrome://juggler/content/protocol/PrimitiveTypes.js');5// Protocol-specific types.6const browserTypes = {};7browserTypes.TargetInfo = {8 type: t.Enum(['page']),9 targetId: t.String,10 browserContextId: t.Optional(t.String),11 // PageId of parent tab, if any.12 openerId: t.Optional(t.String),13};14browserTypes.CookieOptions = {15 name: t.String,16 value: t.String,17 url: t.Optional(t.String),18 domain: t.Optional(t.String),19 path: t.Optional(t.String),20 secure: t.Optional(t.Boolean),21 httpOnly: t.Optional(t.Boolean),22 sameSite: t.Optional(t.Enum(['Strict', 'Lax', 'None'])),23 expires: t.Optional(t.Number),24};25browserTypes.Cookie = {26 name: t.String,27 domain: t.String,28 path: t.String,29 value: t.String,30 expires: t.Number,31 size: t.Number,32 httpOnly: t.Boolean,33 secure: t.Boolean,34 session: t.Boolean,35 sameSite: t.Enum(['Strict', 'Lax', 'None']),36};37browserTypes.Geolocation = {38 latitude: t.Number,39 longitude: t.Number,40 accuracy: t.Optional(t.Number),41};42browserTypes.DownloadOptions = {43 behavior: t.Optional(t.Enum(['saveToDisk', 'cancel'])),44 downloadsDir: t.Optional(t.String),45};46const pageTypes = {};47pageTypes.DOMPoint = {48 x: t.Number,49 y: t.Number,50};51pageTypes.Rect = {52 x: t.Number,53 y: t.Number,54 width: t.Number,55 height: t.Number,56};57pageTypes.Size = {58 width: t.Number,59 height: t.Number,60};61pageTypes.Viewport = {62 viewportSize: pageTypes.Size,63 deviceScaleFactor: t.Optional(t.Number),64};65pageTypes.DOMQuad = {66 p1: pageTypes.DOMPoint,67 p2: pageTypes.DOMPoint,68 p3: pageTypes.DOMPoint,69 p4: pageTypes.DOMPoint,70};71pageTypes.TouchPoint = {72 x: t.Number,73 y: t.Number,74 radiusX: t.Optional(t.Number),75 radiusY: t.Optional(t.Number),76 rotationAngle: t.Optional(t.Number),77 force: t.Optional(t.Number),78};79pageTypes.Clip = {80 x: t.Number,81 y: t.Number,82 width: t.Number,83 height: t.Number,84};85const runtimeTypes = {};86runtimeTypes.RemoteObject = {87 type: t.Optional(t.Enum(['object', 'function', 'undefined', 'string', 'number', 'boolean', 'symbol', 'bigint'])),88 subtype: t.Optional(t.Enum(['array', 'null', 'node', 'regexp', 'date', 'map', 'set', 'weakmap', 'weakset', 'error', 'proxy', 'promise', 'typedarray'])),89 objectId: t.Optional(t.String),90 unserializableValue: t.Optional(t.Enum(['Infinity', '-Infinity', '-0', 'NaN'])),91 value: t.Any92};93runtimeTypes.ObjectProperty = {94 name: t.String,95 value: runtimeTypes.RemoteObject,96};97runtimeTypes.ScriptLocation = {98 columnNumber: t.Number,99 lineNumber: t.Number,100 url: t.String,101};102runtimeTypes.ExceptionDetails = {103 text: t.Optional(t.String),104 stack: t.Optional(t.String),105 value: t.Optional(t.Any),106};107runtimeTypes.CallFunctionArgument = {108 objectId: t.Optional(t.String),109 unserializableValue: t.Optional(t.Enum(['Infinity', '-Infinity', '-0', 'NaN'])),110 value: t.Any,111};112runtimeTypes.AuxData = {113 frameId: t.Optional(t.String),114 name: t.Optional(t.String),115};116const axTypes = {};117axTypes.AXTree = {118 role: t.String,119 name: t.String,120 children: t.Optional(t.Array(t.Recursive(axTypes, 'AXTree'))),121 selected: t.Optional(t.Boolean),122 focused: t.Optional(t.Boolean),123 pressed: t.Optional(t.Boolean),124 focusable: t.Optional(t.Boolean),125 haspopup: t.Optional(t.Boolean),126 required: t.Optional(t.Boolean),127 invalid: t.Optional(t.Boolean),128 modal: t.Optional(t.Boolean),129 editable: t.Optional(t.Boolean),130 busy: t.Optional(t.Boolean),131 multiline: t.Optional(t.Boolean),132 readonly: t.Optional(t.Boolean),133 checked: t.Optional(t.Enum(['mixed', true])),134 expanded: t.Optional(t.Boolean),135 disabled: t.Optional(t.Boolean),136 multiselectable: t.Optional(t.Boolean),137 value: t.Optional(t.String),138 description: t.Optional(t.String),139 roledescription: t.Optional(t.String),140 valuetext: t.Optional(t.String),141 orientation: t.Optional(t.String),142 autocomplete: t.Optional(t.String),143 keyshortcuts: t.Optional(t.String),144 level: t.Optional(t.Number),145 tag: t.Optional(t.String),146 foundObject: t.Optional(t.Boolean),147}148const networkTypes = {};149networkTypes.HTTPHeader = {150 name: t.String,151 value: t.String,152};153networkTypes.HTTPCredentials = {154 username: t.String,155 password: t.String,156};157networkTypes.SecurityDetails = {158 protocol: t.String,159 subjectName: t.String,160 issuer: t.String,161 validFrom: t.Number,162 validTo: t.Number,163};164networkTypes.ResourceTiming = {165 startTime: t.Number,166 domainLookupStart: t.Number,167 domainLookupEnd: t.Number,168 connectStart: t.Number,169 secureConnectionStart: t.Number,170 connectEnd: t.Number,171 requestStart: t.Number,172 responseStart: t.Number,173};174const Browser = {175 targets: ['browser'],176 types: browserTypes,177 events: {178 'attachedToTarget': {179 sessionId: t.String,180 targetInfo: browserTypes.TargetInfo,181 },182 'detachedFromTarget': {183 sessionId: t.String,184 targetId: t.String,185 },186 'downloadCreated': {187 uuid: t.String,188 browserContextId: t.Optional(t.String),189 pageTargetId: t.String,190 url: t.String,191 suggestedFileName: t.String,192 },193 'downloadFinished': {194 uuid: t.String,195 canceled: t.Optional(t.Boolean),196 error: t.Optional(t.String),197 },198 'videoRecordingFinished': {199 screencastId: t.String,200 },201 },202 methods: {203 'enable': {204 params: {205 attachToDefaultContext: t.Boolean,206 },207 },208 'createBrowserContext': {209 params: {210 removeOnDetach: t.Optional(t.Boolean),211 },212 returns: {213 browserContextId: t.String,214 },215 },216 'removeBrowserContext': {217 params: {218 browserContextId: t.String,219 },220 },221 'newPage': {222 params: {223 browserContextId: t.Optional(t.String),224 },225 returns: {226 targetId: t.String,227 }228 },229 'close': {},230 'getInfo': {231 returns: {232 userAgent: t.String,233 version: t.String,234 },235 },236 'setExtraHTTPHeaders': {237 params: {238 browserContextId: t.Optional(t.String),239 headers: t.Array(networkTypes.HTTPHeader),240 },241 },242 'setBrowserProxy': {243 params: {244 type: t.Enum(['http', 'https', 'socks', 'socks4']),245 bypass: t.Array(t.String),246 host: t.String,247 port: t.Number,248 username: t.Optional(t.String),249 password: t.Optional(t.String),250 },251 },252 'setContextProxy': {253 params: {254 browserContextId: t.Optional(t.String),255 type: t.Enum(['http', 'https', 'socks', 'socks4']),256 bypass: t.Array(t.String),257 host: t.String,258 port: t.Number,259 username: t.Optional(t.String),260 password: t.Optional(t.String),261 },262 },263 'setHTTPCredentials': {264 params: {265 browserContextId: t.Optional(t.String),266 credentials: t.Nullable(networkTypes.HTTPCredentials),267 },268 },269 'setRequestInterception': {270 params: {271 browserContextId: t.Optional(t.String),272 enabled: t.Boolean,273 },274 },275 'setGeolocationOverride': {276 params: {277 browserContextId: t.Optional(t.String),278 geolocation: t.Nullable(browserTypes.Geolocation),279 }280 },281 'setUserAgentOverride': {282 params: {283 browserContextId: t.Optional(t.String),284 userAgent: t.Nullable(t.String),285 }286 },287 'setPlatformOverride': {288 params: {289 browserContextId: t.Optional(t.String),290 platform: t.Nullable(t.String),291 }292 },293 'setBypassCSP': {294 params: {295 browserContextId: t.Optional(t.String),296 bypassCSP: t.Nullable(t.Boolean),297 }298 },299 'setIgnoreHTTPSErrors': {300 params: {301 browserContextId: t.Optional(t.String),302 ignoreHTTPSErrors: t.Nullable(t.Boolean),303 }304 },305 'setJavaScriptDisabled': {306 params: {307 browserContextId: t.Optional(t.String),308 javaScriptDisabled: t.Boolean,309 }310 },311 'setLocaleOverride': {312 params: {313 browserContextId: t.Optional(t.String),314 locale: t.Nullable(t.String),315 }316 },317 'setTimezoneOverride': {318 params: {319 browserContextId: t.Optional(t.String),320 timezoneId: t.Nullable(t.String),321 }322 },323 'setDownloadOptions': {324 params: {325 browserContextId: t.Optional(t.String),326 downloadOptions: t.Nullable(browserTypes.DownloadOptions),327 }328 },329 'setTouchOverride': {330 params: {331 browserContextId: t.Optional(t.String),332 hasTouch: t.Nullable(t.Boolean),333 }334 },335 'setDefaultViewport': {336 params: {337 browserContextId: t.Optional(t.String),338 viewport: t.Nullable(pageTypes.Viewport),339 }340 },341 'setScrollbarsHidden': {342 params: {343 browserContextId: t.Optional(t.String),344 hidden: t.Boolean,345 }346 },347 'addScriptToEvaluateOnNewDocument': {348 params: {349 browserContextId: t.Optional(t.String),350 script: t.String,351 }352 },353 'addBinding': {354 params: {355 browserContextId: t.Optional(t.String),356 worldName: t.Optional(t.String),357 name: t.String,358 script: t.String,359 },360 },361 'grantPermissions': {362 params: {363 origin: t.String,364 browserContextId: t.Optional(t.String),365 permissions: t.Array(t.String),366 },367 },368 'resetPermissions': {369 params: {370 browserContextId: t.Optional(t.String),371 }372 },373 'setCookies': {374 params: {375 browserContextId: t.Optional(t.String),376 cookies: t.Array(browserTypes.CookieOptions),377 }378 },379 'clearCookies': {380 params: {381 browserContextId: t.Optional(t.String),382 }383 },384 'getCookies': {385 params: {386 browserContextId: t.Optional(t.String)387 },388 returns: {389 cookies: t.Array(browserTypes.Cookie),390 },391 },392 'setOnlineOverride': {393 params: {394 browserContextId: t.Optional(t.String),395 override: t.Nullable(t.Enum(['online', 'offline'])),396 }397 },398 'setColorScheme': {399 params: {400 browserContextId: t.Optional(t.String),401 colorScheme: t.Nullable(t.Enum(['dark', 'light', 'no-preference'])),402 },403 },404 'setReducedMotion': {405 params: {406 browserContextId: t.Optional(t.String),407 reducedMotion: t.Nullable(t.Enum(['reduce', 'no-preference'])),408 },409 },410 'setForcedColors': {411 params: {412 browserContextId: t.Optional(t.String),413 forcedColors: t.Nullable(t.Enum(['active', 'none'])),414 },415 },416 'setVideoRecordingOptions': {417 params: {418 browserContextId: t.Optional(t.String),419 options: t.Optional({420 dir: t.String,421 width: t.Number,422 height: t.Number,423 }),424 },425 },426 'cancelDownload': {427 params: {428 uuid: t.Optional(t.String),429 }430 }431 },432};433const Network = {434 targets: ['page'],435 types: networkTypes,436 events: {437 'requestWillBeSent': {438 // frameId may be absent for redirected requests.439 frameId: t.Optional(t.String),440 requestId: t.String,441 // RequestID of redirected request.442 redirectedFrom: t.Optional(t.String),443 postData: t.Optional(t.String),444 headers: t.Array(networkTypes.HTTPHeader),445 isIntercepted: t.Boolean,446 url: t.String,447 method: t.String,448 navigationId: t.Optional(t.String),449 cause: t.String,450 internalCause: t.String,451 },452 'responseReceived': {453 securityDetails: t.Nullable(networkTypes.SecurityDetails),454 requestId: t.String,455 fromCache: t.Boolean,456 remoteIPAddress: t.Optional(t.String),457 remotePort: t.Optional(t.Number),458 status: t.Number,459 statusText: t.String,460 headers: t.Array(networkTypes.HTTPHeader),461 timing: networkTypes.ResourceTiming,462 },463 'requestFinished': {464 requestId: t.String,465 responseEndTime: t.Number,466 transferSize: t.Number,467 encodedBodySize: t.Number,468 protocolVersion: t.Optional(t.String),469 },470 'requestFailed': {471 requestId: t.String,472 errorCode: t.String,473 },474 },475 methods: {476 'setRequestInterception': {477 params: {478 enabled: t.Boolean,479 },480 },481 'setExtraHTTPHeaders': {482 params: {483 headers: t.Array(networkTypes.HTTPHeader),484 },485 },486 'abortInterceptedRequest': {487 params: {488 requestId: t.String,489 errorCode: t.String,490 },491 },492 'resumeInterceptedRequest': {493 params: {494 requestId: t.String,495 url: t.Optional(t.String),496 method: t.Optional(t.String),497 headers: t.Optional(t.Array(networkTypes.HTTPHeader)),498 postData: t.Optional(t.String),499 },500 },501 'fulfillInterceptedRequest': {502 params: {503 requestId: t.String,504 status: t.Number,505 statusText: t.String,506 headers: t.Array(networkTypes.HTTPHeader),507 base64body: t.Optional(t.String), // base64-encoded508 },509 },510 'getResponseBody': {511 params: {512 requestId: t.String,513 },514 returns: {515 base64body: t.String,516 evicted: t.Optional(t.Boolean),517 },518 },519 },520};521const Runtime = {522 targets: ['page'],523 types: runtimeTypes,524 events: {525 'executionContextCreated': {526 executionContextId: t.String,527 auxData: runtimeTypes.AuxData,528 },529 'executionContextDestroyed': {530 executionContextId: t.String,531 },532 'console': {533 executionContextId: t.String,534 args: t.Array(runtimeTypes.RemoteObject),535 type: t.String,536 location: runtimeTypes.ScriptLocation,537 },538 },539 methods: {540 'evaluate': {541 params: {542 // Pass frameId here.543 executionContextId: t.String,544 expression: t.String,545 returnByValue: t.Optional(t.Boolean),546 },547 returns: {548 result: t.Optional(runtimeTypes.RemoteObject),549 exceptionDetails: t.Optional(runtimeTypes.ExceptionDetails),550 }551 },552 'callFunction': {553 params: {554 // Pass frameId here.555 executionContextId: t.String,556 functionDeclaration: t.String,557 returnByValue: t.Optional(t.Boolean),558 args: t.Array(runtimeTypes.CallFunctionArgument),559 },560 returns: {561 result: t.Optional(runtimeTypes.RemoteObject),562 exceptionDetails: t.Optional(runtimeTypes.ExceptionDetails),563 }564 },565 'disposeObject': {566 params: {567 executionContextId: t.String,568 objectId: t.String,569 },570 },571 'getObjectProperties': {572 params: {573 executionContextId: t.String,574 objectId: t.String,575 },576 returns: {577 properties: t.Array(runtimeTypes.ObjectProperty),578 }579 },580 },581};582const Page = {583 targets: ['page'],584 types: pageTypes,585 events: {586 'ready': {587 },588 'crashed': {589 },590 'eventFired': {591 frameId: t.String,592 name: t.Enum(['load', 'DOMContentLoaded']),593 },594 'uncaughtError': {595 frameId: t.String,596 message: t.String,597 stack: t.String,598 },599 'frameAttached': {600 frameId: t.String,601 parentFrameId: t.Optional(t.String),602 },603 'frameDetached': {604 frameId: t.String,605 },606 'navigationStarted': {607 frameId: t.String,608 navigationId: t.String,609 url: t.String,610 },611 'navigationCommitted': {612 frameId: t.String,613 // |navigationId| can only be null in response to enable.614 navigationId: t.Optional(t.String),615 url: t.String,616 // frame.id or frame.name617 name: t.String,618 },619 'navigationAborted': {620 frameId: t.String,621 navigationId: t.String,622 errorText: t.String,623 },624 'sameDocumentNavigation': {625 frameId: t.String,626 url: t.String,627 },628 'dialogOpened': {629 dialogId: t.String,630 type: t.Enum(['prompt', 'alert', 'confirm', 'beforeunload']),631 message: t.String,632 defaultValue: t.Optional(t.String),633 },634 'dialogClosed': {635 dialogId: t.String,636 },637 'bindingCalled': {638 executionContextId: t.String,639 name: t.String,640 payload: t.Any,641 },642 'linkClicked': {643 phase: t.Enum(['before', 'after']),644 },645 'willOpenNewWindowAsynchronously': {},646 'fileChooserOpened': {647 executionContextId: t.String,648 element: runtimeTypes.RemoteObject649 },650 'workerCreated': {651 workerId: t.String,652 frameId: t.String,653 url: t.String,654 },655 'workerDestroyed': {656 workerId: t.String,657 },658 'dispatchMessageFromWorker': {659 workerId: t.String,660 message: t.String,661 },662 'videoRecordingStarted': {663 screencastId: t.String,664 file: t.String,665 },666 'webSocketCreated': {667 frameId: t.String,668 wsid: t.String,669 requestURL: t.String,670 },671 'webSocketOpened': {672 frameId: t.String,673 requestId: t.String,674 wsid: t.String,675 effectiveURL: t.String,676 },677 'webSocketClosed': {678 frameId: t.String,679 wsid: t.String,680 error: t.String,681 },682 'webSocketFrameSent': {683 frameId: t.String,684 wsid: t.String,685 opcode: t.Number,686 data: t.String,687 },688 'webSocketFrameReceived': {689 frameId: t.String,690 wsid: t.String,691 opcode: t.Number,692 data: t.String,693 },694 'screencastFrame': {695 data: t.String,696 deviceWidth: t.Number,697 deviceHeight: t.Number,698 },699 },700 methods: {701 'close': {702 params: {703 runBeforeUnload: t.Optional(t.Boolean),704 },705 },706 'setFileInputFiles': {707 params: {708 frameId: t.String,709 objectId: t.String,710 files: t.Array(t.String),711 },712 },713 'addBinding': {714 params: {715 worldName: t.Optional(t.String),716 name: t.String,717 script: t.String,718 },719 },720 'setViewportSize': {721 params: {722 viewportSize: t.Nullable(pageTypes.Size),723 },724 },725 'bringToFront': {726 params: {727 },728 },729 'setEmulatedMedia': {730 params: {731 type: t.Optional(t.Enum(['screen', 'print', ''])),732 colorScheme: t.Optional(t.Enum(['dark', 'light', 'no-preference'])),733 reducedMotion: t.Optional(t.Enum(['reduce', 'no-preference'])),734 forcedColors: t.Optional(t.Enum(['active', 'none'])),735 },736 },737 'setCacheDisabled': {738 params: {739 cacheDisabled: t.Boolean,740 },741 },742 'describeNode': {743 params: {744 frameId: t.String,745 objectId: t.String,746 },747 returns: {748 contentFrameId: t.Optional(t.String),749 ownerFrameId: t.Optional(t.String),750 },751 },752 'scrollIntoViewIfNeeded': {753 params: {754 frameId: t.String,755 objectId: t.String,756 rect: t.Optional(pageTypes.Rect),757 },758 },759 'addScriptToEvaluateOnNewDocument': {760 params: {761 script: t.String,762 worldName: t.Optional(t.String),763 }764 },765 'navigate': {766 params: {767 frameId: t.String,768 url: t.String,769 referer: t.Optional(t.String),770 },771 returns: {772 navigationId: t.Nullable(t.String),773 navigationURL: t.Nullable(t.String),774 }775 },776 'goBack': {777 params: {778 frameId: t.String,779 },780 returns: {781 success: t.Boolean,782 },783 },784 'goForward': {785 params: {786 frameId: t.String,787 },788 returns: {789 success: t.Boolean,790 },791 },792 'reload': {793 params: {794 frameId: t.String,795 },796 },797 'adoptNode': {798 params: {799 frameId: t.String,800 objectId: t.String,801 executionContextId: t.String,802 },803 returns: {804 remoteObject: t.Nullable(runtimeTypes.RemoteObject),805 },806 },807 'screenshot': {808 params: {809 mimeType: t.Enum(['image/png', 'image/jpeg']),810 clip: t.Optional(pageTypes.Clip),811 omitDeviceScaleFactor: t.Optional(t.Boolean),812 },813 returns: {814 data: t.String,815 }816 },817 'getContentQuads': {818 params: {819 frameId: t.String,820 objectId: t.String,821 },822 returns: {823 quads: t.Array(pageTypes.DOMQuad),824 },825 },826 'dispatchKeyEvent': {827 params: {828 type: t.String,829 key: t.String,830 keyCode: t.Number,831 location: t.Number,832 code: t.String,833 repeat: t.Boolean,834 text: t.Optional(t.String),835 }836 },837 'dispatchTouchEvent': {838 params: {839 type: t.Enum(['touchStart', 'touchEnd', 'touchMove', 'touchCancel']),840 touchPoints: t.Array(pageTypes.TouchPoint),841 modifiers: t.Number,842 },843 returns: {844 defaultPrevented: t.Boolean,845 }846 },847 'dispatchTapEvent': {848 params: {849 x: t.Number,850 y: t.Number,851 modifiers: t.Number,852 }853 },854 'dispatchMouseEvent': {855 params: {856 type: t.String,857 button: t.Number,858 x: t.Number,859 y: t.Number,860 modifiers: t.Number,861 clickCount: t.Optional(t.Number),862 buttons: t.Number,863 }864 },865 'dispatchWheelEvent': {866 params: {867 x: t.Number,868 y: t.Number,869 deltaX: t.Number,870 deltaY: t.Number,871 deltaZ: t.Number,872 modifiers: t.Number,873 }874 },875 'insertText': {876 params: {877 text: t.String,878 }879 },880 'crash': {881 params: {}882 },883 'handleDialog': {884 params: {885 dialogId: t.String,886 accept: t.Boolean,887 promptText: t.Optional(t.String),888 },889 },890 'setInterceptFileChooserDialog': {891 params: {892 enabled: t.Boolean,893 },894 },895 'sendMessageToWorker': {896 params: {897 frameId: t.String,898 workerId: t.String,899 message: t.String,900 },901 },902 'startScreencast': {903 params: {904 width: t.Number,905 height: t.Number,906 quality: t.Number,907 },908 returns: {909 screencastId: t.String,910 },911 },912 'screencastFrameAck': {913 params: {914 screencastId: t.String,915 },916 },917 'stopScreencast': {918 },919 },920};921const Accessibility = {922 targets: ['page'],923 types: axTypes,924 events: {},925 methods: {926 'getFullAXTree': {927 params: {928 objectId: t.Optional(t.String),929 },930 returns: {931 tree: axTypes.AXTree932 },933 }934 }935}936this.protocol = {937 domains: {Browser, Page, Runtime, Network, Accessibility},938};939this.checkScheme = checkScheme;...

Full Screen

Full Screen

ffBrowser.js

Source:ffBrowser.js Github

copy

Full Screen

1"use strict";2Object.defineProperty(exports, "__esModule", {3 value: true4});5exports.FFBrowserContext = exports.FFBrowser = void 0;6var _errors = require("../../utils/errors");7var _utils = require("../../utils/utils");8var _browser = require("../browser");9var _browserContext = require("../browserContext");10var network = _interopRequireWildcard(require("../network"));11var _ffConnection = require("./ffConnection");12var _ffPage = require("./ffPage");13function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }14function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }15/**16 * Copyright 2018 Google Inc. All rights reserved.17 * Modifications copyright (c) Microsoft Corporation.18 *19 * Licensed under the Apache License, Version 2.0 (the 'License');20 * you may not use this file except in compliance with the License.21 * You may obtain a copy of the License at22 *23 * http://www.apache.org/licenses/LICENSE-2.024 *25 * Unless required by applicable law or agreed to in writing, software26 * distributed under the License is distributed on an 'AS IS' BASIS,27 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.28 * See the License for the specific language governing permissions and29 * limitations under the License.30 */31class FFBrowser extends _browser.Browser {32 static async connect(transport, options) {33 const connection = new _ffConnection.FFConnection(transport, options.protocolLogger, options.browserLogsCollector);34 const browser = new FFBrowser(connection, options);35 if (options.__testHookOnConnectToBrowser) await options.__testHookOnConnectToBrowser();36 const promises = [connection.send('Browser.enable', {37 attachToDefaultContext: !!options.persistent38 }), browser._initVersion()];39 if (options.persistent) {40 browser._defaultContext = new FFBrowserContext(browser, undefined, options.persistent);41 promises.push(browser._defaultContext._initialize());42 }43 if (options.proxy) promises.push(browser._connection.send('Browser.setBrowserProxy', toJugglerProxyOptions(options.proxy)));44 await Promise.all(promises);45 return browser;46 }47 constructor(connection, options) {48 super(options);49 this._connection = void 0;50 this._ffPages = void 0;51 this._contexts = void 0;52 this._version = '';53 this._userAgent = '';54 this._connection = connection;55 this._ffPages = new Map();56 this._contexts = new Map();57 this._connection.on(_ffConnection.ConnectionEvents.Disconnected, () => this._onDisconnect());58 this._connection.on('Browser.attachedToTarget', this._onAttachedToTarget.bind(this));59 this._connection.on('Browser.detachedFromTarget', this._onDetachedFromTarget.bind(this));60 this._connection.on('Browser.downloadCreated', this._onDownloadCreated.bind(this));61 this._connection.on('Browser.downloadFinished', this._onDownloadFinished.bind(this));62 this._connection.on('Browser.videoRecordingFinished', this._onVideoRecordingFinished.bind(this));63 }64 async _initVersion() {65 const result = await this._connection.send('Browser.getInfo');66 this._version = result.version.substring(result.version.indexOf('/') + 1);67 this._userAgent = result.userAgent;68 }69 isConnected() {70 return !this._connection._closed;71 }72 async newContext(options) {73 (0, _browserContext.validateBrowserContextOptions)(options, this.options);74 if (options.isMobile) throw new Error('options.isMobile is not supported in Firefox');75 const {76 browserContextId77 } = await this._connection.send('Browser.createBrowserContext', {78 removeOnDetach: true79 });80 const context = new FFBrowserContext(this, browserContextId, options);81 await context._initialize();82 this._contexts.set(browserContextId, context);83 return context;84 }85 contexts() {86 return Array.from(this._contexts.values());87 }88 version() {89 return this._version;90 }91 userAgent() {92 return this._userAgent;93 }94 _onDetachedFromTarget(payload) {95 const ffPage = this._ffPages.get(payload.targetId);96 this._ffPages.delete(payload.targetId);97 ffPage.didClose();98 }99 _onAttachedToTarget(payload) {100 const {101 targetId,102 browserContextId,103 openerId,104 type105 } = payload.targetInfo;106 (0, _utils.assert)(type === 'page');107 const context = browserContextId ? this._contexts.get(browserContextId) : this._defaultContext;108 (0, _utils.assert)(context, `Unknown context id:${browserContextId}, _defaultContext: ${this._defaultContext}`);109 const session = this._connection.createSession(payload.sessionId);110 const opener = openerId ? this._ffPages.get(openerId) : null;111 const ffPage = new _ffPage.FFPage(session, context, opener);112 this._ffPages.set(targetId, ffPage);113 }114 _onDownloadCreated(payload) {115 const ffPage = this._ffPages.get(payload.pageTargetId);116 (0, _utils.assert)(ffPage);117 if (!ffPage) return;118 let originPage = ffPage._initializedPage; // If it's a new window download, report it on the opener page.119 if (!originPage) {120 // Resume the page creation with an error. The page will automatically close right121 // after the download begins.122 ffPage._markAsError(new Error('Starting new page download'));123 if (ffPage._opener) originPage = ffPage._opener._initializedPage;124 }125 if (!originPage) return;126 this._downloadCreated(originPage, payload.uuid, payload.url, payload.suggestedFileName);127 }128 _onDownloadFinished(payload) {129 const error = payload.canceled ? 'canceled' : payload.error;130 this._downloadFinished(payload.uuid, error);131 }132 _onVideoRecordingFinished(payload) {133 var _this$_takeVideo;134 (_this$_takeVideo = this._takeVideo(payload.screencastId)) === null || _this$_takeVideo === void 0 ? void 0 : _this$_takeVideo.reportFinished();135 }136 _onDisconnect() {137 for (const video of this._idToVideo.values()) video.artifact.reportFinished(_errors.kBrowserClosedError);138 this._idToVideo.clear();139 this._didClose();140 }141}142exports.FFBrowser = FFBrowser;143class FFBrowserContext extends _browserContext.BrowserContext {144 constructor(browser, browserContextId, options) {145 super(browser, options, browserContextId);146 }147 async _initialize() {148 (0, _utils.assert)(!this._ffPages().length);149 const browserContextId = this._browserContextId;150 const promises = [super._initialize()];151 promises.push(this._browser._connection.send('Browser.setDownloadOptions', {152 browserContextId,153 downloadOptions: {154 behavior: this._options.acceptDownloads ? 'saveToDisk' : 'cancel',155 downloadsDir: this._browser.options.downloadsPath156 }157 }));158 if (this._options.viewport) {159 const viewport = {160 viewportSize: {161 width: this._options.viewport.width,162 height: this._options.viewport.height163 },164 deviceScaleFactor: this._options.deviceScaleFactor || 1165 };166 promises.push(this._browser._connection.send('Browser.setDefaultViewport', {167 browserContextId,168 viewport169 }));170 }171 if (this._options.hasTouch) promises.push(this._browser._connection.send('Browser.setTouchOverride', {172 browserContextId,173 hasTouch: true174 }));175 if (this._options.userAgent) promises.push(this._browser._connection.send('Browser.setUserAgentOverride', {176 browserContextId,177 userAgent: this._options.userAgent178 }));179 if (this._options.bypassCSP) promises.push(this._browser._connection.send('Browser.setBypassCSP', {180 browserContextId,181 bypassCSP: true182 }));183 if (this._options.ignoreHTTPSErrors) promises.push(this._browser._connection.send('Browser.setIgnoreHTTPSErrors', {184 browserContextId,185 ignoreHTTPSErrors: true186 }));187 if (this._options.javaScriptEnabled === false) promises.push(this._browser._connection.send('Browser.setJavaScriptDisabled', {188 browserContextId,189 javaScriptDisabled: true190 }));191 if (this._options.locale) promises.push(this._browser._connection.send('Browser.setLocaleOverride', {192 browserContextId,193 locale: this._options.locale194 }));195 if (this._options.timezoneId) promises.push(this._browser._connection.send('Browser.setTimezoneOverride', {196 browserContextId,197 timezoneId: this._options.timezoneId198 }));199 if (this._options.permissions) promises.push(this.grantPermissions(this._options.permissions));200 if (this._options.extraHTTPHeaders || this._options.locale) promises.push(this.setExtraHTTPHeaders(this._options.extraHTTPHeaders || []));201 if (this._options.httpCredentials) promises.push(this.setHTTPCredentials(this._options.httpCredentials));202 if (this._options.geolocation) promises.push(this.setGeolocation(this._options.geolocation));203 if (this._options.offline) promises.push(this.setOffline(this._options.offline));204 promises.push(this._browser._connection.send('Browser.setColorScheme', {205 browserContextId,206 colorScheme: this._options.colorScheme !== undefined ? this._options.colorScheme : 'light'207 }));208 // [Replay] - Browser.setReducedMotion and Browser.setReducedMotion are not supported209 // promises.push(this._browser._connection.send('Browser.setReducedMotion', {210 // browserContextId,211 // reducedMotion: this._options.reducedMotion !== undefined ? this._options.reducedMotion : 'no-preference'212 // }));213 // promises.push(this._browser._connection.send('Browser.setReducedMotion', {214 // browserContextId,215 // forcedColors: this._options.forcedColors !== undefined ? this._options.forcedColors : 'none'216 // }));217 if (this._options.recordVideo) {218 promises.push(this._ensureVideosPath().then(() => {219 return this._browser._connection.send('Browser.setVideoRecordingOptions', {220 // validateBrowserContextOptions ensures correct video size.221 options: { ...this._options.recordVideo.size,222 dir: this._options.recordVideo.dir223 },224 browserContextId: this._browserContextId225 });226 }));227 }228 if (this._options.proxy) {229 promises.push(this._browser._connection.send('Browser.setContextProxy', {230 browserContextId: this._browserContextId,231 ...toJugglerProxyOptions(this._options.proxy)232 }));233 }234 await Promise.all(promises);235 }236 _ffPages() {237 return Array.from(this._browser._ffPages.values()).filter(ffPage => ffPage._browserContext === this);238 }239 pages() {240 return this._ffPages().map(ffPage => ffPage._initializedPage).filter(pageOrNull => !!pageOrNull);241 }242 async newPageDelegate() {243 (0, _browserContext.assertBrowserContextIsNotOwned)(this);244 const {245 targetId246 } = await this._browser._connection.send('Browser.newPage', {247 browserContextId: this._browserContextId248 }).catch(e => {249 if (e.message.includes('Failed to override timezone')) throw new Error(`Invalid timezone ID: ${this._options.timezoneId}`);250 throw e;251 });252 return this._browser._ffPages.get(targetId);253 }254 async _doCookies(urls) {255 const {256 cookies257 } = await this._browser._connection.send('Browser.getCookies', {258 browserContextId: this._browserContextId259 });260 return network.filterCookies(cookies.map(c => {261 const copy = { ...c262 };263 delete copy.size;264 delete copy.session;265 return copy;266 }), urls);267 }268 async addCookies(cookies) {269 const cc = network.rewriteCookies(cookies).map(c => ({ ...c,270 expires: c.expires && c.expires !== -1 ? c.expires : undefined271 }));272 await this._browser._connection.send('Browser.setCookies', {273 browserContextId: this._browserContextId,274 cookies: cc275 });276 }277 async clearCookies() {278 await this._browser._connection.send('Browser.clearCookies', {279 browserContextId: this._browserContextId280 });281 }282 async _doGrantPermissions(origin, permissions) {283 const webPermissionToProtocol = new Map([['geolocation', 'geo'], ['persistent-storage', 'persistent-storage'], ['push', 'push'], ['notifications', 'desktop-notification']]);284 const filtered = permissions.map(permission => {285 const protocolPermission = webPermissionToProtocol.get(permission);286 if (!protocolPermission) throw new Error('Unknown permission: ' + permission);287 return protocolPermission;288 });289 await this._browser._connection.send('Browser.grantPermissions', {290 origin: origin,291 browserContextId: this._browserContextId,292 permissions: filtered293 });294 }295 async _doClearPermissions() {296 await this._browser._connection.send('Browser.resetPermissions', {297 browserContextId: this._browserContextId298 });299 }300 async setGeolocation(geolocation) {301 (0, _browserContext.verifyGeolocation)(geolocation);302 this._options.geolocation = geolocation;303 await this._browser._connection.send('Browser.setGeolocationOverride', {304 browserContextId: this._browserContextId,305 geolocation: geolocation || null306 });307 }308 async setExtraHTTPHeaders(headers) {309 this._options.extraHTTPHeaders = headers;310 let allHeaders = this._options.extraHTTPHeaders;311 if (this._options.locale) allHeaders = network.mergeHeaders([allHeaders, network.singleHeader('Accept-Language', this._options.locale)]);312 await this._browser._connection.send('Browser.setExtraHTTPHeaders', {313 browserContextId: this._browserContextId,314 headers: allHeaders315 });316 }317 async setOffline(offline) {318 this._options.offline = offline;319 await this._browser._connection.send('Browser.setOnlineOverride', {320 browserContextId: this._browserContextId,321 override: offline ? 'offline' : 'online'322 });323 }324 async _doSetHTTPCredentials(httpCredentials) {325 this._options.httpCredentials = httpCredentials;326 await this._browser._connection.send('Browser.setHTTPCredentials', {327 browserContextId: this._browserContextId,328 credentials: httpCredentials || null329 });330 }331 async _doAddInitScript(source) {332 await this._browser._connection.send('Browser.addScriptToEvaluateOnNewDocument', {333 browserContextId: this._browserContextId,334 script: source335 });336 }337 async _doExposeBinding(binding) {338 await this._browser._connection.send('Browser.addBinding', {339 browserContextId: this._browserContextId,340 name: binding.name,341 script: binding.source342 });343 }344 async _doUpdateRequestInterception() {345 await this._browser._connection.send('Browser.setRequestInterception', {346 browserContextId: this._browserContextId,347 enabled: !!this._requestInterceptor348 });349 }350 _onClosePersistent() {}351 async _doClose() {352 (0, _utils.assert)(this._browserContextId);353 await this._browser._connection.send('Browser.removeBrowserContext', {354 browserContextId: this._browserContextId355 });356 this._browser._contexts.delete(this._browserContextId);357 }358 async _doCancelDownload(uuid) {359 await this._browser._connection.send('Browser.cancelDownload', {360 uuid361 });362 }363}364exports.FFBrowserContext = FFBrowserContext;365function toJugglerProxyOptions(proxy) {366 const proxyServer = new URL(proxy.server);367 let port = parseInt(proxyServer.port, 10);368 let type = 'http';369 if (proxyServer.protocol === 'socks5:') type = 'socks';else if (proxyServer.protocol === 'socks4:') type = 'socks4';else if (proxyServer.protocol === 'https:') type = 'https';370 if (proxyServer.port === '') {371 if (proxyServer.protocol === 'http:') port = 80;else if (proxyServer.protocol === 'https:') port = 443;372 }373 return {374 type,375 bypass: proxy.bypass ? proxy.bypass.split(',').map(domain => domain.trim()) : [],376 host: proxyServer.hostname,377 port,378 username: proxy.username,379 password: proxy.password380 };...

Full Screen

Full Screen

BrowserHandler.js

Source:BrowserHandler.js Github

copy

Full Screen

...179 async ['Browser.setForcedColors']({browserContextId, forcedColors}) {180 await this._targetRegistry.browserContextForId(browserContextId).setForcedColors(nullToUndefined(forcedColors));181 }182 async ['Browser.setVideoRecordingOptions']({browserContextId, options}) {183 await this._targetRegistry.browserContextForId(browserContextId).setVideoRecordingOptions(options);184 }185 async ['Browser.setUserAgentOverride']({browserContextId, userAgent}) {186 await this._targetRegistry.browserContextForId(browserContextId).setDefaultUserAgent(userAgent);187 }188 async ['Browser.setPlatformOverride']({browserContextId, platform}) {189 await this._targetRegistry.browserContextForId(browserContextId).setDefaultPlatform(platform);190 }191 async ['Browser.setBypassCSP']({browserContextId, bypassCSP}) {192 await this._targetRegistry.browserContextForId(browserContextId).applySetting('bypassCSP', nullToUndefined(bypassCSP));193 }194 async ['Browser.setJavaScriptDisabled']({browserContextId, javaScriptDisabled}) {195 await this._targetRegistry.browserContextForId(browserContextId).setJavaScriptDisabled(javaScriptDisabled);196 }197 async ['Browser.setLocaleOverride']({browserContextId, locale}) {...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false });4 const page = await browser.newPage();5 await page.screenshot({ path: 'playwright.png' });6 await browser.close();7})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const path = require('path');3(async () => {4 const browser = await chromium.launch({ headless: false });5 const context = await browser.newContext({6 recordVideo: {7 dir: path.join(__dirname, 'videos'),8 },9 });10 const page = await context.newPage();11 await page.screenshot({ path: 'example.png' });12 await browser.close();13})();14const { chromium } = require('playwright');15const path = require('path');16(async () => {17 const browser = await chromium.launch({ headless: false });18 const context = await browser.newContext({19 recordVideo: {20 dir: path.join(__dirname, 'videos'),21 },22 });23 const page = await context.newPage();24 await page.screenshot({ path: 'example.png' });25 await browser.close();26})();27const { chromium } = require('playwright');28const path = require('path');29(async () => {30 const browser = await chromium.launch({ headless: false });31 const context = await browser.newContext({32 recordVideo: {33 dir: path.join(__dirname, 'videos'),34 },35 });36 const page = await context.newPage();37 await page.screenshot({ path: 'example.png' });38 await browser.close();39})();40const { chromium } = require('playwright');41const path = require('path');42(async () => {43 const browser = await chromium.launch({ headless: false });44 const context = await browser.newContext({45 recordVideo: {46 dir: path.join(__dirname, 'videos'),47 },48 });49 const page = await context.newPage();50 await page.screenshot({ path: 'example.png' });51 await browser.close();52})();53const { chromium } = require('playwright');54const path = require('path');55(async () => {56 const browser = await chromium.launch({

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ headless: false, devtools: true });4 const context = await browser.newContext({5 recordVideo: {6 },7 });8 const page = await context.newPage();9 await page.close();10 await context.close();11 await browser.close();12})();13const { helper } = require('../helper');14const { BrowserContext } = require('../browserContext');15const { Events } = require('../events');16const { Page } = require('../page');17const { assert } = require('../../utils/utils');18const { CRSession } = require('./crConnection');19const { CRPage } = require('./crPage');20const { Protocol } = require('./protocol');21const { CRBrowserServer } = require('./crBrowserServer');22const { Browser } = require('../browser');23class CRBrowser extends Browser {24 * @param {!Puppeteer.CDPSession} client25 * @param {function():Promise} closeCallback26 * @param {BrowserContext} context27 * @param {boolean} ignoreHTTPSErrors28 * @param {boolean} appMode29 * @param {boolean} hasTouch30 * @param {boolean} isChromium31 constructor(client, closeCallback, context, ignoreHTTPSErrors, appMode, hasTouch, isChromium) {32 super(context, ignoreHTTPSErrors, appMode, hasTouch, isChromium);33 this._client = client;34 this._closeCallback = closeCallback;35 this._contexts = new Set();36 this._defaultContext = context;37 this._contexts.add(context);38 this._eventListeners = [];39 this._crPages = new Map();40 this._crPagePromises = new Map();41 this._connection = client._connection;42 this._connection.on(Events.Disconnected, () => this._onDisconnected());43 this._browserContextIds = new Map();44 this._version = null;45 /** @type {function():Promise} */

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({ 4 });5 const context = await browser.newContext();6 await context.setVideoRecordingOptions({7 size: {8 },9 });10 const page = await context.newPage();11 await page.click('#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-left-controls > button');12 await page.waitForTimeout(10000);13 await browser.close();14})();15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch({ 18 });19 const context = await browser.newContext();20 await context.setVideoRecordingOptions({21 size: {22 },23 });24 const page = await context.newPage();25 await page.click('#movie_player > div.ytp-chrome-bottom > div.ytp-chrome-controls > div.ytp-left-controls > button');26 await page.waitForTimeout(10000);27 await browser.close();28})();29const { chromium } = require('playwright');30(async () => {31 const browser = await chromium.launch({

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { setVideoRecordingOptions } = require('playwright-core/lib/server/deviceDescriptors');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 setVideoRecordingOptions(context, { dir: './videos' });7 const page = await context.newPage();8 await page.screenshot({ path: `example.png` });9 await browser.close();10})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require("playwright");2(async () => {3 const browser = await chromium.launch();4 const context = await browser.newContext();5 await context.setVideoRecordingOptions({6 size: { width: 1280, height: 720 },7 });8 const page = await context.newPage();9 await page.screenshot({ path: "example.png" });10 await browser.close();11})();12const { chromium } = require("playwright");13(async () => {14 const browser = await chromium.launch();15 const context = await browser.newContext();16 await context.setVideoRecordingOptions({17 size: { width: 1280, height: 720 },18 });19 const page = await context.newPage();20 await page.screenshot({ path: "example.png" });21 await browser.close();22})();23const { chromium } = require("playwright");24(async () => {25 const browser = await chromium.launch();26 const context = await browser.newContext();27 await context.setVideoRecordingOptions({28 size: { width: 1280, height: 720 },29 });30 const page = await context.newPage();31 await page.screenshot({ path: "example.png" });32 await browser.close();33})();34const { chromium } = require("playwright");35(async () => {36 const browser = await chromium.launch();37 const context = await browser.newContext();38 await context.setVideoRecordingOptions({39 size: { width: 1280, height: 720 },40 });41 const page = await context.newPage();42 await page.screenshot({ path: "example.png" });43 await browser.close();44})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2(async () => {3 const browser = await chromium.launch({headless: false});4 const context = await browser.newContext({recordVideo: { dir: 'videos/' }});5 const page = await context.newPage();6 await page.screenshot({ path: 'example.png' });7 await browser.close();8})();9const { chromium } = require('playwright');10(async () => {11 const browser = await chromium.launch({headless: false});12 const context = await browser.newContext({recordVideo: { dir: 'videos/' }});13 const page = await context.newPage();14 await page.screenshot({ path: 'example.png' });15 await browser.close();16})();17const { chromium } = require('playwright');18(async () => {19 const browser = await chromium.launch({headless: false});20 const context = await browser.newContext({recordVideo: { dir: 'videos/' }});21 const page = await context.newPage();22 await page.screenshot({ path: 'example.png' });23 await browser.close();24})();25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch({headless: false});28 const context = await browser.newContext({recordVideo: { dir: 'videos/' }});29 const page = await context.newPage();30 await page.screenshot({ path: 'example.png' });31 await browser.close();32})();33const { chromium } = require('playwright');34(async () => {35 const browser = await chromium.launch({headless: false});36 const context = await browser.newContext({recordVideo: { dir: 'videos/' }});37 const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { setVideoRecordingOptions } = require('playwright/lib/server/chromium/crBrowser');3(async () => {4 setVideoRecordingOptions({5 size: { width: 1280, height: 720 },6 });7 const browser = await chromium.launch();8 const context = await browser.newContext();9 const page = await context.newPage();10 await page.screenshot({ path: 'example.png' });11 await browser.close();12})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const browser = await chromium.launch();3const context = await browser.newContext({4 videoSize: {5 }6});7const page = await context.newPage();8const { chromium } = require('playwright');9const browser = await chromium.launch();10const context = await browser.newContext({11 videoSize: {12 }13});14const page = await context.newPage();15const { chromium } = require('playwright');16const browser = await chromium.launch();17const context = await browser.newContext({18 videoSize: {19 }20});21const page = await context.newPage();22const { chromium } = require('playwright');23const browser = await chromium.launch();24const context = await browser.newContext({25 videoSize: {26 }27});28const page = await context.newPage();29const { chromium } = require('playwright');30const browser = await chromium.launch();31const context = await browser.newContext({32 videoSize: {33 }34});35const page = await context.newPage();36const { chromium } = require('playwright');37const browser = await chromium.launch();38const context = await browser.newContext({39 videoSize: {40 }41});42const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { chromium } = require('playwright');2const { setVideoRecordingOptions } = require('playwright-core/lib/server/video/recorder');3(async () => {4 const browser = await chromium.launch();5 setVideoRecordingOptions(browser._defaultContext, { recordVideo: { dir: 'videos' } });6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.screenshot({ path: `example.png` });9 await browser.close();10})();11- Constant Rate Factor (CRF) is a quality setting for the video encoding. The lower the value, the higher the quality of the video. Defaults to

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful