Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore(dashboard): new buttons (#40225)

Simon Knott508f8ec97be3
diff --git a/eslint.config.mjs b/eslint.config.mjs
index 9ac28172f4..df150e14cd 100644
--- a/eslint.config.mjs
+++ b/eslint.config.mjs
@@ -286,6 +286,8 @@ const reactFiles = [
`packages/recorder/src/**/*.tsx`,
`packages/trace-viewer/src/**/*.ts`,
`packages/trace-viewer/src/**/*.tsx`,
+ `packages/dashboard/src/**/*.ts`,
+ `packages/dashboard/src/**/*.tsx`,
`packages/web/src/**/*.ts`,
`packages/web/src/**/*.tsx`,
];
diff --git a/package-lock.json b/package-lock.json
index 154f1bdb5d..6130a56acd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9793,7 +9793,8 @@
"dependencies": {
"@xterm/addon-fit": "^0.10.0",
"@xterm/xterm": "^5.5.0",
- "codemirror": "5.65.18"
+ "codemirror": "5.65.18",
+ "yaml": "^2.8.3"
}
}
}
diff --git a/packages/dashboard/src/common.css b/packages/dashboard/src/common.css
index 49a567722b..c1d8ce2d1e 100644
--- a/packages/dashboard/src/common.css
+++ b/packages/dashboard/src/common.css
@@ -54,3 +54,7 @@ button {
button:hover {
color: var(--color-fg-default);
}
+
+svg {
+ fill: none; /* override @web/common.css */
+}
diff --git a/packages/dashboard/src/dashboard.css b/packages/dashboard/src/dashboard.css
index d6b411353d..037ba9e86c 100644
--- a/packages/dashboard/src/dashboard.css
+++ b/packages/dashboard/src/dashboard.css
@@ -16,9 +16,11 @@
.dashboard-view {
--interactive-orange: 238 134 12;
+ --annotate-blue: 54 116 209;
display: flex;
flex-direction: column;
height: 100%;
+ width: 100%;
overflow: hidden;
}
@@ -26,8 +28,8 @@
.tabbar {
display: flex;
align-items: flex-end;
- height: 38px;
- min-height: 38px;
+ height: 39px;
+ min-height: 39px;
padding: 0 4px;
user-select: none;
position: relative;
@@ -131,6 +133,14 @@
height: 16px;
}
+.interactive .toolbar .toolbar-button > .codicon {
+ color: var(--color-fg-on-emphasis);
+}
+
+.annotate .toolbar .toolbar-button > .codicon {
+ color: var(--color-fg-on-emphasis);
+}
+
.tabstrip {
display: flex;
align-items: flex-end;
@@ -188,6 +198,11 @@
color: var(--color-fg-on-emphasis);
}
+.dashboard-view.annotate .tab.active {
+ background: rgb(var(--annotate-blue));
+ color: var(--color-fg-on-emphasis);
+}
+
.tab-label {
overflow: hidden;
text-overflow: ellipsis;
@@ -198,8 +213,6 @@
width: 14px;
height: 14px;
flex-shrink: 0;
- background: var(--color-fg-subtle);
- border-radius: 2px;
display: flex;
align-items: center;
justify-content: center;
@@ -207,6 +220,11 @@
font-weight: 700;
}
+.tab-favicon.placeholder {
+ background: var(--color-fg-subtle);
+ border-radius: 2px;
+}
+
.tab-close {
width: 16px;
height: 16px;
@@ -369,7 +387,9 @@
background: var(--color-canvas-overlay);
padding: 0 8px;
position: relative;
- z-index: 0;
+ z-index: 100;
+ border-bottom: 1px solid var(--color-border-muted);
+ overflow: visible;
}
:root.light-mode .toolbar {
@@ -381,11 +401,21 @@
color: var(--color-fg-on-emphasis);
}
+.dashboard-view.annotate .toolbar {
+ background: rgb(var(--annotate-blue));
+ color: var(--color-fg-on-emphasis);
+}
+
.dashboard-view.interactive .toolbar .nav-btn,
.dashboard-view.interactive .toolbar .omnibox {
color: var(--color-fg-on-emphasis);
}
+.dashboard-view.annotate .toolbar .nav-btn,
+.dashboard-view.annotate .toolbar .omnibox {
+ color: var(--color-fg-on-emphasis);
+}
+
:root.light-mode .dashboard-view.interactive .toolbar {
color: var(--color-fg-on-emphasis);
}
@@ -397,6 +427,17 @@
color: rgb(255 255 255 / 0.6);
}
+:root.light-mode .dashboard-view.annotate .toolbar {
+ color: var(--color-fg-on-emphasis);
+}
+:root.light-mode .dashboard-view.annotate .toolbar .omnibox {
+ background: rgb(0 0 0 / 0.15);
+ color: var(--color-fg-on-emphasis);
+}
+:root.light-mode .dashboard-view.annotate .toolbar .omnibox::placeholder {
+ color: rgb(255 255 255 / 0.6);
+}
+
.nav-btn {
width: 32px;
height: 32px;
@@ -411,12 +452,12 @@
background: var(--color-neutral-muted);
}
-.nav-btn:disabled {
+.nav-btn[aria-disabled] {
color: var(--color-fg-subtle);
cursor: default;
}
-.nav-btn:disabled:hover {
+.nav-btn[aria-disabled]:hover {
background: none;
}
@@ -452,11 +493,47 @@
background: var(--color-accent-muted);
}
+.omnibox[aria-disabled] {
+ color: var(--color-fg-subtle);
+ cursor: default;
+}
+
+/* -- Interactive hint popover -- */
+.interactive-hint-popover {
+ position: absolute;
+ top: calc(100% + 8px);
+ right: 0;
+ background: var(--color-canvas-overlay);
+ color: var(--color-fg-default);
+ font-size: 12px;
+ padding: 6px 12px;
+ border-radius: 6px;
+ white-space: nowrap;
+ border: 1px solid var(--color-border-default);
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
+ pointer-events: none;
+ z-index: 1000;
+ animation: hint-fade-in 150ms ease;
+}
+
+.interactive-hint-popover::after {
+ content: '';
+ position: absolute;
+ bottom: 100%;
+ right: 10px;
+ border: 5px solid transparent;
+ border-bottom-color: var(--color-canvas-overlay);
+}
+
+@keyframes hint-fade-in {
+ from { opacity: 0; transform: translateY(-4px); }
+ to { opacity: 1; transform: translateY(0); }
+}
+
/* -- Viewport -- */
.viewport-wrapper {
flex: 1;
display: flex;
- background: #000;
overflow: hidden;
position: relative;
min-height: 0;
@@ -477,21 +554,11 @@
height: 100%;
}
-.screen::after {
- content: '';
- position: absolute;
- inset: 0;
- pointer-events: none;
- opacity: 0;
- box-shadow: inset 0 0 0 1px rgb(var(--interactive-orange) / 0.72), inset 0 0 26px rgb(var(--interactive-orange) / 0.42);
- transition: opacity 180ms ease;
-}
-
.display {
display: block;
width: 100%;
height: 100%;
- background: #000;
+ background: var(--color-canvas-subtle);
object-fit: contain;
}
@@ -508,7 +575,7 @@
font-size: 14px;
z-index: 10;
pointer-events: none;
- background: #000;
+ background: var(--color-canvas-subtle);
color: var(--color-fg-subtle);
}
@@ -569,40 +636,37 @@
background: var(--color-accent-subtle);
}
-/* -- Annotate mode (dashboard chrome) -- */
-.dashboard-view {
- --annotate-blue: 54 116 209;
-}
-
-.segmented-control-3 {
- padding: 2px;
-}
-
-.segmented-control-3::before {
- width: calc(33.333% - 2px);
- transform: translateX(0);
-}
-
-.segmented-control-3.interactive::before {
- transform: translateX(100%);
- background: rgb(var(--interactive-orange) / 0.95);
-}
-
-.segmented-control-3.annotate::before {
- transform: translateX(200%);
- background: rgb(var(--annotate-blue) / 0.95);
+.recording.toggled > .codicon {
+ animation: recording-pulse 1.5s ease-in-out infinite;
}
-.segmented-control-3 .segmented-control-option {
- width: 88px;
+@keyframes recording-pulse {
+ 0%, 100% {
+ opacity: 1;
+ transform: scale(1);
+ }
+ 50% {
+ opacity: 0.4;
+ transform: scale(0.85);
+ }
}
-.dashboard-view.annotate .toolbar {
- background: rgb(var(--annotate-blue));
- color: var(--color-fg-on-emphasis);
+.recording-label {
+ display: inline-block;
+ margin-left: 5px;
+ white-space: nowrap;
+ animation: recording-label-slide-in 300ms ease both;
}
-.dashboard-view.annotate .toolbar .nav-btn,
-.dashboard-view.annotate .toolbar .omnibox {
- color: var(--color-fg-on-emphasis);
+@keyframes recording-label-slide-in {
+ from {
+ max-width: 0;
+ opacity: 0;
+ overflow: hidden;
+ }
+ to {
+ max-width: 100px;
+ opacity: 1;
+ overflow: hidden;
+ }
}
diff --git a/packages/dashboard/src/dashboard.tsx b/packages/dashboard/src/dashboard.tsx
index e685950da0..6e6687de0c 100644
--- a/packages/dashboard/src/dashboard.tsx
+++ b/packages/dashboard/src/dashboard.tsx
@@ -19,11 +19,16 @@ import './dashboard.css';
import { navigate, DashboardClientContext } from './index';
import { asLocator } from '@isomorphic/locatorGenerators';
import { SplitView } from '@web/components/splitView';
-import { ChevronLeftIcon, ChevronRightIcon, CloseIcon, PlusIcon, ReloadIcon, PickLocatorIcon, InspectorPanelIcon } from './icons';
+import { ChevronLeftIcon, ChevronRightIcon, CloseIcon, PlusIcon, ReloadIcon } from './icons';
import { SettingsButton } from './settingsView';
import { Annotations, getImageLayout, clientToViewport } from './annotations';
+import { ToolbarButton } from '@web/components/toolbarButton';
+import { TabbedPaneTabModel, TabbedPane } from '@web/components/tabbedPane';
+import { InspectorTab } from '@trace-viewer/ui/inspectorTab';
+import { useSetting } from '@web/uiUtils';
import type { Tab, DashboardChannelEvents } from './dashboardChannel';
+import { HighlightedElement } from '@trace-viewer/ui/snapshotTab';
function tabFavicon(url: string): string {
try {
@@ -36,7 +41,6 @@ function tabFavicon(url: string): string {
}
const BUTTONS = ['left', 'middle', 'right'] as const;
-
type Mode = 'readonly' | 'interactive' | 'annotate';
export const Dashboard: React.FC<{
@@ -44,8 +48,10 @@ export const Dashboard: React.FC<{
autoInteractive?: boolean;
onAutoInteractiveConsumed?: () => void;
}> = ({ browser, autoInteractive, onAutoInteractiveConsumed }) => {
+ const [sidebarLocation, setSidebarLocation] = useSetting<'bottom' | 'right'>('propertiesSidebarLocation', 'bottom');
const client = React.useContext(DashboardClientContext);
const [mode, setMode] = React.useState<Mode>('readonly');
+ const [sidebarVisible, setSidebarVisible] = useSetting<boolean>('propertiesSidebarVisible', false);
React.useEffect(() => {
if (!autoInteractive)
@@ -56,23 +62,43 @@ export const Dashboard: React.FC<{
const [tabs, setTabs] = React.useState<Tab[] | null>(null);
const [url, setUrl] = React.useState('');
const [frame, setFrame] = React.useState<DashboardChannelEvents['frame']>();
- const [showInspector, setShowInspector] = React.useState(false);
const [pickingPage, setPickingPage] = React.useState<string | null>(null);
- const [locatorToast, setLocatorToast] = React.useState<{ text: string; timer: ReturnType<typeof setTimeout> }>();
+ const [highlightedElement, setHighlightedElement] = React.useState<HighlightedElement>({ locator: undefined, ariaSnapshot: undefined, lastEdited: 'none' });
const [context, setContext] = React.useState<string | undefined>();
+ const [recording, setRecording] = React.useState(false);
+ const [screenshotIcon, setScreenshotIcon] = React.useState<'device-camera' | 'clippy'>('device-camera');
+ const [showInteractiveHint, setShowInteractiveHint] = React.useState(false);
const displayRef = React.useRef<HTMLImageElement>(null);
const screenRef = React.useRef<HTMLDivElement>(null);
const tabbarRef = React.useRef<HTMLDivElement>(null);
const toolbarRef = React.useRef<HTMLDivElement>(null);
const moveThrottleRef = React.useRef(0);
+ const hintTimerRef = React.useRef<ReturnType<typeof setTimeout>>(undefined);
const modeRef = React.useRef<Mode>('readonly');
- React.useEffect(() => { modeRef.current = mode; }, [mode]);
+ React.useEffect(() => {
+ modeRef.current = mode;
+ }, [mode]);
const interactive = mode === 'interactive';
const annotating = mode === 'annotate';
+ React.useEffect(() => {
+ if (interactive)
+ setShowInteractiveHint(false);
+ }, [interactive]);
+
+ React.useEffect(() => {
+ return () => clearTimeout(hintTimerRef.current);
+ }, []);
+
+ function flashInteractiveHint() {
+ clearTimeout(hintTimerRef.current);
+ setShowInteractiveHint(true);
+ hintTimerRef.current = setTimeout(() => setShowInteractiveHint(false), 2000);
+ }
+
React.useEffect(() => {
if (!client)
return;
@@ -111,10 +137,7 @@ export const Dashboard: React.FC<{
const locator = asLocator('javascript', params.selector);
navigator.clipboard?.writeText(locator).catch(() => {});
setPickingPage(null);
- setLocatorToast(old => {
- clearTimeout(old?.timer);
- return { text: locator, timer: setTimeout(() => setLocatorToast(undefined), 3000) };
- });
+ setHighlightedElement({ locator, ariaSnapshot: params.ariaSnapshot, lastEdited: 'locator' });
};
client.on('tabs', onTabs);
@@ -137,7 +160,7 @@ export const Dashboard: React.FC<{
setFrame(undefined);
setMode('readonly');
setPickingPage(null);
- setShowInspector(false);
+ setRecording(false);
};
}, [client, browser]);
@@ -147,11 +170,17 @@ export const Dashboard: React.FC<{
? { browser, context: context!, page: selectedTab.page }
: undefined;
+ React.useEffect(() => {
+ setRecording(false);
+ }, [selectedTab?.page]);
+
function imgCoords(e: React.MouseEvent): { x: number; y: number } {
const vw = frame?.viewportWidth ?? 0;
const vh = frame?.viewportHeight ?? 0;
+ if (!vw || !vh)
+ return { x: 0, y: 0 };
const layout = getImageLayout(displayRef.current);
- if (!vw || !vh || !layout)
+ if (!layout)
return { x: 0, y: 0 };
return clientToViewport(layout, vw, vh, e.clientX, e.clientY);
}
@@ -171,7 +200,7 @@ export const Dashboard: React.FC<{
if (!ready)
return;
if (!interactive) {
- setMode('interactive');
+ flashInteractiveHint();
return;
}
sendMouseEvent('mousedown', e);
@@ -239,6 +268,33 @@ export const Dashboard: React.FC<{
const picking = selectedTab?.page === pickingPage;
+ const inspectorTabs: TabbedPaneTabModel[] = [
+ {
+ id: 'inspector',
+ title: 'Locator',
+ render: () => <InspectorTab
+ sdkLanguage='javascript'
+ isInspecting={picking}
+ setIsInspecting={isInspecting => {
+ if (isInspecting) {
+ if (!pageTarget || !selectedTab)
+ return;
+ setMode('interactive');
+ setPickingPage(selectedTab.page);
+ screenRef.current?.focus();
+ client?.pickLocator(pageTarget);
+ } else {
+ if (pageTarget)
+ client?.cancelPickLocator(pageTarget);
+ setPickingPage(null);
+ }
+ }}
+ highlightedElement={highlightedElement}
+ setHighlightedElement={setHighlightedElement}
+ />,
+ },
+ ];
+
let overlayText: string | undefined;
if (!client || !context)
overlayText = 'Disconnected';
@@ -247,207 +303,245 @@ export const Dashboard: React.FC<{
else if (tabs.length === 0)
overlayText = 'No tabs open';
- return (<div className={'dashboard-view' + (interactive ? ' interactive' : '') + (annotating ? ' annotate' : '')}
- >
- {/* Tab bar */}
- <div ref={tabbarRef} className='tabbar'>
- <a className='tabbar-back' href='#' title='Back to sessions' onClick={e => { e.preventDefault(); navigate('#'); }}>
- <ChevronLeftIcon />
- Sessions
- </a>
- <div id='tabstrip' className='tabstrip' role='tablist'>
- {tabs?.map(tab => (
- <div
- key={tab.page}
- className={'tab' + (tab.selected ? ' active' : '')}
- role='tab'
- aria-selected={tab.selected}
- title={tab.url || ''}
- onClick={() => client?.selectTab({ browser, context: tab.context, page: tab.page })}
- >
- <span className='tab-favicon' aria-hidden='true'>{tabFavicon(tab.url)}</span>
- <span className='tab-label'>{tab.title || 'New Tab'}</span>
- <button
- className='tab-close'
- title='Close tab'
- onClick={e => {
- e.stopPropagation();
- client?.closeTab({ browser, context: tab.context, page: tab.page });
- }}
- >
- <CloseIcon />
- </button>
- </div>
- ))}
- </div>
- <button id='new-tab-btn' className='new-tab-btn' title='New Tab' onClick={() => {
- if (context)
- client?.newTab({ browser, context });
- }}>
- <PlusIcon />
- </button>
- <div className='interactive-controls'>
- <div
- className={'segmented-control segmented-control-3' + (interactive ? ' interactive' : '') + (annotating ? ' annotate' : '')}
- role='group'
- aria-label='Interaction mode'
- title={annotating ? 'Annotate mode: draw rectangular regions and add comments' : interactive ? 'Interactive mode: page input is forwarded' : 'Read-only mode: page input is blocked'}
- >
- <button
- className={'segmented-control-option' + (mode === 'readonly' ? ' active' : '')}
- disabled={!ready}
- aria-pressed={mode === 'readonly'}
- title='Read-only mode'
- onClick={() => {
- if (pageTarget)
- client?.cancelPickLocator(pageTarget);
- setPickingPage(null);
- setShowInspector(false);
- setMode('readonly');
- }}
- >
- Read-only
- </button>
- <button
- className={'segmented-control-option' + (mode === 'interactive' ? ' active' : '')}
- disabled={!ready}
- aria-pressed={mode === 'interactive'}
- title='Interactive mode'
- onClick={() => setMode('interactive')}
- >
- Interactive
- </button>
- <button
- className={'segmented-control-option' + (mode === 'annotate' ? ' active' : '')}
- disabled={!ready || !frame}
- aria-pressed={mode === 'annotate'}
- title='Annotate mode'
- onClick={() => {
- if (pageTarget)
- client?.cancelPickLocator(pageTarget);
- setPickingPage(null);
- setShowInspector(false);
- setMode('annotate');
- }}
- >
- Annotate
- </button>
- </div>
- <SettingsButton />
- </div>
- </div>
-
- {/* Toolbar */}
- <div ref={toolbarRef} className='toolbar'>
- <button className='nav-btn' title='Back' onClick={() => pageTarget && client?.back(pageTarget)}>
- <ChevronLeftIcon />
- </button>
- <button className='nav-btn' title='Forward' onClick={() => pageTarget && client?.forward(pageTarget)}>
- <ChevronRightIcon />
- </button>
- <button className='nav-btn' title='Reload' onClick={() => pageTarget && client?.reload(pageTarget)}>
- <ReloadIcon />
- </button>
- <input
- id='omnibox'
- className='omnibox'
- type='text'
- placeholder='Search or enter URL'
- spellCheck={false}
- autoComplete='off'
- value={url}
- onChange={e => setUrl(e.target.value)}
- onKeyDown={onOmniboxKeyDown}
- onFocus={e => e.target.select()}
- />
- <button
- className={'nav-btn' + (picking ? ' active-toggle' : '')}
- title='Pick locator'
- aria-pressed={picking}
- disabled={!ready}
- onClick={() => {
- if (!pageTarget)
- return;
- if (picking) {
- client?.cancelPickLocator(pageTarget);
- setPickingPage(null);
- } else {
- setMode('interactive');
- setPickingPage(selectedTab?.page ?? null);
- screenRef.current?.focus();
- client?.pickLocator(pageTarget);
- }
- }}
- >
- <PickLocatorIcon />
- </button>
- {selectedTab?.inspectorUrl && (
- <button
- className={'nav-btn' + (showInspector ? ' active-toggle' : '')}
- title='Chrome DevTools'
- aria-pressed={showInspector}
- disabled={!ready}
- onClick={() => {
- setMode('interactive');
- setShowInspector(!showInspector);
- }}
- >
- <InspectorPanelIcon />
- </button>
- )}
- </div>
-
- {/* Viewport */}
- <div className='viewport-wrapper'>
+ return (
+ <div className='vbox'>
<SplitView
- orientation='horizontal'
+ sidebarHidden={!sidebarVisible}
+ orientation={sidebarLocation === 'bottom' ? 'vertical' : 'horizontal'}
sidebarSize={500}
minSidebarSize={300}
settingName='devtoolsInspector'
- sidebarHidden={!showInspector || !selectedTab?.inspectorUrl}
- main={<div className='viewport-main'>
- <div
- ref={screenRef}
- className='screen'
- tabIndex={0}
- style={{ display: frame ? '' : 'none' }}
- onMouseDown={onScreenMouseDown}
- onMouseUp={onScreenMouseUp}
- onMouseMove={onScreenMouseMove}
- onWheel={onScreenWheel}
- onKeyDown={onScreenKeyDown}
- onKeyUp={onScreenKeyUp}
- onContextMenu={e => e.preventDefault()}
- >
- <img
- ref={displayRef}
- id='display'
- className='display'
- alt='screencast'
- src={frame ? 'data:image/jpeg;base64,' + frame.data : undefined}
+ main={<div className={'dashboard-view' + (interactive ? ' interactive' : '') + (annotating ? ' annotate' : '')}>
+ {/* Tab bar */}
+ <div ref={tabbarRef} className='tabbar'>
+ <a className='tabbar-back' href='#' title='Back to sessions' onClick={e => { e.preventDefault(); navigate('#'); }}>
+ <ChevronLeftIcon />
+ Sessions
+ </a>
+ <div id='tabstrip' className='tabstrip' role='tablist'>
+ {tabs?.map(tab => (
+ <div
+ key={tab.page}
+ className={'tab' + (tab.selected ? ' active' : '')}
+ role='tab'
+ aria-selected={tab.selected}
+ title={tab.url || ''}
+ onClick={() => client?.selectTab({ browser, context: tab.context, page: tab.page })}
+ >
+ {tab.faviconUrl
+ ? <img className='tab-favicon' src={tab.faviconUrl} alt='' aria-hidden='true' />
+ : <span className='tab-favicon placeholder' aria-hidden='true'>{tabFavicon(tab.url)}</span>}
+ <span className='tab-label'>{tab.title || 'New Tab'}</span>
+ <button
+ className='tab-close'
+ title='Close tab'
+ onClick={e => {
+ e.stopPropagation();
+ client?.closeTab({ browser, context: tab.context, page: tab.page });
+ }}
+ >
+ <CloseIcon />
+ </button>
+ </div>
+ ))}
+ </div>
+ <button id='new-tab-btn' className='new-tab-btn' title='New Tab' onClick={() => {
+ if (context)
+ client?.newTab({ browser, context });
+ }}>
+ <PlusIcon />
+ </button>
+ <div className='interactive-controls' />
+ </div>
+
+ {/* Toolbar */}
+ <div ref={toolbarRef} className='toolbar'>
+ <button className='nav-btn' title='Back' aria-disabled={!interactive || undefined} onClick={() => {
+ if (!interactive) {
+ flashInteractiveHint();
+ return;
+ }
+ pageTarget && client?.back(pageTarget);
+ }}>
+ <ChevronLeftIcon />
+ </button>
+ <button className='nav-btn' title='Forward' aria-disabled={!interactive || undefined} onClick={() => {
+ if (!interactive) {
+ flashInteractiveHint();
+ return;
+ }
+ pageTarget && client?.forward(pageTarget);
+ }}>
+ <ChevronRightIcon />
+ </button>
+ <button className='nav-btn' title='Reload' aria-disabled={!interactive || undefined} onClick={() => {
+ if (!interactive) {
+ flashInteractiveHint();
+ return;
+ }
+ pageTarget && client?.reload(pageTarget);
+ }}>
+ <ReloadIcon />
+ </button>
+ <input
+ id='omnibox'
+ className='omnibox'
+ type='text'
+ placeholder='Search or enter URL'
+ spellCheck={false}
+ autoComplete='off'
+ value={url}
+ onChange={e => {
+ if (!interactive)
+ return;
+ setUrl(e.target.value);
+ }}
+ onKeyDown={e => {
+ if (!interactive)
+ return;
+ onOmniboxKeyDown(e);
+ }}
+ onFocus={e => {
+ if (!interactive) {
+ flashInteractiveHint();
+ e.target.blur();
+ return;
+ }
+ e.target.select();
+ }}
+ aria-disabled={!interactive || undefined}
+ readOnly={!interactive}
/>
- <Annotations
- active={annotating}
- displayRef={displayRef}
- screenRef={screenRef}
- viewportWidth={frame?.viewportWidth ?? 0}
- viewportHeight={frame?.viewportHeight ?? 0}
+ <ToolbarButton
+ className='recording'
+ title={recording ? 'Stop recording' : 'Record video'}
+ icon='record'
+ toggled={recording}
+ style={{ color: recording ? (interactive ? 'var(--color-fg-on-emphasis)' : 'var(--color-scale-red-5)') : undefined }}
+ disabled={!ready}
+ onClick={async () => {
+ if (!client || !pageTarget)
+ return;
+ if (recording) {
+ const { path } = await client.stopRecording(pageTarget);
+ await client.reveal({ path });
+ setRecording(false);
+ } else {
+ await client.startRecording(pageTarget);
+ setRecording(true);
+ }
+ }}>
+ {recording && <span className='recording-label'>Recording...</span>}
+ </ToolbarButton>
+ <ToolbarButton
+ className='screenshot'
+ title='Copy screenshot to clipboard'
+ icon={screenshotIcon}
+ disabled={!ready}
+ onClick={async () => {
+ if (!client || !pageTarget)
+ return;
+ const screenshot = await client.screenshot(pageTarget);
+ const blob = await (await fetch('data:image/png;base64,' + screenshot)).blob();
+ await navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })]);
+ setScreenshotIcon('clippy');
+ setTimeout(() => setScreenshotIcon('device-camera'), 3000);
+ }}
/>
- {locatorToast
- ? <div className='screen-toast visible'>Copied: <code>{locatorToast.text}</code></div>
- : picking
- ? <div className='screen-toast visible'>Click an element to pick its locator</div>
- : null
- }
+ <div style={{ marginLeft: 8, borderLeft: '1px solid var(--color-border-default)', paddingLeft: 8, display: 'flex', gap: 4 }}>
+ <div style={{ position: 'relative' }}>
+ <ToolbarButton
+ title={interactive ? 'Disable interactive mode' : 'Enable interactive mode'}
+ icon='inspect'
+ toggled={interactive}
+ disabled={!ready}
+ onClick={() => {
+ if (interactive) {
+ if (pageTarget)
+ client?.cancelPickLocator(pageTarget);
+ setPickingPage(null);
+ setMode('readonly');
+ return;
+ }
+ if (pageTarget)
+ client?.cancelPickLocator(pageTarget);
+ setPickingPage(null);
+ setMode('interactive');
+ }}
+ />
+ {showInteractiveHint && <div className='interactive-hint-popover'>Enable interactive mode</div>}
+ </div>
+ <ToolbarButton
+ title={annotating ? 'Disable annotation mode' : 'Enable annotation mode'}
+ icon='edit'
+ toggled={annotating}
+ disabled={!ready || !frame}
+ onClick={() => {
+ if (annotating) {
+ setMode('readonly');
+ return;
+ }
+ if (pageTarget)
+ client?.cancelPickLocator(pageTarget);
+ setPickingPage(null);
+ setMode('annotate');
+ }}
+ />
+ <ToolbarButton
+ title={sidebarVisible ? 'Hide sidebar' : 'Show sidebar'}
+ icon={sidebarLocation === 'bottom' ? 'layout-panel' : 'layout-sidebar-right'}
+ toggled={sidebarVisible}
+ onClick={() => setSidebarVisible(!sidebarVisible)}
+ disabled={!ready}
+ />
+ </div>
+ </div>
+
+ {/* Viewport */}
+ <div className='viewport-wrapper'>
+ <div className='viewport-main'>
+ <div
+ ref={screenRef}
+ className='screen'
+ tabIndex={0}
+ style={{ display: frame ? '' : 'none' }}
+ onMouseDown={onScreenMouseDown}
+ onMouseUp={onScreenMouseUp}
+ onMouseMove={onScreenMouseMove}
+ onWheel={onScreenWheel}
+ onKeyDown={onScreenKeyDown}
+ onKeyUp={onScreenKeyUp}
+ onContextMenu={e => e.preventDefault()}
+ >
+ <img
+ ref={displayRef}
+ id='display'
+ className='display'
+ alt='screencast'
+ src={frame ? 'data:image/jpeg;base64,' + frame.data : undefined}
+ />
+ <Annotations
+ active={annotating}
+ displayRef={displayRef}
+ screenRef={screenRef}
+ viewportWidth={frame?.viewportWidth ?? 0}
+ viewportHeight={frame?.viewportHeight ?? 0}
+ />
+ </div>
+ {overlayText && <div className={'screen-overlay' + (frame ? ' has-frame' : '')}><span>{overlayText}</span></div>}
+ </div>
</div>
- {overlayText && <div className={'screen-overlay' + (frame ? ' has-frame' : '')}><span>{overlayText}</span></div>}
</div>}
- sidebar={<iframe
- className='inspector-frame'
- src={selectedTab?.inspectorUrl || ''}
- title='Chrome DevTools'
+ sidebar={<TabbedPane
+ tabs={inspectorTabs}
+ selectedTab='inspector'
+ setSelectedTab={() => {}}
+ rightToolbar={[
+ <SettingsButton key='settings' sidebarLocation={sidebarLocation} setSidebarLocation={setSidebarLocation} />,
+ ]}
+ mode='default'
/>}
/>
</div>
- </div>);
+ );
};
diff --git a/packages/dashboard/src/dashboardChannel.ts b/packages/dashboard/src/dashboardChannel.ts
index 30023a3169..44e2e94814 100644
--- a/packages/dashboard/src/dashboardChannel.ts
+++ b/packages/dashboard/src/dashboardChannel.ts
@@ -28,6 +28,7 @@ export type Tab = {
title: string;
url: string;
selected: boolean;
+ faviconUrl?: string;
inspectorUrl?: string;
};
@@ -35,7 +36,7 @@ export type DashboardChannelEvents = {
sessions: { sessions: SessionStatus[]; clientInfo: ClientInfo };
tabs: { target: ContextTarget; tabs: Tab[] };
frame: { target: PageTarget; data: string; viewportWidth: number; viewportHeight: number };
- elementPicked: { target: PageTarget; selector: string };
+ elementPicked: { target: PageTarget; selector: string; ariaSnapshot?: string };
pickLocator: { target: PageTarget };
};
@@ -65,6 +66,10 @@ export interface DashboardChannel {
keyup(params: PageTarget & { key: string }): Promise<void>;
pickLocator(params: PageTarget): Promise<void>;
cancelPickLocator(params: PageTarget): Promise<void>;
+ startRecording(params: PageTarget): Promise<void>;
+ stopRecording(params: PageTarget): Promise<{ path: string }>;
+ screenshot(params: PageTarget): Promise<string>;
+ reveal(params: { path: string }): Promise<void>;
on<K extends keyof DashboardChannelEvents>(event: K, listener: (params: DashboardChannelEvents[K]) => void): void;
off<K extends keyof DashboardChannelEvents>(event: K, listener: (params: DashboardChannelEvents[K]) => void): void;
diff --git a/packages/dashboard/src/grid.css b/packages/dashboard/src/grid.css
index 797c4e2ca2..c513964396 100644
--- a/packages/dashboard/src/grid.css
+++ b/packages/dashboard/src/grid.css
@@ -18,6 +18,7 @@
display: flex;
flex-direction: column;
height: 100%;
+ width: 100%;
}
.grid-toolbar {
diff --git a/packages/dashboard/src/grid.tsx b/packages/dashboard/src/grid.tsx
index d20df11b6c..fe505e80ca 100644
--- a/packages/dashboard/src/grid.tsx
+++ b/packages/dashboard/src/grid.tsx
@@ -127,7 +127,7 @@ const SessionChip: React.FC<{ descriptor: BrowserDescriptor; canConnect: boolean
const chipTitle = selectedTab ? `[${descriptor.title}] ${selectedTab.url} \u2014 ${selectedTab.title}` : descriptor.title;
return (
- <a className={'session-chip' + (canConnect ? '' : ' disconnected')} href={canConnect ? href : undefined} title={chipTitle} onClick={e => {
+ <a className={'session-chip' + (canConnect ? '' : ' disconnected')} aria-disabled={!canConnect} href={canConnect ? href : undefined} title={chipTitle} onClick={e => {
e.preventDefault();
if (canConnect)
navigate(href);
diff --git a/packages/dashboard/src/index.tsx b/packages/dashboard/src/index.tsx
index 3b741e322e..95e3c8abbb 100644
--- a/packages/dashboard/src/index.tsx
+++ b/packages/dashboard/src/index.tsx
@@ -17,6 +17,7 @@
import React from 'react';
import * as ReactDOM from 'react-dom/client';
import './colors.css';
+import '@web/common.css';
import './common.css';
import { applyTheme } from '@web/theme';
import { Dashboard } from './dashboard';
diff --git a/packages/dashboard/src/settingsView.css b/packages/dashboard/src/settingsView.css
index 337ad79a68..a0f12ac3df 100644
--- a/packages/dashboard/src/settingsView.css
+++ b/packages/dashboard/src/settingsView.css
@@ -27,6 +27,7 @@
.settings-gear-btn svg {
width: 16px;
height: 16px;
+ fill: currentColor;
}
.settings-gear-btn:hover {
diff --git a/packages/dashboard/src/settingsView.tsx b/packages/dashboard/src/settingsView.tsx
index a57014fff3..d324d1ea41 100644
--- a/packages/dashboard/src/settingsView.tsx
+++ b/packages/dashboard/src/settingsView.tsx
@@ -19,7 +19,14 @@ import './settingsView.css';
import { kThemeOptions, type Theme, useThemeSetting } from '@web/theme';
import { GearIcon } from './icons';
-export const SettingsButton: React.FC = () => {
+type SidebarLocation = 'bottom' | 'right';
+
+type SettingsButtonProps = {
+ sidebarLocation?: SidebarLocation;
+ setSidebarLocation?: (location: SidebarLocation) => void;
+};
+
+export const SettingsButton: React.FC<SettingsButtonProps> = ({ sidebarLocation, setSidebarLocation }) => {
const [open, setOpen] = React.useState(false);
const [theme, setTheme] = useThemeSetting();
const containerRef = React.useRef<HTMLDivElement>(null);
@@ -68,6 +75,25 @@ export const SettingsButton: React.FC = () => {
))}
</div>
</div>
+ {sidebarLocation && setSidebarLocation && (
+ <div className='setting-row'>
+ <span className='setting-label'>Inspector Dock</span>
+ <div className='setting-options'>
+ <div
+ className={'setting-option' + (sidebarLocation === 'bottom' ? ' selected' : '')}
+ onClick={() => { setSidebarLocation('bottom'); setOpen(false); }}
+ >
+ Bottom
+ </div>
+ <div
+ className={'setting-option' + (sidebarLocation === 'right' ? ' selected' : '')}
+ onClick={() => { setSidebarLocation('right'); setOpen(false); }}
+ >
+ Right
+ </div>
+ </div>
+ </div>
+ )}
</div>
)}
</div>
diff --git a/packages/dashboard/vite.config.ts b/packages/dashboard/vite.config.ts
index 6ee0b0c660..967cf2ba81 100644
--- a/packages/dashboard/vite.config.ts
+++ b/packages/dashboard/vite.config.ts
@@ -29,6 +29,7 @@ export default defineConfig({
'@isomorphic': path.resolve(__dirname, '../isomorphic'),
'@protocol': path.resolve(__dirname, '../protocol/src'),
'@web': path.resolve(__dirname, '../web/src'),
+ '@trace-viewer': path.resolve(__dirname, '../trace-viewer/src'),
},
},
build: {
diff --git a/packages/playwright-core/src/tools/dashboard/dashboardApp.ts b/packages/playwright-core/src/tools/dashboard/dashboardApp.ts
index 994741630f..bb7c88b15c 100644
--- a/packages/playwright-core/src/tools/dashboard/dashboardApp.ts
+++ b/packages/playwright-core/src/tools/dashboard/dashboardApp.ts
@@ -25,7 +25,7 @@ import { gracefullyProcessExitDoNotHang } from '@utils/processLauncher';
import { libPath } from '../../package';
import { playwright } from '../../inprocess';
import { findChromiumChannelBestEffort, registryDirectory } from '../../server/registry/index';
-import { CDPConnection, DashboardConnection } from './dashboardController';
+import { DashboardConnection } from './dashboardController';
import type * as api from '../../..';
@@ -35,22 +35,10 @@ async function innerOpenDashboardApp(): Promise<api.Page> {
const connections = new Set<DashboardConnection>();
- httpServer.createWebSocket(url => {
- const cdpPageId = url.searchParams.get('cdpPageId');
- if (cdpPageId) {
- for (const conn of connections) {
- const page = conn.pageForId(cdpPageId);
- if (page)
- return new CDPConnection(page);
- }
- throw new Error('Page not found for cdpPageId: ' + cdpPageId);
- }
-
- const cdpUrl = new URL(httpServer.urlPrefix('human-readable'));
- cdpUrl.pathname = '/ws';
+ httpServer.createWebSocket(() => {
let connection: DashboardConnection;
// eslint-disable-next-line prefer-const
- connection = new DashboardConnection(cdpUrl, () => connections.delete(connection));
+ connection = new DashboardConnection(() => connections.delete(connection));
connections.add(connection);
return connection;
}, 'ws');
@@ -113,7 +101,7 @@ async function launchApp(appName: string) {
}
export async function syncLocalStorageWithSettings(page: api.Page, appName: string) {
- const settingsFile = path.join(registryDirectory, '.settings', `${appName}.json`);
+ const settingsFile = process.env.PLAYWRIGHT_DASHBOARD_SETTINGS_FILE_FOR_TEST ?? path.join(registryDirectory, '.settings', `${appName}.json`);
await page.exposeBinding('_saveSerializedSettings', (_, settings) => {
fs.mkdirSync(path.dirname(settingsFile), { recursive: true });
diff --git a/packages/playwright-core/src/tools/dashboard/dashboardController.ts b/packages/playwright-core/src/tools/dashboard/dashboardController.ts
index 9817868ce5..f88c375d39 100644
--- a/packages/playwright-core/src/tools/dashboard/dashboardController.ts
+++ b/packages/playwright-core/src/tools/dashboard/dashboardController.ts
@@ -14,6 +14,10 @@
* limitations under the License.
*/
+import path from 'path';
+import os from 'os';
+import fs from 'fs';
+import { execFile } from 'child_process';
import { eventsHelper } from '@utils/eventsHelper';
import { connectToBrowserAcrossVersions } from '../utils/connect';
import { serverRegistry } from '../../serverRegistry';
@@ -33,15 +37,16 @@ export class DashboardConnection implements Transport {
close?: () => void;
private _attached = new Map<string, AttachedBrowser>();
- private _cdpUrl: URL;
private _onclose: () => void;
private _serverRegistryDispose?: () => void;
private _pushSessionsScheduled = false;
private _visible = true;
- constructor(cdpUrl: URL, onclose: () => void) {
- this._cdpUrl = cdpUrl;
+ _recordingDir: string;
+
+ constructor(onclose: () => void) {
this._onclose = onclose;
+ this._recordingDir = fs.mkdtempSync(path.join(os.tmpdir(), 'playwright-recordings-'));
}
onconnect() {
@@ -118,6 +123,20 @@ export class DashboardConnection implements Transport {
await Promise.all([...this._attached.values()].map(att => att.setScreencastActive(params.visible)));
}
+ async reveal(params: { path: string }) {
+ switch (os.platform()) {
+ case 'darwin':
+ execFile('open', ['-R', params.path]);
+ break;
+ case 'win32':
+ execFile('explorer', ['/select,', params.path]);
+ break;
+ case 'linux':
+ execFile('xdg-open', [path.dirname(params.path)]);
+ break;
+ }
+ }
+
visible(): boolean {
return this._visible;
}
@@ -131,10 +150,6 @@ export class DashboardConnection implements Transport {
return undefined;
}
- cdpUrl(): URL {
- return this._cdpUrl;
- }
-
emitSessions(sessions: BrowserStatus[]) {
this.sendEvent?.('sessions', { sessions, clientInfo: createClientInfo() });
}
@@ -150,10 +165,11 @@ export class DashboardConnection implements Transport {
});
}
- emitElementPicked(att: AttachedBrowser, pageGuid: string, selector: string) {
+ emitElementPicked(att: AttachedBrowser, pageGuid: string, selector: string, ariaSnapshot?: string) {
this.sendEvent?.('elementPicked', {
target: { browser: att.browserGuid, context: att.contextGuid, page: pageGuid },
selector,
+ ariaSnapshot,
});
}
@@ -192,6 +208,7 @@ class AttachedBrowser {
private _selectedPage: api.Page | null = null;
private _screencastRunning = false;
+ private _recordingPath: string | null = null;
private _pageListeners: Disposable[] = [];
private _contextListeners: Disposable[] = [];
@@ -231,6 +248,7 @@ class AttachedBrowser {
if (this._selectedPage && this._screencastRunning)
this._selectedPage.screencast.stop().catch(() => {});
this._screencastRunning = false;
+ this._recordingPath = null;
this._selectedPage = null;
}
@@ -327,13 +345,42 @@ class AttachedBrowser {
if (!page)
return;
const locator = await page.pickLocator();
- this._owner.emitElementPicked(this, this._pageId(page), locator.toString());
+ this._owner.emitElementPicked(this, this._pageId(page), locator.toString(), await locator.ariaSnapshot());
}
async cancelPickLocator(params: { page: string }) {
await this.pageForId(params.page)?.cancelPickLocator();
}
+ async startRecording(params: { page: string }) {
+ const page = this.pageForId(params.page);
+ if (!page)
+ return;
+ const artifactsDir = this._descriptor.browser.launchOptions.artifactsDir ?? this._owner._recordingDir;
+ this._recordingPath = path.join(artifactsDir, `recording-${Date.now()}.webm`);
+ if (page === this._selectedPage && this._screencastRunning)
+ await this._restartScreencast(page);
+ }
+
+ async stopRecording(params: { page: string }): Promise<{ path: string }> {
+ const path = this._recordingPath;
+ if (!path)
+ throw new Error('No recording in progress');
+ this._recordingPath = null;
+ const page = this.pageForId(params.page);
+ if (page && page === this._selectedPage && this._screencastRunning)
+ await this._restartScreencast(page);
+ return { path };
+ }
+
+ async screenshot(params: { page: string }): Promise<string> {
+ const page = this.pageForId(params.page);
+ if (!page)
+ throw new Error('No page selected');
+ const buffer = await page.screenshot({ type: 'png' });
+ return buffer.toString('base64');
+ }
+
private async _selectPage(page: api.Page) {
if (this._selectedPage === page)
return;
@@ -344,6 +391,7 @@ class AttachedBrowser {
if (this._screencastRunning)
await this._selectedPage.screencast.stop();
this._screencastRunning = false;
+ this._recordingPath = null;
}
this._selectedPage = page;
@@ -373,9 +421,15 @@ class AttachedBrowser {
await page.screencast.start({
onFrame: ({ data }: { data: Buffer }) => this._writeFrame(page, data, page.viewportSize()?.width ?? 0, page.viewportSize()?.height ?? 0),
size: { width: 1280, height: 800 },
+ ...(this._recordingPath ? { path: this._recordingPath } : {}),
});
}
+ private async _restartScreencast(page: api.Page) {
+ await page.screencast.stop().catch(() => {});
+ await this._startScreencast(page);
+ }
+
private _deselectPage() {
if (!this._selectedPage)
return;
@@ -384,6 +438,7 @@ class AttachedBrowser {
if (this._screencastRunning)
this._selectedPage.screencast.stop().catch(() => {});
this._screencastRunning = false;
+ this._recordingPath = null;
this._selectedPage = null;
}
@@ -399,7 +454,6 @@ class AttachedBrowser {
const pages = this._context.pages();
if (pages.length === 0)
return [];
- const devtoolsUrl = await this._devtoolsUrl(pages[0]);
return await Promise.all(pages.map(async page => {
const title = await page.title();
return {
@@ -409,7 +463,7 @@ class AttachedBrowser {
title,
url: page.url(),
selected: page === this._selectedPage,
- inspectorUrl: devtoolsUrl ? await this._pageInspectorUrl(page, devtoolsUrl) : 'data:text/plain,Dashboard only supported in Chromium based browsers',
+ faviconUrl: await this._faviconUrl(page),
};
}));
}
@@ -419,79 +473,20 @@ class AttachedBrowser {
return (p as any)._guid;
}
- private async _devtoolsUrl(page: api.Page): Promise<URL | null> {
- // eslint-disable-next-line no-restricted-syntax -- cdpPort is not in the public LaunchOptions type, fine if regresses.
- const cdpPort = (this._descriptor.browser.launchOptions as any).cdpPort;
- if (cdpPort)
- return new URL(`http://localhost:${cdpPort}/devtools/`);
-
- const browserRevision = await getBrowserRevision(page);
- if (!browserRevision)
- return null;
- return new URL(`https://chrome-devtools-frontend.appspot.com/serve_rev/${browserRevision}/`);
- }
-
- private async _pageInspectorUrl(page: api.Page, devtoolsUrl: URL): Promise<string | undefined> {
- const inspector = new URL('./devtools_app.html', devtoolsUrl);
- const cdp = new URL(this._owner.cdpUrl());
- cdp.searchParams.set('cdpPageId', this._pageId(page));
- inspector.searchParams.set('ws', `${cdp.host}${cdp.pathname}${cdp.search}`);
- return inspector.toString();
- }
-}
-
-async function getBrowserRevision(page: api.Page): Promise<string | null> {
- try {
- const session = await page.context().newCDPSession(page);
- const version = await session.send('Browser.getVersion');
- await session.detach();
- return version.revision;
- } catch (error) {
- return null;
- }
-}
-
-export class CDPConnection implements Transport {
- sendEvent?: (method: string, params: any) => void;
- close?: () => void;
-
- private _page: api.Page;
- private _rawSession: api.CDPSession | null = null;
- private _rawSessionListeners: { dispose: () => Promise<void> }[] = [];
- private _initializePromise: Promise<void> | undefined;
-
- constructor(page: api.Page) {
- this._page = page;
- }
-
- onconnect() {
- this._initializePromise = this._initializeRawSession();
- }
-
- async dispatch(method: string, params: any): Promise<any> {
- await this._initializePromise;
- if (!this._rawSession)
- throw new Error('CDP session is not initialized');
- return await this._rawSession.send(method as Parameters<api.CDPSession['send']>[0], params);
- }
-
- onclose() {
- this._rawSessionListeners.forEach(listener => listener.dispose());
- this._rawSession?.detach().catch(() => {});
- this._rawSession = null;
- this._initializePromise = undefined;
- }
-
- private async _initializeRawSession() {
- const session = await this._page.context().newCDPSession(this._page);
- this._rawSession = session;
- this._rawSessionListeners = [
- eventsHelper.addEventListener(session, 'event', ({ method, params }) => {
- this.sendEvent?.(method, params);
- }),
- eventsHelper.addEventListener(session, 'close', () => {
- this.close?.();
- }),
- ];
+ private async _faviconUrl(page: api.Page): Promise<string | undefined> {
+ const url = await page.evaluate(async () => {
+ const response = await fetch(document.querySelector<HTMLLinkElement>('link[rel~="icon"]')?.href ?? '/favicon.ico');
+ if (!response.ok)
+ return undefined;
+ const blob = await response.blob();
+ return await new Promise<string>((resolve, reject) => {
+ const reader = new FileReader();
+ reader.onloadend = () => resolve(reader.result as string);
+ reader.onerror = reject;
+ reader.readAsDataURL(blob);
+ });
+ }).catch(() => undefined);
+ const timeout = new Promise<undefined>(resolve => setTimeout(() => resolve(undefined), 3000));
+ return await Promise.race([url, timeout]);
}
}
diff --git a/packages/web/package.json b/packages/web/package.json
index 0c45c30c7b..88174fe4bc 100644
--- a/packages/web/package.json
+++ b/packages/web/package.json
@@ -6,6 +6,7 @@
"dependencies": {
"codemirror": "5.65.18",
"@xterm/xterm": "^5.5.0",
- "@xterm/addon-fit": "^0.10.0"
+ "@xterm/addon-fit": "^0.10.0",
+ "yaml": "^2.8.3"
}
}
diff --git a/packages/web/src/DEPS.list b/packages/web/src/DEPS.list
index e43dcb5d9f..d44a4d0367 100644
--- a/packages/web/src/DEPS.list
+++ b/packages/web/src/DEPS.list
@@ -1 +1,2 @@
[*]
+../isomorphic/**
diff --git a/packages/web/src/components/DEPS.list b/packages/web/src/components/DEPS.list
index 9b747867be..2d302f4c6e 100644
--- a/packages/web/src/components/DEPS.list
+++ b/packages/web/src/components/DEPS.list
@@ -4,6 +4,7 @@
../uiUtils.ts
../ansi2html.ts
../shared
+../../../isomorphic/**
[expandable.spec.tsx]
***
diff --git a/tests/mcp/cli-fixtures.ts b/tests/mcp/cli-fixtures.ts
index ccbf791953..c44eb2554f 100644
--- a/tests/mcp/cli-fixtures.ts
+++ b/tests/mcp/cli-fixtures.ts
@@ -23,7 +23,7 @@ import { test as baseTest } from './fixtures';
import { killProcessGroup } from '../config/commonFixtures';
import { inheritAndCleanEnv } from '../config/utils';
-import type { Page } from 'playwright-core';
+import type { Browser, Page } from 'playwright-core';
import type { CommonFixtures } from '../config/commonFixtures';
export { expect } from './fixtures';
@@ -44,7 +44,7 @@ export const test = baseTest.extend<{
await use(cliEnv());
},
openDashboard: async ({ cli, waitForPort, findFreePort }, use) => {
- const dashboards = [];
+ const dashboards: { dashboard: Page, browser: Browser }[] = [];
await use(async (options?: { cwd?: string }) => {
const debugPort = await findFreePort();
await cli('show', { cwd: options?.cwd, env: { PLAYWRIGHT_DASHBOARD_DEBUG_PORT: String(debugPort) } });
@@ -57,6 +57,8 @@ export const test = baseTest.extend<{
for (const { dashboard, browser } of dashboards) {
if (!browser.isConnected())
continue;
+ if (test.info().error)
+ await test.info().attach('dashboard', { body: await dashboard.ariaSnapshot({ mode: 'ai' }), contentType: 'text/yaml' });
await Promise.all([
// Closing the page should close the browser.
new Promise(r => browser.on('disconnected', r)),
@@ -92,6 +94,7 @@ export const test = baseTest.extend<{
function cliEnv() {
return {
PLAYWRIGHT_SERVER_REGISTRY: test.info().outputPath('registry'),
+ PLAYWRIGHT_DASHBOARD_SETTINGS_FILE_FOR_TEST: test.info().outputPath('dashboard.settings.json'),
PLAYWRIGHT_DAEMON_SESSION_DIR: test.info().outputPath('daemon'),
PLAYWRIGHT_SOCKETS_DIR: path.join(test.info().project.outputDir, 'ds', String(test.info().parallelIndex)),
};
diff --git a/tests/mcp/dashboard.spec.ts b/tests/mcp/dashboard.spec.ts
index 22e4712c10..ca5e0cc21d 100644
--- a/tests/mcp/dashboard.spec.ts
+++ b/tests/mcp/dashboard.spec.ts
@@ -31,20 +31,6 @@ test('should show browser session chip', async ({ cli, server, openDashboard })
await expect(chips).toHaveCount(1);
});
-test('should show devtools sidebar', async ({ cli, server, openDashboard, mcpBrowser }) => {
- test.skip(!['chrome', 'msedge', 'chromium'].includes(mcpBrowser!), 'DevTools sidebar requires CDP, only available in Chromium');
-
- await cli('open', server.EMPTY_PAGE);
-
- const dashboard = await openDashboard();
- await dashboard.locator('.session-chip').click();
-
- const devToolsButton = dashboard.locator('button.nav-btn[title="Chrome DevTools"]');
- await expect(dashboard.locator('.inspector-frame')).not.toBeVisible();
- await devToolsButton.click();
- await expect(dashboard.locator('.inspector-frame')).toBeVisible();
-});
-
test('should show current workspace sessions first', async ({ cli, server, openDashboard }) => {
const wsA = test.info().outputPath('workspace-a');
const wsB = test.info().outputPath('workspace-b');
@@ -88,31 +74,13 @@ test('should pick locator from browser', async ({ cli, server, openDashboard })
const dashboard = await openDashboard();
await dashboard.locator('.session-chip').click();
- const pickBtn = dashboard.locator('button.nav-btn[title="Pick locator"]');
- await pickBtn.click();
+ await dashboard.getByRole('button', { name: 'Show sidebar' }).click();
+ await dashboard.getByRole('button', { name: 'Pick locator' }).click();
await expect(dashboard.locator('div.dashboard-view')).toContainClass('interactive');
- // Intercept clipboard writes before clicking pick.
- const copyPromise = dashboard.evaluate(() => {
- if (!navigator.clipboard)
- return 'no clipboard';
- return new Promise<string>(f => {
- const original = navigator.clipboard.writeText;
- navigator.clipboard.writeText = text => {
- f(text);
- navigator.clipboard.writeText = original;
- return navigator.clipboard.writeText(text);
- };
- });
- }).catch(e => `Exception in eval: ${e}`);
-
await expect(async () => {
- await dashboard.locator('img#display').click({ position: { x: 50, y: 25 } });
- const text = await Promise.race([
- copyPromise,
- new Promise<string>(f => setTimeout(() => f('timeout'), 1000))
- ]);
- expect(text).toContain('Submit');
+ await dashboard.locator('img#display').click({ position: { x: 500, y: 25 } });
+ await expect(dashboard.locator('.cm-wrapper').first()).toContainText(`getByRole('button', { name: 'Submit' })`);
}).toPass();
});
diff --git a/tsconfig.json b/tsconfig.json
index cc2f5082a6..f321b66211 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -11,6 +11,7 @@
- .../lib/* means require dependency
*/
"@dashboard/*": ["./packages/dashboard/src/*"],
+ "@trace-viewer/*": ["./packages/trace-viewer/src/*"],
"@html-reporter/*": ["./packages/html-reporter/src/*"],
"@injected/*": ["./packages/injected/src/*"],
"@isomorphic/*": ["./packages/isomorphic/*"],