How to use getRootElementsFromComponentInstance method in Playwright Internal

Best JavaScript code snippet using playwright-internal

backend.js

Source:backend.js Github

copy

Full Screen

...3299 return rect;3300 }3301 return bounds;3302}3303function getRootElementsFromComponentInstance(instance) {3304 if (instance._isFragment) {3305 const list = [];3306 const {3307 _fragmentStart,3308 _fragmentEnd3309 } = instance;3310 util().mapNodeRange(_fragmentStart, _fragmentEnd, node => {3311 list.push(node);3312 });3313 return list;3314 }3315 return [instance.$el];3316}3317exports.getRootElementsFromComponentInstance = getRootElementsFromComponentInstance;3318/***/ }),3319/***/ 18059:3320/***/ ((__unused_webpack_module, exports, __webpack_require__) => {3321"use strict";3322Object.defineProperty(exports, "__esModule", ({3323 value: true3324}));3325exports.getComponentParents = exports.walkTree = exports.functionalVnodeMap = exports.instanceMap = void 0;3326const shared_utils_1 = __webpack_require__(27146);3327const el_1 = __webpack_require__(66351);3328const util_1 = __webpack_require__(95136);3329let appRecord;3330let api;3331const consoleBoundInstances = Array(5);3332let filter = '';3333const functionalIds = new Map(); // Dedupe instances3334// Some instances may be both on a component and on a child abstract/functional component3335const captureIds = new Map();3336async function walkTree(instance, pFilter, api, ctx) {3337 initCtx(api, ctx);3338 filter = pFilter;3339 functionalIds.clear();3340 captureIds.clear();3341 const result = flatten(await findQualifiedChildren(instance));3342 return result;3343}3344exports.walkTree = walkTree;3345function getComponentParents(instance, api, ctx) {3346 initCtx(api, ctx);3347 const captureIds = new Map();3348 const captureId = vm => {3349 const id = (0, util_1.getUniqueId)(vm);3350 if (captureIds.has(id)) return;3351 captureIds.set(id, undefined);3352 mark(vm);3353 };3354 const parents = [];3355 captureId(instance);3356 let parent = instance;3357 while (parent = parent.$parent) {3358 captureId(parent);3359 parents.push(parent);3360 }3361 return parents;3362}3363exports.getComponentParents = getComponentParents;3364function initCtx(_api, ctx) {3365 appRecord = ctx.currentAppRecord;3366 api = _api;3367 if (!appRecord.meta.instanceMap) {3368 appRecord.meta.instanceMap = new Map();3369 }3370 exports.instanceMap = appRecord.meta.instanceMap;3371 if (!appRecord.meta.functionalVnodeMap) {3372 appRecord.meta.functionalVnodeMap = new Map();3373 }3374 exports.functionalVnodeMap = appRecord.meta.functionalVnodeMap;3375}3376/**3377 * Iterate through an array of instances and flatten it into3378 * an array of qualified instances. This is a depth-first3379 * traversal - e.g. if an instance is not matched, we will3380 * recursively go deeper until a qualified child is found.3381 */3382function findQualifiedChildrenFromList(instances) {3383 instances = instances.filter(child => !(0, util_1.isBeingDestroyed)(child));3384 return Promise.all(!filter ? instances.map(capture) : Array.prototype.concat.apply([], instances.map(findQualifiedChildren)));3385}3386/**3387 * Find qualified children from a single instance.3388 * If the instance itself is qualified, just return itself.3389 * This is ok because [].concat works in both cases.3390 */3391async function findQualifiedChildren(instance) {3392 if (isQualified(instance)) {3393 return [await capture(instance)];3394 } else {3395 let children = await findQualifiedChildrenFromList(instance.$children); // Find functional components in recursively in non-functional vnodes.3396 if (instance._vnode && instance._vnode.children) {3397 const list = await Promise.all(flatten(instance._vnode.children.filter(child => !child.componentInstance).map(captureChild))); // Filter qualified children.3398 const additionalChildren = list.filter(instance => isQualified(instance));3399 children = children.concat(additionalChildren);3400 }3401 return children;3402 }3403}3404/**3405 * Get children from a component instance.3406 */3407function getInternalInstanceChildren(instance) {3408 if (instance.$children) {3409 return instance.$children;3410 }3411 return [];3412}3413/**3414 * Check if an instance is qualified.3415 */3416function isQualified(instance) {3417 const name = (0, shared_utils_1.classify)((0, util_1.getInstanceName)(instance)).toLowerCase();3418 return name.indexOf(filter) > -1;3419}3420function flatten(items) {3421 const r = items.reduce((acc, item) => {3422 if (Array.isArray(item)) {3423 let children = [];3424 for (const i of item) {3425 if (Array.isArray(i)) {3426 children = children.concat(flatten(i));3427 } else {3428 children.push(i);3429 }3430 }3431 acc.push(...children);3432 } else if (item) {3433 acc.push(item);3434 }3435 return acc;3436 }, []);3437 return r;3438}3439function captureChild(child) {3440 if (child.fnContext && !child.componentInstance) {3441 return capture(child);3442 } else if (child.componentInstance) {3443 if (!(0, util_1.isBeingDestroyed)(child.componentInstance)) return capture(child.componentInstance);3444 } else if (child.children) {3445 return Promise.all(flatten(child.children.map(captureChild)));3446 }3447}3448/**3449 * Capture the meta information of an instance. (recursive)3450 */3451async function capture(instance, index, list) {3452 var _a, _b, _c, _d, _e, _f;3453 if (instance.__VUE_DEVTOOLS_FUNCTIONAL_LEGACY__) {3454 instance = instance.vnode;3455 }3456 if (instance.$options && instance.$options.abstract && instance._vnode && instance._vnode.componentInstance) {3457 instance = instance._vnode.componentInstance;3458 }3459 if ((_b = (_a = instance.$options) === null || _a === void 0 ? void 0 : _a.devtools) === null || _b === void 0 ? void 0 : _b.hide) return; // Functional component.3460 if (instance.fnContext && !instance.componentInstance) {3461 const contextUid = instance.fnContext.__VUE_DEVTOOLS_UID__;3462 let id = functionalIds.get(contextUid);3463 if (id == null) {3464 id = 0;3465 } else {3466 id++;3467 }3468 functionalIds.set(contextUid, id);3469 const functionalId = contextUid + ':functional:' + id;3470 markFunctional(functionalId, instance);3471 const childrenPromise = instance.children ? instance.children.map(child => child.fnContext ? captureChild(child) : child.componentInstance ? capture(child.componentInstance) : undefined) // router-view has both fnContext and componentInstance on vnode.3472 : instance.componentInstance ? [capture(instance.componentInstance)] : []; // await all childrenCapture to-be resolved3473 const children = (await Promise.all(childrenPromise)).filter(Boolean);3474 const treeNode = {3475 uid: functionalId,3476 id: functionalId,3477 tags: [{3478 label: 'functional',3479 textColor: 0x555555,3480 backgroundColor: 0xeeeeee3481 }],3482 name: (0, util_1.getInstanceName)(instance),3483 renderKey: (0, util_1.getRenderKey)(instance.key),3484 children,3485 hasChildren: !!children.length,3486 inactive: false,3487 isFragment: false // TODO: Check what is it for.3488 };3489 return api.visitComponentTree(instance, treeNode, filter, (_c = appRecord === null || appRecord === void 0 ? void 0 : appRecord.options) === null || _c === void 0 ? void 0 : _c.app);3490 } // instance._uid is not reliable in devtools as there3491 // may be 2 roots with same _uid which causes unexpected3492 // behaviour3493 instance.__VUE_DEVTOOLS_UID__ = (0, util_1.getUniqueId)(instance); // Dedupe3494 if (captureIds.has(instance.__VUE_DEVTOOLS_UID__)) {3495 return;3496 } else {3497 captureIds.set(instance.__VUE_DEVTOOLS_UID__, undefined);3498 }3499 mark(instance);3500 const name = (0, util_1.getInstanceName)(instance);3501 const children = (await Promise.all((await getInternalInstanceChildren(instance)).filter(child => !(0, util_1.isBeingDestroyed)(child)).map(capture))).filter(Boolean);3502 const ret = {3503 uid: instance._uid,3504 id: instance.__VUE_DEVTOOLS_UID__,3505 name,3506 renderKey: (0, util_1.getRenderKey)(instance.$vnode ? instance.$vnode.key : null),3507 inactive: !!instance._inactive,3508 isFragment: !!instance._isFragment,3509 children,3510 hasChildren: !!children.length,3511 tags: [],3512 meta: {}3513 };3514 if (instance._vnode && instance._vnode.children) {3515 const vnodeChildren = await Promise.all(flatten(instance._vnode.children.map(captureChild)));3516 ret.children = ret.children.concat(flatten(vnodeChildren).filter(Boolean));3517 ret.hasChildren = !!ret.children.length;3518 } // ensure correct ordering3519 const rootElements = (0, el_1.getRootElementsFromComponentInstance)(instance);3520 const firstElement = rootElements[0];3521 if (firstElement === null || firstElement === void 0 ? void 0 : firstElement.parentElement) {3522 const parentInstance = instance.$parent;3523 const parentRootElements = parentInstance ? (0, el_1.getRootElementsFromComponentInstance)(parentInstance) : [];3524 let el = firstElement;3525 const indexList = [];3526 do {3527 indexList.push(Array.from(el.parentElement.childNodes).indexOf(el));3528 el = el.parentElement;3529 } while (el.parentElement && parentRootElements.length && !parentRootElements.includes(el));3530 ret.domOrder = indexList.reverse();3531 } else {3532 ret.domOrder = [-1];3533 } // check if instance is available in console3534 const consoleId = consoleBoundInstances.indexOf(instance.__VUE_DEVTOOLS_UID__);3535 ret.consoleId = consoleId > -1 ? '$vm' + consoleId : null; // check router view3536 const isRouterView2 = (_e = (_d = instance.$vnode) === null || _d === void 0 ? void 0 : _d.data) === null || _e === void 0 ? void 0 : _e.routerView;3537 if (instance._routerView || isRouterView2) {3538 ret.isRouterView = true;3539 if (!instance._inactive && instance.$route) {3540 const matched = instance.$route.matched;3541 const depth = isRouterView2 ? instance.$vnode.data.routerViewDepth : instance._routerView.depth;3542 ret.meta.matchedRouteSegment = matched && matched[depth] && (isRouterView2 ? matched[depth].path : matched[depth].handler.path);3543 }3544 ret.tags.push({3545 label: `router-view${ret.meta.matchedRouteSegment ? `: ${ret.meta.matchedRouteSegment}` : ''}`,3546 textColor: 0x000000,3547 backgroundColor: 0xff83443548 });3549 }3550 return api.visitComponentTree(instance, ret, filter, (_f = appRecord === null || appRecord === void 0 ? void 0 : appRecord.options) === null || _f === void 0 ? void 0 : _f.app);3551}3552/**3553 * Mark an instance as captured and store it in the instance map.3554 *3555 * @param {Vue} instance3556 */3557function mark(instance) {3558 const refId = instance.__VUE_DEVTOOLS_UID__;3559 if (!exports.instanceMap.has(refId)) {3560 exports.instanceMap.set(refId, instance);3561 appRecord.instanceMap.set(refId, instance);3562 instance.$on('hook:beforeDestroy', function () {3563 exports.instanceMap.delete(refId);3564 });3565 }3566}3567function markFunctional(id, vnode) {3568 const refId = vnode.fnContext.__VUE_DEVTOOLS_UID__;3569 if (!exports.functionalVnodeMap.has(refId)) {3570 exports.functionalVnodeMap.set(refId, {});3571 vnode.fnContext.$on('hook:beforeDestroy', function () {3572 exports.functionalVnodeMap.delete(refId);3573 });3574 }3575 exports.functionalVnodeMap.get(refId)[id] = vnode;3576 appRecord.instanceMap.set(id, {3577 __VUE_DEVTOOLS_UID__: id,3578 __VUE_DEVTOOLS_FUNCTIONAL_LEGACY__: true,3579 vnode3580 });3581}3582/***/ }),3583/***/ 95136:3584/***/ ((__unused_webpack_module, exports, __webpack_require__) => {3585"use strict";3586Object.defineProperty(exports, "__esModule", ({3587 value: true3588}));3589exports.getUniqueId = exports.getRenderKey = exports.getInstanceName = exports.isBeingDestroyed = void 0;3590const shared_utils_1 = __webpack_require__(27146);3591function isBeingDestroyed(instance) {3592 return instance._isBeingDestroyed;3593}3594exports.isBeingDestroyed = isBeingDestroyed;3595/**3596 * Get the appropriate display name for an instance.3597 */3598function getInstanceName(instance) {3599 const name = (0, shared_utils_1.getComponentName)(instance.$options || instance.fnOptions || {});3600 if (name) return name;3601 return instance.$root === instance ? 'Root' : 'Anonymous Component';3602}3603exports.getInstanceName = getInstanceName;3604function getRenderKey(value) {3605 if (value == null) return;3606 const type = typeof value;3607 if (type === 'number') {3608 return value.toString();3609 } else if (type === 'string') {3610 return `'${value}'`;3611 } else if (Array.isArray(value)) {3612 return 'Array';3613 } else {3614 return 'Object';3615 }3616}3617exports.getRenderKey = getRenderKey;3618/**3619 * Returns a devtools unique id for instance.3620 */3621function getUniqueId(instance) {3622 if (instance.__VUE_DEVTOOLS_UID__ != null) return instance.__VUE_DEVTOOLS_UID__;3623 const rootVueId = instance.$root.__VUE_DEVTOOLS_APP_RECORD_ID__;3624 return `${rootVueId}:${instance._uid}`;3625}3626exports.getUniqueId = getUniqueId;3627/***/ }),3628/***/ 16935:3629/***/ ((__unused_webpack_module, exports, __webpack_require__) => {3630"use strict";3631Object.defineProperty(exports, "__esModule", ({3632 value: true3633}));3634exports.wrapVueForEvents = void 0;3635const shared_utils_1 = __webpack_require__(27146);3636const internalRE = /^(?:pre-)?hook:/;3637function wrap(app, Vue, method, ctx) {3638 const original = Vue.prototype[method];3639 if (original) {3640 Vue.prototype[method] = function (...args) {3641 const res = original.apply(this, args);3642 logEvent(this, method, args[0], args.slice(1));3643 return res;3644 };3645 }3646 function logEvent(vm, type, eventName, payload) {3647 // The string check is important for compat with 1.x where the first3648 // argument may be an object instead of a string.3649 // this also ensures the event is only logged for direct $emit (source)3650 // instead of by $dispatch/$broadcast3651 if (typeof eventName === 'string' && !internalRE.test(eventName)) {3652 const instance = vm._self || vm;3653 ctx.hook.emit(shared_utils_1.HookEvents.COMPONENT_EMIT, app, instance, eventName, payload);3654 }3655 }3656}3657function wrapVueForEvents(app, Vue, ctx) {3658 ['$emit', '$broadcast', '$dispatch'].forEach(method => {3659 wrap(app, Vue, method, ctx);3660 });3661}3662exports.wrapVueForEvents = wrapVueForEvents;3663/***/ }),3664/***/ 88690:3665/***/ ((__unused_webpack_module, exports, __webpack_require__) => {3666"use strict";3667Object.defineProperty(exports, "__esModule", ({3668 value: true3669}));3670exports.backend = void 0;3671const app_backend_api_1 = __webpack_require__(64803);3672const shared_utils_1 = __webpack_require__(27146);3673const data_1 = __webpack_require__(4465);3674const el_1 = __webpack_require__(66351);3675const tree_1 = __webpack_require__(18059);3676const util_1 = __webpack_require__(95136);3677const events_1 = __webpack_require__(16935);3678const plugin_1 = __webpack_require__(7725);3679exports.backend = (0, app_backend_api_1.defineBackend)({3680 frameworkVersion: 2,3681 features: [app_backend_api_1.BuiltinBackendFeature.FLUSH],3682 setup(api) {3683 api.on.getAppRecordName(payload => {3684 if (payload.app.name) {3685 payload.name = payload.app.name;3686 } else if (payload.app.$options.name) {3687 payload.name = payload.app.$options.name;3688 }3689 });3690 api.on.getAppRootInstance(payload => {3691 payload.root = payload.app;3692 });3693 api.on.walkComponentTree(async (payload, ctx) => {3694 payload.componentTreeData = await (0, tree_1.walkTree)(payload.componentInstance, payload.filter, api, ctx);3695 });3696 api.on.walkComponentParents((payload, ctx) => {3697 payload.parentInstances = (0, tree_1.getComponentParents)(payload.componentInstance, api, ctx);3698 });3699 api.on.inspectComponent(payload => {3700 injectToUtils();3701 payload.instanceData = (0, data_1.getInstanceDetails)(payload.componentInstance);3702 });3703 api.on.getComponentBounds(payload => {3704 payload.bounds = (0, el_1.getInstanceOrVnodeRect)(payload.componentInstance);3705 });3706 api.on.getComponentName(payload => {3707 const instance = payload.componentInstance;3708 payload.name = instance.fnContext ? (0, shared_utils_1.getComponentName)(instance.fnOptions) : (0, util_1.getInstanceName)(instance);3709 });3710 api.on.getElementComponent(payload => {3711 payload.componentInstance = (0, el_1.findRelatedComponent)(payload.element);3712 });3713 api.on.editComponentState(payload => {3714 (0, data_1.editState)(payload, api.stateEditor);3715 });3716 api.on.getComponentRootElements(payload => {3717 payload.rootElements = (0, el_1.getRootElementsFromComponentInstance)(payload.componentInstance);3718 });3719 api.on.getComponentDevtoolsOptions(payload => {3720 payload.options = payload.componentInstance.$options.devtools;3721 });3722 api.on.getComponentRenderCode(payload => {3723 payload.code = payload.componentInstance.$options.render.toString();3724 });3725 api.on.getComponentInstances(() => {3726 console.warn('on.getComponentInstances is not implemented for Vue 2');3727 });3728 },3729 setupApp(api, appRecord) {3730 const {3731 Vue3732 } = appRecord.options.meta;3733 const app = appRecord.options.app; // State editor overrides3734 api.stateEditor.createDefaultSetCallback = state => {3735 return (obj, field, value) => {3736 if (state.remove || state.newKey) Vue.delete(obj, field);3737 if (!state.remove) Vue.set(obj, state.newKey || field, value);3738 };3739 }; // Utils3740 injectToUtils();3741 (0, events_1.wrapVueForEvents)(app, Vue, api.ctx); // Plugin3742 (0, plugin_1.setupPlugin)(api, app, Vue);3743 }3744}); // @TODO refactor3745function injectToUtils() {3746 shared_utils_1.backendInjections.getCustomInstanceDetails = data_1.getCustomInstanceDetails;3747 shared_utils_1.backendInjections.instanceMap = tree_1.instanceMap;3748 shared_utils_1.backendInjections.isVueInstance = val => val._isVue;3749}3750/***/ }),3751/***/ 7725:3752/***/ (function(__unused_webpack_module, exports, __webpack_require__) {3753"use strict";3754var __importDefault = this && this.__importDefault || function (mod) {3755 return mod && mod.__esModule ? mod : {3756 "default": mod3757 };3758};3759Object.defineProperty(exports, "__esModule", ({3760 value: true3761}));3762exports.setupPlugin = void 0;3763const devtools_api_1 = __webpack_require__(72039);3764const shared_utils_1 = __webpack_require__(27146);3765const clone_deep_1 = __importDefault(__webpack_require__(96206));3766let actionId = 0;3767function setupPlugin(api, app, Vue) {3768 const ROUTER_INSPECTOR_ID = 'vue2-router-inspector';3769 const ROUTER_CHANGES_LAYER_ID = 'vue2-router-changes';3770 const VUEX_INSPECTOR_ID = 'vue2-vuex-inspector';3771 const VUEX_MUTATIONS_ID = 'vue2-vuex-mutations';3772 const VUEX_ACTIONS_ID = 'vue2-vuex-actions';3773 (0, devtools_api_1.setupDevtoolsPlugin)({3774 app,3775 id: 'org.vuejs.vue2-internal',3776 label: 'Vue 2',3777 homepage: 'https://vuejs.org/',3778 logo: 'https://vuejs.org/images/icons/favicon-96x96.png'3779 }, api => {3780 const hook = shared_utils_1.target.__VUE_DEVTOOLS_GLOBAL_HOOK__; // Vue Router3781 if (app.$router) {3782 const router = app.$router; // Inspector3783 api.addInspector({3784 id: ROUTER_INSPECTOR_ID,3785 label: 'Routes',3786 icon: 'book',3787 treeFilterPlaceholder: 'Search routes'3788 });3789 api.on.getInspectorTree(payload => {3790 if (payload.inspectorId === ROUTER_INSPECTOR_ID) {3791 payload.rootNodes = router.options.routes.map(route => formatRouteNode(router, route, '', payload.filter)).filter(Boolean);3792 }3793 });3794 api.on.getInspectorState(payload => {3795 if (payload.inspectorId === ROUTER_INSPECTOR_ID) {3796 const route = router.matcher.getRoutes().find(r => getPathId(r) === payload.nodeId);3797 if (route) {3798 payload.state = {3799 options: formatRouteData(route)3800 };3801 }3802 }3803 }); // Timeline3804 api.addTimelineLayer({3805 id: ROUTER_CHANGES_LAYER_ID,3806 label: 'Router Navigations',3807 color: 0x40a8c43808 });3809 router.afterEach((to, from) => {3810 api.addTimelineEvent({3811 layerId: ROUTER_CHANGES_LAYER_ID,3812 event: {3813 time: Date.now(),3814 title: to.path,3815 data: {3816 from,3817 to3818 }3819 }3820 });3821 api.sendInspectorTree(ROUTER_INSPECTOR_ID);3822 });3823 } // Vuex3824 if (app.$store) {3825 const store = app.$store;3826 api.addInspector({3827 id: VUEX_INSPECTOR_ID,3828 label: 'Vuex',3829 icon: 'storage',3830 treeFilterPlaceholder: 'Filter stores...'3831 });3832 api.on.getInspectorTree(payload => {3833 if (payload.inspectorId === VUEX_INSPECTOR_ID) {3834 if (payload.filter) {3835 const nodes = [];3836 flattenStoreForInspectorTree(nodes, store._modules.root, payload.filter, '');3837 payload.rootNodes = nodes;3838 } else {3839 payload.rootNodes = [formatStoreForInspectorTree(store._modules.root, '')];3840 }3841 }3842 });3843 api.on.getInspectorState(payload => {3844 if (payload.inspectorId === VUEX_INSPECTOR_ID) {3845 const modulePath = payload.nodeId;3846 const module = getStoreModule(store._modules, modulePath); // Access the getters prop to init getters cache (which is lazy)3847 // eslint-disable-next-line no-unused-expressions3848 module.context.getters;3849 payload.state = formatStoreForInspectorState(module, store._makeLocalGettersCache, modulePath);3850 }3851 });3852 api.addTimelineLayer({3853 id: VUEX_MUTATIONS_ID,3854 label: 'Vuex Mutations',3855 color: LIME_5003856 });3857 api.addTimelineLayer({3858 id: VUEX_ACTIONS_ID,3859 label: 'Vuex Actions',3860 color: LIME_5003861 });3862 hook.on('vuex:mutation', (mutation, state) => {3863 api.sendInspectorState(VUEX_INSPECTOR_ID);3864 const data = {};3865 if (mutation.payload) {3866 data.payload = mutation.payload;3867 }3868 data.state = (0, clone_deep_1.default)(state);3869 api.addTimelineEvent({3870 layerId: VUEX_MUTATIONS_ID,3871 event: {3872 time: Date.now(),3873 title: mutation.type,3874 data3875 }3876 });3877 });3878 store.subscribeAction({3879 before: (action, state) => {3880 const data = {};3881 if (action.payload) {3882 data.payload = action.payload;3883 }3884 action._id = actionId++;3885 action._time = Date.now();3886 data.state = state;3887 api.addTimelineEvent({3888 layerId: VUEX_ACTIONS_ID,3889 event: {3890 time: action._time,3891 title: action.type,3892 groupId: action._id,3893 subtitle: 'start',3894 data3895 }3896 });3897 },3898 after: (action, state) => {3899 const data = {};3900 const duration = Date.now() - action._time;3901 data.duration = {3902 _custom: {3903 type: 'duration',3904 display: `${duration}ms`,3905 tooltip: 'Action duration',3906 value: duration3907 }3908 };3909 if (action.payload) {3910 data.payload = action.payload;3911 }3912 data.state = state;3913 api.addTimelineEvent({3914 layerId: VUEX_ACTIONS_ID,3915 event: {3916 time: Date.now(),3917 title: action.type,3918 groupId: action._id,3919 subtitle: 'end',3920 data3921 }3922 });3923 }3924 }, {3925 prepend: true3926 }); // Inspect getters on mutations3927 api.on.inspectTimelineEvent(payload => {3928 if (payload.layerId === VUEX_MUTATIONS_ID) {3929 const getterKeys = Object.keys(store.getters);3930 if (getterKeys.length) {3931 const vm = new Vue({3932 data: {3933 $$state: payload.data.state3934 },3935 computed: store._vm.$options.computed3936 });3937 const originalVm = store._vm;3938 store._vm = vm;3939 const tree = transformPathsToObjectTree(store.getters);3940 payload.data.getters = (0, clone_deep_1.default)(tree);3941 store._vm = originalVm;3942 vm.$destroy();3943 }3944 }3945 });3946 }3947 });3948}3949exports.setupPlugin = setupPlugin;3950/**3951 * Extracted from tailwind palette3952 */3953const BLUE_600 = 0x2563eb;3954const LIME_500 = 0x84cc16;3955const CYAN_400 = 0x22d3ee;3956const ORANGE_400 = 0xfb923c;3957const WHITE = 0xffffff;3958const DARK = 0x666666;3959function formatRouteNode(router, route, parentPath, filter) {3960 var _a, _b;3961 const node = {3962 id: parentPath + route.path,3963 label: route.path,3964 children: (_a = route.children) === null || _a === void 0 ? void 0 : _a.map(child => formatRouteNode(router, child, route.path, filter)).filter(Boolean),3965 tags: []3966 };3967 if (filter && !node.id.includes(filter) && !((_b = node.children) === null || _b === void 0 ? void 0 : _b.length)) return null;3968 if (route.name != null) {3969 node.tags.push({3970 label: String(route.name),3971 textColor: 0,3972 backgroundColor: CYAN_4003973 });3974 }3975 if (route.alias != null) {3976 node.tags.push({3977 label: 'alias',3978 textColor: 0,3979 backgroundColor: ORANGE_4003980 });3981 }3982 const currentPath = router.currentRoute.matched.reduce((p, m) => p + m.path, '');3983 if (node.id === currentPath) {3984 node.tags.push({3985 label: 'active',3986 textColor: WHITE,3987 backgroundColor: BLUE_6003988 });3989 }3990 if (route.redirect) {3991 node.tags.push({3992 label: 'redirect: ' + (typeof route.redirect === 'string' ? route.redirect : 'Object'),3993 textColor: WHITE,3994 backgroundColor: DARK3995 });3996 }3997 return node;3998}3999function formatRouteData(route) {4000 const data = [];4001 data.push({4002 key: 'path',4003 value: route.path4004 });4005 if (route.redirect) {4006 data.push({4007 key: 'redirect',4008 value: route.redirect4009 });4010 }4011 if (route.alias) {4012 data.push({4013 key: 'alias',4014 value: route.alias4015 });4016 }4017 if (route.props) {4018 data.push({4019 key: 'props',4020 value: route.props4021 });4022 }4023 if (route.name && route.name != null) {4024 data.push({4025 key: 'name',4026 value: route.name4027 });4028 }4029 if (route.component) {4030 const component = {}; // if (route.component.__file) {4031 // component.file = route.component.__file4032 // }4033 if (route.component.template) {4034 component.template = route.component.template;4035 }4036 if (route.component.props) {4037 component.props = route.component.props;4038 }4039 if (!(0, shared_utils_1.isEmptyObject)(component)) {4040 data.push({4041 key: 'component',4042 value: component4043 });4044 }4045 }4046 return data;4047}4048function getPathId(routeMatcher) {4049 let path = routeMatcher.path;4050 if (routeMatcher.parent) {4051 path = getPathId(routeMatcher.parent) + path;4052 }4053 return path;4054}4055const TAG_NAMESPACED = {4056 label: 'namespaced',4057 textColor: WHITE,4058 backgroundColor: DARK4059};4060function formatStoreForInspectorTree(module, path) {4061 return {4062 id: path || 'root',4063 // all modules end with a `/`, we want the last segment only4064 // cart/ -> cart4065 // nested/cart/ -> cart4066 label: extractNameFromPath(path),4067 tags: module.namespaced ? [TAG_NAMESPACED] : [],4068 children: Object.keys(module._children).map(moduleName => formatStoreForInspectorTree(module._children[moduleName], path + moduleName + '/'))4069 };4070}4071function flattenStoreForInspectorTree(result, module, filter, path) {4072 if (path.includes(filter)) {4073 result.push({4074 id: path || 'root',4075 label: path.endsWith('/') ? path.slice(0, path.length - 1) : path || 'Root',4076 tags: module.namespaced ? [TAG_NAMESPACED] : []4077 });4078 }4079 Object.keys(module._children).forEach(moduleName => {4080 flattenStoreForInspectorTree(result, module._children[moduleName], filter, path + moduleName + '/');4081 });4082}4083function extractNameFromPath(path) {4084 return path && path !== 'root' ? path.split('/').slice(-2, -1)[0] : 'Root';4085}4086function formatStoreForInspectorState(module, getters, path) {4087 getters = !module.namespaced || path === 'root' ? module.context.getters : getters[path];4088 const gettersKeys = Object.keys(getters);4089 const storeState = {4090 state: Object.keys(module.state).map(key => ({4091 key,4092 editable: true,4093 value: module.state[key]4094 }))4095 };4096 if (gettersKeys.length) {4097 const tree = transformPathsToObjectTree(getters);4098 storeState.getters = Object.keys(tree).map(key => ({4099 key: key.endsWith('/') ? extractNameFromPath(key) : key,4100 editable: false,4101 value: canThrow(() => tree[key])4102 }));4103 }4104 return storeState;4105}4106function transformPathsToObjectTree(getters) {4107 const result = {};4108 Object.keys(getters).forEach(key => {4109 const path = key.split('/');4110 if (path.length > 1) {4111 let target = result;4112 const leafKey = path.pop();4113 for (const p of path) {4114 if (!target[p]) {4115 target[p] = {4116 _custom: {4117 value: {},4118 display: p,4119 tooltip: 'Module',4120 abstract: true4121 }4122 };4123 }4124 target = target[p]._custom.value;4125 }4126 target[leafKey] = canThrow(() => getters[key]);4127 } else {4128 result[key] = canThrow(() => getters[key]);4129 }4130 });4131 return result;4132}4133function getStoreModule(moduleMap, path) {4134 const names = path.split('/').filter(n => n);4135 return names.reduce((module, moduleName, i) => {4136 const child = module[moduleName];4137 if (!child) {4138 throw new Error(`Missing module "${moduleName}" for path "${path}".`);4139 }4140 return i === names.length - 1 ? child : child._children;4141 }, path === 'root' ? moduleMap : moduleMap.root._children);4142}4143function canThrow(cb) {4144 try {4145 return cb();4146 } catch (e) {4147 return e;4148 }4149}4150/***/ }),4151/***/ 42054:4152/***/ ((__unused_webpack_module, exports, __webpack_require__) => {4153"use strict";4154Object.defineProperty(exports, "__esModule", ({4155 value: true4156}));4157exports.getCustomInstanceDetails = exports.editState = exports.getInstanceDetails = void 0;4158const util_1 = __webpack_require__(33756);4159const shared_utils_1 = __webpack_require__(27146);4160const util_2 = __webpack_require__(77858);4161/**4162 * Get the detailed information of an inspected instance.4163 */4164function getInstanceDetails(instance, ctx) {4165 var _a;4166 return {4167 id: (0, util_1.getUniqueComponentId)(instance, ctx),4168 name: (0, util_1.getInstanceName)(instance),4169 file: (_a = instance.type) === null || _a === void 0 ? void 0 : _a.__file,4170 state: getInstanceState(instance)4171 };4172}4173exports.getInstanceDetails = getInstanceDetails;4174function getInstanceState(instance) {4175 const mergedType = resolveMergedOptions(instance);4176 return processProps(instance).concat(processState(instance), processSetupState(instance), processComputed(instance, mergedType), processAttrs(instance), processProvide(instance), processInject(instance, mergedType), processRefs(instance));4177}4178/**4179 * Process the props of an instance.4180 * Make sure return a plain object because window.postMessage()4181 * will throw an Error if the passed object contains Functions.4182 *4183 * @param {Vue} instance4184 * @return {Array}4185 */4186function processProps(instance) {4187 const propsData = [];4188 const propDefinitions = instance.type.props;4189 for (let key in instance.props) {4190 const propDefinition = propDefinitions ? propDefinitions[key] : null;4191 key = (0, shared_utils_1.camelize)(key);4192 propsData.push({4193 type: 'props',4194 key,4195 value: (0, util_2.returnError)(() => instance.props[key]),4196 meta: propDefinition ? {4197 type: propDefinition.type ? getPropType(propDefinition.type) : 'any',4198 required: !!propDefinition.required,4199 ...(propDefinition.default != null ? {4200 default: propDefinition.default.toString()4201 } : {})4202 } : {4203 type: 'invalid'4204 },4205 editable: shared_utils_1.SharedData.editableProps4206 });4207 }4208 return propsData;4209}4210const fnTypeRE = /^(?:function|class) (\w+)/;4211/**4212 * Convert prop type constructor to string.4213 */4214function getPropType(type) {4215 if (Array.isArray(type)) {4216 return type.map(t => getPropType(t)).join(' or ');4217 }4218 if (type == null) {4219 return 'null';4220 }4221 const match = type.toString().match(fnTypeRE);4222 return typeof type === 'function' ? match && match[1] || 'any' : 'any';4223}4224/**4225 * Process state, filtering out props and "clean" the result4226 * with a JSON dance. This removes functions which can cause4227 * errors during structured clone used by window.postMessage.4228 *4229 * @param {Vue} instance4230 * @return {Array}4231 */4232function processState(instance) {4233 const type = instance.type;4234 const props = type.props;4235 const getters = type.vuex && type.vuex.getters;4236 const computedDefs = type.computed;4237 const data = { ...instance.data,4238 ...instance.renderContext4239 };4240 return Object.keys(data).filter(key => !(props && key in props) && !(getters && key in getters) && !(computedDefs && key in computedDefs)).map(key => ({4241 key,4242 type: 'data',4243 value: (0, util_2.returnError)(() => data[key]),4244 editable: true4245 }));4246}4247function processSetupState(instance) {4248 const raw = instance.devtoolsRawSetupState || {};4249 return Object.keys(instance.setupState).map(key => {4250 var _a, _b, _c, _d;4251 const value = (0, util_2.returnError)(() => instance.setupState[key]);4252 const rawData = raw[key];4253 let result;4254 if (rawData) {4255 const info = getSetupStateInfo(rawData);4256 const objectType = info.computed ? 'Computed' : info.ref ? 'Ref' : info.reactive ? 'Reactive' : null;4257 const isState = info.ref || info.computed || info.reactive;4258 const isOther = typeof value === 'function' || typeof (value === null || value === void 0 ? void 0 : value.render) === 'function';4259 const raw = ((_b = (_a = rawData.effect) === null || _a === void 0 ? void 0 : _a.raw) === null || _b === void 0 ? void 0 : _b.toString()) || ((_d = (_c = rawData.effect) === null || _c === void 0 ? void 0 : _c.fn) === null || _d === void 0 ? void 0 : _d.toString());4260 result = { ...(objectType ? {4261 objectType4262 } : {}),4263 ...(raw ? {4264 raw4265 } : {}),4266 editable: isState && !info.readonly,4267 type: isOther ? 'setup (other)' : 'setup'4268 };4269 } else {4270 result = {4271 type: 'setup'4272 };4273 }4274 return {4275 key,4276 value,4277 ...result4278 };4279 });4280}4281function isRef(raw) {4282 return !!raw.__v_isRef;4283}4284function isComputed(raw) {4285 return isRef(raw) && !!raw.effect;4286}4287function isReactive(raw) {4288 return !!raw.__v_isReactive;4289}4290function isReadOnly(raw) {4291 return !!raw.__v_isReadonly;4292}4293function getSetupStateInfo(raw) {4294 return {4295 ref: isRef(raw),4296 computed: isComputed(raw),4297 reactive: isReactive(raw),4298 readonly: isReadOnly(raw)4299 };4300}4301/**4302 * Process the computed properties of an instance.4303 *4304 * @param {Vue} instance4305 * @return {Array}4306 */4307function processComputed(instance, mergedType) {4308 const type = mergedType;4309 const computed = [];4310 const defs = type.computed || {}; // use for...in here because if 'computed' is not defined4311 // on component, computed properties will be placed in prototype4312 // and Object.keys does not include4313 // properties from object's prototype4314 for (const key in defs) {4315 const def = defs[key];4316 const type = typeof def === 'function' && def.vuex ? 'vuex bindings' : 'computed';4317 computed.push({4318 type,4319 key,4320 value: (0, util_2.returnError)(() => instance.proxy[key]),4321 editable: typeof def.set === 'function'4322 });4323 }4324 return computed;4325}4326function processAttrs(instance) {4327 return Object.keys(instance.attrs).map(key => ({4328 type: 'attrs',4329 key,4330 value: (0, util_2.returnError)(() => instance.attrs[key])4331 }));4332}4333function processProvide(instance) {4334 return Object.keys(instance.provides).map(key => ({4335 type: 'provided',4336 key,4337 value: (0, util_2.returnError)(() => instance.provides[key])4338 }));4339}4340function processInject(instance, mergedType) {4341 if (!(mergedType === null || mergedType === void 0 ? void 0 : mergedType.inject)) return [];4342 let keys = [];4343 if (Array.isArray(mergedType.inject)) {4344 keys = mergedType.inject.map(key => ({4345 key,4346 originalKey: key4347 }));4348 } else {4349 keys = Object.keys(mergedType.inject).map(key => {4350 const value = mergedType.inject[key];4351 let originalKey;4352 if (typeof value === 'string') {4353 originalKey = value;4354 } else {4355 originalKey = value.from;4356 }4357 return {4358 key,4359 originalKey4360 };4361 });4362 }4363 return keys.map(({4364 key,4365 originalKey4366 }) => ({4367 type: 'injected',4368 key: originalKey && key !== originalKey ? `${originalKey} ➞ ${key}` : key,4369 value: (0, util_2.returnError)(() => instance.ctx[key])4370 }));4371}4372function processRefs(instance) {4373 return Object.keys(instance.refs).map(key => ({4374 type: 'refs',4375 key,4376 value: (0, util_2.returnError)(() => instance.refs[key])4377 }));4378}4379function editState({4380 componentInstance,4381 path,4382 state,4383 type4384}, stateEditor, ctx) {4385 if (!['data', 'props', 'computed', 'setup'].includes(type)) return;4386 let target;4387 const targetPath = path.slice();4388 if (Object.keys(componentInstance.props).includes(path[0])) {4389 // Props4390 target = componentInstance.props;4391 } else if (componentInstance.devtoolsRawSetupState && Object.keys(componentInstance.devtoolsRawSetupState).includes(path[0])) {4392 // Setup4393 target = componentInstance.devtoolsRawSetupState;4394 const currentValue = stateEditor.get(componentInstance.devtoolsRawSetupState, path);4395 if (currentValue != null) {4396 const info = getSetupStateInfo(currentValue);4397 if (info.readonly) return;4398 }4399 } else {4400 target = componentInstance.proxy;4401 }4402 if (target && targetPath) {4403 stateEditor.set(target, targetPath, 'value' in state ? state.value : undefined, stateEditor.createDefaultSetCallback(state));4404 }4405}4406exports.editState = editState;4407function reduceStateList(list) {4408 if (!list.length) {4409 return undefined;4410 }4411 return list.reduce((map, item) => {4412 const key = item.type || 'data';4413 const obj = map[key] = map[key] || {};4414 obj[item.key] = item.value;4415 return map;4416 }, {});4417}4418function getCustomInstanceDetails(instance) {4419 if (instance._) instance = instance._;4420 const state = getInstanceState(instance);4421 return {4422 _custom: {4423 type: 'component',4424 id: instance.__VUE_DEVTOOLS_UID__,4425 display: (0, util_1.getInstanceName)(instance),4426 tooltip: 'Component instance',4427 value: reduceStateList(state),4428 fields: {4429 abstract: true4430 }4431 }4432 };4433}4434exports.getCustomInstanceDetails = getCustomInstanceDetails;4435function resolveMergedOptions(instance) {4436 const raw = instance.type;4437 const {4438 mixins,4439 extends: extendsOptions4440 } = raw;4441 const globalMixins = instance.appContext.mixins;4442 if (!globalMixins.length && !mixins && !extendsOptions) return raw;4443 const options = {};4444 globalMixins.forEach(m => mergeOptions(options, m, instance));4445 mergeOptions(options, raw, instance);4446 return options;4447}4448function mergeOptions(to, from, instance) {4449 if (typeof from === 'function') {4450 from = from.options;4451 }4452 if (!from) return to;4453 const {4454 mixins,4455 extends: extendsOptions4456 } = from;4457 extendsOptions && mergeOptions(to, extendsOptions, instance);4458 mixins && mixins.forEach(m => mergeOptions(to, m, instance));4459 for (const key of ['computed', 'inject']) {4460 if (Object.prototype.hasOwnProperty.call(from, key)) {4461 if (!to[key]) {4462 to[key] = from[key];4463 } else {4464 Object.assign(to[key], from[key]);4465 }4466 }4467 }4468 return to;4469}4470/***/ }),4471/***/ 88722:4472/***/ ((__unused_webpack_module, exports, __webpack_require__) => {4473"use strict";4474Object.defineProperty(exports, "__esModule", ({4475 value: true4476}));4477exports.getInstanceOrVnodeRect = exports.getRootElementsFromComponentInstance = exports.getComponentInstanceFromElement = void 0;4478const shared_utils_1 = __webpack_require__(27146);4479const util_1 = __webpack_require__(33756);4480function getComponentInstanceFromElement(element) {4481 return element.__vueParentComponent;4482}4483exports.getComponentInstanceFromElement = getComponentInstanceFromElement;4484function getRootElementsFromComponentInstance(instance) {4485 if ((0, util_1.isFragment)(instance)) {4486 return getFragmentRootElements(instance.subTree);4487 }4488 return [instance.subTree.el];4489}4490exports.getRootElementsFromComponentInstance = getRootElementsFromComponentInstance;4491function getFragmentRootElements(vnode) {4492 if (!vnode.children) return [];4493 const list = [];4494 for (let i = 0, l = vnode.children.length; i < l; i++) {4495 const childVnode = vnode.children[i];4496 if (childVnode.component) {4497 list.push(...getRootElementsFromComponentInstance(childVnode.component));4498 } else if (childVnode.el) {4499 list.push(childVnode.el);4500 }4501 }4502 return list;4503}4504/**4505 * Get the client rect for an instance.4506 *4507 * @param {Vue|Vnode} instance4508 * @return {Object}4509 */4510function getInstanceOrVnodeRect(instance) {4511 const el = instance.subTree.el;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const [root] = await getRootElementsFromComponentInstance(page, 'google');8 console.log(root);9 await browser.close();10})();11ElementHandle {12 _context: BrowserContext {13 _closeCallback: [Function (anonymous)],14 _didCloseCallback: [Function (anonymous)],15 _didFirstPageCallback: [Function (anonymous)],16 },17 _channel: Connection {

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom.js');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const rootElements = await getRootElementsFromComponentInstance(page);7 console.log(rootElements);8 await browser.close();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');2const { chromium } = require('playwright');3(async () => {4 const browser = await chromium.launch();5 const page = await browser.newPage();6 const element = await page.$('body');7 const rootElements = await getRootElementsFromComponentInstance(element);8 console.log(rootElements);9 await browser.close();10})();11 {12 _remoteObject: {13 objectId: '{"injectedScriptId":1,"id":1}',14 },15 }

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getRootElementsFromComponentInstance } = require('playwright/lib/webkit/webkit');2const { webkit } = require('playwright');3(async () => {4 const browser = await webkit.launch();5 const context = await browser.newContext();6 const page = await context.newPage();7 const rootElements = await getRootElementsFromComponentInstance(page);8 console.log(rootElements);9 await browser.close();10})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');2const { chromium } = require('playwright');3const path = require('path');4(async () => {5 const browser = await chromium.launch();6 const page = await browser.newPage();7 const rootElements = await getRootElementsFromComponentInstance(page, 'my-component');8 console.log(rootElements);9 await browser.close();10})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');2const { chromium } = require('playwright');3(async () => {4const browser = await chromium.launch();5const context = await browser.newContext();6const page = await context.newPage();7const handle = await page.$('input');8const rootElements = await getRootElementsFromComponentInstance(page, handle);9console.log(rootElements);10await browser.close();11})();12{ type: 'node', name:

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');2const { createPageInNewContext } = require('playwright/lib/server/browserContext');3const { chromium } = require('playwright');4(async () => {5 const browser = await chromium.launch();6 const context = await browser.newContext();7 const page = await context.newPage();8 await page.setContent('<div><span>span1</span><span>span2</span></div>');9 const rootElements = await getRootElementsFromComponentInstance(page, 'div');10 console.log(rootElements);11 await browser.close();12})();13Output: [{type: "node", value: {…}}, {type: "node", value: {…}}]14const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');15const { chromium } = require('playwright');16(async () => {17 const browser = await chromium.launch();18 const context = await browser.newContext();19 const page = await context.newPage();20 const rootElements = await getRootElementsFromComponentInstance(page, 'header');21 console.log(rootElements);22 await browser.close();23})();24const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');25const { chromium } = require('playwright');26(async () => {27 const browser = await chromium.launch();28 const context = await browser.newContext();29 const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');2const { chromium } = require('playwright');3const { readFileSync } = require('fs');4const { join } = require('path');5(async () => {6 const browser = await chromium.launch();7 const context = await browser.newContext();8 const page = await context.newPage();9 await page.setContent(readFileSync(join(__dirname, 'index.html'), 'utf8'));10 const root = await getRootElementsFromComponentInstance(page.mainFrame(), 'my-component');11 console.log('Root element of the component: ', root);12 await browser.close();13})();14class MyComponent extends HTMLElement {15 constructor() {16 super();17 this.attachShadow({ mode: 'open' });18 }19}20customElements.define('my-component', MyComponent);21h1 {22 color: red;23}24const { shadowRoot } = require('playwright/lib/server/dom');25const { chromium } = require('playwright');26const { readFileSync } = require('fs');27const { join } = require('path');28(async () => {29 const browser = await chromium.launch();30 const context = await browser.newContext();31 const page = await context.newPage();32 await page.setContent(readFileSync(join(__dirname, 'index.html'), 'utf8'));33 const root = await getRootElementsFromComponentInstance(page.mainFrame(), 'my-component');34 const shadow = await shadowRoot(root);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');2const element = await page.$('div');3const rootElements = getRootElementsFromComponentInstance(element._context._delegate);4console.log(rootElements);5const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');6const element = await page.$('div');7const rootElements = getRootElementsFromComponentInstance(element._context._delegate);8console.log(rootElements);9const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');10const element = await page.$('div');11const rootElements = getRootElementsFromComponentInstance(element._context._delegate);12console.log(rootElements);13const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');14const element = await page.$('div');15const rootElements = getRootElementsFromComponentInstance(element._context._delegate);16console.log(rootElements);17const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');18const element = await page.$('div');19const rootElements = getRootElementsFromComponentInstance(element._context._delegate);20console.log(rootElements);21const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');22const element = await page.$('div');23const rootElements = getRootElementsFromComponentInstance(element._context._delegate);24console.log(rootElements);25const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');26const element = await page.$('div');27const rootElements = getRootElementsFromComponentInstance(element._context._delegate);28console.log(rootElements);29const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');30const element = await page.$('div');31const rootElements = getRootElementsFromComponentInstance(element._context._delegate

Full Screen

Using AI Code Generation

copy

Full Screen

1const { getRootElementsFromComponentInstance } = require('playwright/lib/server/dom');2const componentInstance = await page.$eval('my-component', (e) => e);3const rootElements = await getRootElementsFromComponentInstance(componentInstance);4const rootElement = rootElements[0];5const shadowRoot = rootElement.shadowRoot;6const shadowRootElements = shadowRoot.children;7const shadowRootElement = shadowRootElements[0];8const shadowRootElement = shadowRoot.children[0];9const shadowRootElement = rootElement.shadowRoot.children[0];10const shadowRootElement = rootElements[0].shadowRoot.children[0];11const shadowRootElement = await page.$eval('my-component', (e) => e.shadowRoot.children[0]);12const shadowRootElement = await page.$('my-component >> shadow >> *');13const shadowRootElement = await page.$('my-component >> shadow >> div');14const shadowRootElement = await page.$('my-component >> shadow >> div:nth-child(1)');15const shadowRootElement = await page.$('my-component >> shadow >> div:nth-child(1) >> span');16const shadowRootElement = await page.$('my-component >> shadow >> div:nth-child(1) >> span:nth-child(1)');17const shadowRootElement = await page.$('my-component >> shadow >> div:nth-child(1) >> span:nth-child(1) >> p');18const shadowRootElement = await page.$('my-component >> shadow >> div:nth-child(1) >> span:nth-child(1) >> p:nth-child(1)');

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