mirror of
https://github.com/getpaseo/paseo.git
synced 2026-12-05 06:36:34 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
abe70b9dd2 | ||
|
|
610ca8dc98 |
@@ -165,9 +165,9 @@ function buildElementSelectorScript(sessionToken: string): string {
|
||||
var style = document.createElement('style');
|
||||
style.textContent = [
|
||||
'.__paseo-hover { outline: 2px solid #3b82f6 !important; outline-offset: 2px !important; cursor: crosshair !important; }',
|
||||
'.__paseo-select-mode, .__paseo-select-mode * { cursor: crosshair !important; pointer-events: auto !important; user-select: none !important; }',
|
||||
'.__paseo-select-mode, .__paseo-select-mode * { cursor: crosshair !important; user-select: none !important; }',
|
||||
'.__paseo-select-mode *, .__paseo-select-mode *::before, .__paseo-select-mode *::after { animation: none !important; transition: none !important; }',
|
||||
'.__paseo-select-mode a, .__paseo-select-mode button, .__paseo-select-mode input, .__paseo-select-mode select, .__paseo-select-mode textarea, .__paseo-select-mode [role="button"], .__paseo-select-mode [onclick] { pointer-events: none !important; }',
|
||||
'.__paseo-select-mode :disabled { pointer-events: none !important; }',
|
||||
'.__paseo-select-mode iframe, .__paseo-select-mode video, .__paseo-select-mode audio { pointer-events: none !important; }',
|
||||
'.__paseo-hover-label { position: fixed; z-index: 2147483647; pointer-events: none; max-width: 360px; padding: 4px 8px; border-radius: 6px; background: rgba(24,24,27,0.96); color: #fff; font: 500 11px/1.45 ui-monospace,SFMono-Regular,Menlo,monospace; box-shadow: 0 2px 10px rgba(0,0,0,0.35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }',
|
||||
'.__paseo-hover-label .__paseo-tag { color: #93c5fd; }',
|
||||
@@ -348,16 +348,16 @@ function buildElementSelectorScript(sessionToken: string): string {
|
||||
}
|
||||
function destroy() {
|
||||
document.removeEventListener('mousemove', onMove, true);
|
||||
document.removeEventListener('click', onClick, true);
|
||||
window.removeEventListener('click', onClick, true);
|
||||
document.removeEventListener('keydown', onKey, true);
|
||||
document.removeEventListener('mousedown', blockEvent, true);
|
||||
document.removeEventListener('mouseup', blockEvent, true);
|
||||
document.removeEventListener('pointerdown', blockEvent, true);
|
||||
document.removeEventListener('pointerup', blockEvent, true);
|
||||
document.removeEventListener('touchstart', blockEvent, true);
|
||||
document.removeEventListener('touchend', blockEvent, true);
|
||||
document.removeEventListener('focus', blockEvent, true);
|
||||
document.removeEventListener('submit', blockEvent, true);
|
||||
window.removeEventListener('mousedown', blockEvent, true);
|
||||
window.removeEventListener('mouseup', blockEvent, true);
|
||||
window.removeEventListener('pointerdown', blockEvent, true);
|
||||
window.removeEventListener('pointerup', blockEvent, true);
|
||||
window.removeEventListener('touchstart', blockEvent, true);
|
||||
window.removeEventListener('touchend', blockEvent, true);
|
||||
window.removeEventListener('focus', blockEvent, true);
|
||||
window.removeEventListener('submit', blockEvent, true);
|
||||
document.documentElement.classList.remove('__paseo-select-mode');
|
||||
if (last) last.classList.remove('__paseo-hover');
|
||||
if (hoverLabel.parentNode) hoverLabel.parentNode.removeChild(hoverLabel);
|
||||
@@ -365,16 +365,17 @@ function buildElementSelectorScript(sessionToken: string): string {
|
||||
window.__paseoSelector = null;
|
||||
}
|
||||
document.addEventListener('mousemove', onMove, true);
|
||||
document.addEventListener('click', onClick, true);
|
||||
// Intercept the selection before the page document can handle the click.
|
||||
window.addEventListener('click', onClick, true);
|
||||
document.addEventListener('keydown', onKey, true);
|
||||
document.addEventListener('mousedown', blockEvent, true);
|
||||
document.addEventListener('mouseup', blockEvent, true);
|
||||
document.addEventListener('pointerdown', blockEvent, true);
|
||||
document.addEventListener('pointerup', blockEvent, true);
|
||||
document.addEventListener('touchstart', blockEvent, true);
|
||||
document.addEventListener('touchend', blockEvent, true);
|
||||
document.addEventListener('focus', blockEvent, true);
|
||||
document.addEventListener('submit', blockEvent, true);
|
||||
window.addEventListener('mousedown', blockEvent, true);
|
||||
window.addEventListener('mouseup', blockEvent, true);
|
||||
window.addEventListener('pointerdown', blockEvent, true);
|
||||
window.addEventListener('pointerup', blockEvent, true);
|
||||
window.addEventListener('touchstart', blockEvent, true);
|
||||
window.addEventListener('touchend', blockEvent, true);
|
||||
window.addEventListener('focus', blockEvent, true);
|
||||
window.addEventListener('submit', blockEvent, true);
|
||||
window.__paseoSelector = { destroy: destroy, sessionToken: sessionToken };
|
||||
return { installed: true, sessionToken: sessionToken };
|
||||
})()
|
||||
|
||||
@@ -319,6 +319,18 @@ async function startTargetPage() {
|
||||
<button id="bridge-target" onclick="this.textContent = 'Clicked'">Bridge target</button>
|
||||
<label for="typing-target">Typing target</label>
|
||||
<input id="typing-target" />
|
||||
<button id="selector-target" onclick="this.textContent = 'Clicked'">Selector target</button>
|
||||
<div style="position: relative">
|
||||
<button id="covered-target" onclick="this.textContent = 'Clicked'">Covered target</button>
|
||||
<div style="position: absolute; inset: 0; pointer-events: none">Decoration</div>
|
||||
</div>
|
||||
<script>
|
||||
document.addEventListener('click', (event) => {
|
||||
if (event.target.matches('#selector-target, #covered-target')) {
|
||||
event.target.textContent = 'Clicked by document';
|
||||
}
|
||||
}, true);
|
||||
</script>
|
||||
</body>
|
||||
</html>`);
|
||||
});
|
||||
@@ -775,6 +787,27 @@ async function clickGuestElement(page, client, browserId, selector) {
|
||||
});
|
||||
}
|
||||
|
||||
async function annotateGuestButton({ page, client, browserId, deck, selector, name, failures }) {
|
||||
await deck.getByRole("button", { name: "Annotate element" }).click();
|
||||
assert(await waitForGuestSelector(client, browserId), "Element selector did not start");
|
||||
await clickGuestElement(page, client, browserId, selector);
|
||||
const annotation = page.getByRole("textbox", {
|
||||
name: "Message to the agent about this element…",
|
||||
});
|
||||
await annotation.waitFor({ state: "visible", timeout: timeoutMs });
|
||||
if (!(await page.getByText(`button · ${name}`, { exact: true }).isVisible())) {
|
||||
failures.push(`annotating ${name} identifies the button under the pointer`);
|
||||
}
|
||||
const guestText = await callBrowserTool(client, "browser_evaluate", {
|
||||
browserId,
|
||||
function: `() => document.querySelector(${JSON.stringify(selector)}).textContent`,
|
||||
});
|
||||
const buttonText = JSON.parse(guestText.resultJson);
|
||||
assert(buttonText === name, `Annotating ${name} changed its text to ${buttonText}`);
|
||||
await page.keyboard.press("Escape");
|
||||
await annotation.waitFor({ state: "hidden", timeout: timeoutMs });
|
||||
}
|
||||
|
||||
async function selectDeviceSize(page, label) {
|
||||
const trigger = page.getByLabel("Device size", { exact: true });
|
||||
const item = page.getByRole("menuitem", { name: label, exact: true });
|
||||
@@ -1451,6 +1484,18 @@ async function runRegression({
|
||||
await page.screenshot({ path: path.join(artifactDir, "local-page-screenshot-selector.png") });
|
||||
await originalDeck.getByRole("button", { name: "Cancel element selector" }).click();
|
||||
|
||||
const annotationContext = { page, client, browserId, deck: originalDeck, failures };
|
||||
await annotateGuestButton({
|
||||
...annotationContext,
|
||||
selector: "#selector-target",
|
||||
name: "Selector target",
|
||||
});
|
||||
await annotateGuestButton({
|
||||
...annotationContext,
|
||||
selector: "#covered-target",
|
||||
name: "Covered target",
|
||||
});
|
||||
|
||||
// This journey selects tabs from both pane rails. Keep both columns above the compact-header
|
||||
// breakpoint; narrow panes deliberately replace their rail with a tab dropdown.
|
||||
await resizeDesktopWindow(inspectorPort, { width: 1920, height: 1080 });
|
||||
|
||||
Reference in New Issue
Block a user