@empiricalrun/playwright-utils 0.15.3 → 0.15.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/test/scripts/locator-highlights.d.ts.map +1 -1
- package/dist/test/scripts/locator-highlights.js +7 -1
- package/dist/test/scripts/locator-vision.d.ts.map +1 -1
- package/dist/test/scripts/locator-vision.js +4 -0
- package/dist/test/scripts/mouse-pointer.d.ts.map +1 -1
- package/dist/test/scripts/mouse-pointer.js +81 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locator-highlights.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/locator-highlights.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAW7C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"locator-highlights.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/locator-highlights.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAW7C,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,QAK9C"}
|
|
@@ -10,6 +10,13 @@ const is_disabled_1 = require("./pw-locator-patch/highlight/is-disabled");
|
|
|
10
10
|
const is_editable_1 = require("./pw-locator-patch/highlight/is-editable");
|
|
11
11
|
const text_content_1 = require("./pw-locator-patch/highlight/text-content");
|
|
12
12
|
function addLocatorHighlights(page) {
|
|
13
|
+
applyHighlights(page);
|
|
14
|
+
page.context().on("page", async (newPage) => {
|
|
15
|
+
applyHighlights(newPage);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.addLocatorHighlights = addLocatorHighlights;
|
|
19
|
+
function applyHighlights(page) {
|
|
13
20
|
const LocatorClass = page.locator("").constructor;
|
|
14
21
|
(0, expect_1.patchExpect)(LocatorClass);
|
|
15
22
|
(0, input_value_1.patchInputValue)(LocatorClass);
|
|
@@ -20,4 +27,3 @@ function addLocatorHighlights(page) {
|
|
|
20
27
|
(0, inner_text_1.patchInnerText)(LocatorClass);
|
|
21
28
|
(0, text_content_1.patchTextContent)(LocatorClass);
|
|
22
29
|
}
|
|
23
|
-
exports.addLocatorHighlights = addLocatorHighlights;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locator-vision.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/locator-vision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAI7C,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"locator-vision.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/locator-vision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAI7C,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,IAAI,QAQjD"}
|
|
@@ -5,5 +5,9 @@ const query_1 = require("./pw-locator-patch/vision/query");
|
|
|
5
5
|
function addLocatorVisionMethods(page) {
|
|
6
6
|
const LocatorClass = page.locator("").constructor;
|
|
7
7
|
(0, query_1.patchQuery)(LocatorClass);
|
|
8
|
+
page.context().on("page", async (newPage) => {
|
|
9
|
+
const NewPageLocatorClass = newPage.locator("").constructor;
|
|
10
|
+
(0, query_1.patchQuery)(NewPageLocatorClass);
|
|
11
|
+
});
|
|
8
12
|
}
|
|
9
13
|
exports.addLocatorVisionMethods = addLocatorVisionMethods;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mouse-pointer.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/mouse-pointer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAI7C,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,
|
|
1
|
+
{"version":3,"file":"mouse-pointer.d.ts","sourceRoot":"","sources":["../../../src/test/scripts/mouse-pointer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAI7C,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,IAAI,QA0MpD"}
|
|
@@ -82,5 +82,86 @@ function addMousePointerHighlighter(page) {
|
|
|
82
82
|
logger_1.logger.debug(`Error adding mouse pointer highlighter`, e);
|
|
83
83
|
}
|
|
84
84
|
});
|
|
85
|
+
page.context().on("page", async (newPage) => {
|
|
86
|
+
newPage?.on("load", async () => {
|
|
87
|
+
try {
|
|
88
|
+
await newPage?.evaluate(() => {
|
|
89
|
+
const box = document.createElement("div");
|
|
90
|
+
box.classList.add("empirical-mouse-pointer");
|
|
91
|
+
const styleElement = document.createElement("style");
|
|
92
|
+
styleElement.textContent = `
|
|
93
|
+
.empirical-mouse-pointer {
|
|
94
|
+
pointer-events: none;
|
|
95
|
+
position: absolute;
|
|
96
|
+
top: 0;
|
|
97
|
+
z-index: 10000;
|
|
98
|
+
left: 0;
|
|
99
|
+
width: 20px;
|
|
100
|
+
height: 20px;
|
|
101
|
+
background: rgba(0,0,0,.4);
|
|
102
|
+
border: 1px dashed #FF000D;
|
|
103
|
+
border-radius: 10px;
|
|
104
|
+
margin: -10px 0 0 -10px;
|
|
105
|
+
padding: 0;
|
|
106
|
+
transition: background .2s, border-radius .2s, border-color .2s;
|
|
107
|
+
}
|
|
108
|
+
.empirical-mouse-pointer.button-1 {
|
|
109
|
+
transition: none;
|
|
110
|
+
background: rgba(0,0,0,0.9);
|
|
111
|
+
}
|
|
112
|
+
.empirical-mouse-pointer.button-2 {
|
|
113
|
+
transition: none;
|
|
114
|
+
border-color: rgba(0,0,255,0.9);
|
|
115
|
+
}
|
|
116
|
+
.empirical-mouse-pointer.button-3 {
|
|
117
|
+
transition: none;
|
|
118
|
+
border-radius: 4px;
|
|
119
|
+
}
|
|
120
|
+
.empirical-mouse-pointer.button-4 {
|
|
121
|
+
transition: none;
|
|
122
|
+
border-color: rgba(255,0,0,0.9);
|
|
123
|
+
}
|
|
124
|
+
.empirical-mouse-pointer.button-5 {
|
|
125
|
+
transition: none;
|
|
126
|
+
border-color: rgba(0,255,0,0.9);
|
|
127
|
+
}
|
|
128
|
+
.empirical-element-grab-highlight {
|
|
129
|
+
outline: 2px dashed cyan !important;
|
|
130
|
+
}
|
|
131
|
+
*:focus {
|
|
132
|
+
outline: 2px dashed #FF000D !important;
|
|
133
|
+
}
|
|
134
|
+
*:focus-visible {
|
|
135
|
+
outline: 2px dashed #FF000D !important;
|
|
136
|
+
}
|
|
137
|
+
`;
|
|
138
|
+
document.head.appendChild(styleElement);
|
|
139
|
+
document.body.appendChild(box);
|
|
140
|
+
document.addEventListener("mousemove", (event) => {
|
|
141
|
+
box.style.left = `${event.pageX}px`;
|
|
142
|
+
box.style.top = `${event.pageY}px`;
|
|
143
|
+
updateButtons(event.buttons);
|
|
144
|
+
}, true);
|
|
145
|
+
document.addEventListener("mousedown", (event) => {
|
|
146
|
+
updateButtons(event.buttons);
|
|
147
|
+
box.classList.add(`button-${event.button + 1}`);
|
|
148
|
+
}, true);
|
|
149
|
+
document.addEventListener("mouseup", (event) => {
|
|
150
|
+
updateButtons(event.buttons);
|
|
151
|
+
box.classList.remove(`button-${event.button + 1}`);
|
|
152
|
+
}, true);
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
function updateButtons(buttons) {
|
|
155
|
+
for (let i = 0; i < 5; i++) {
|
|
156
|
+
box.classList.toggle(`button-${i + 1}`, (buttons / Math.pow(2, i)) % 2 >= 1);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
catch (e) {
|
|
162
|
+
logger_1.logger.debug(`Error adding mouse pointer highlighter`, e);
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
85
166
|
}
|
|
86
167
|
exports.addMousePointerHighlighter = addMousePointerHighlighter;
|