Skip to content

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

feat(uimode): add pick locator button to inspector tab (#37753)

Adam Gastineau2efc46a5d9a0
diff --git a/packages/trace-viewer/src/ui/inspectorTab.tsx b/packages/trace-viewer/src/ui/inspectorTab.tsx
index f7392234ec..cc93d25935 100644
--- a/packages/trace-viewer/src/ui/inspectorTab.tsx
+++ b/packages/trace-viewer/src/ui/inspectorTab.tsx
@@ -27,10 +27,11 @@ import type { Language } from '@isomorphic/locatorGenerators';
export const InspectorTab: React.FunctionComponent<{
sdkLanguage: Language,
+ isInspecting: boolean,
setIsInspecting: (isInspecting: boolean) => void,
highlightedElement: HighlightedElement,
setHighlightedElement: (element: HighlightedElement) => void,
-}> = ({ sdkLanguage, setIsInspecting, highlightedElement, setHighlightedElement }) => {
+}> = ({ sdkLanguage, isInspecting, setIsInspecting, highlightedElement, setHighlightedElement }) => {
const [ariaSnapshotErrors, setAriaSnapshotErrors] = React.useState<SourceHighlight[]>();
const onAriaEditorChange = React.useCallback((ariaSnapshot: string) => {
const { errors } = parseAriaSnapshot(yaml, ariaSnapshot, { prettyErrors: false });
@@ -50,7 +51,9 @@ export const InspectorTab: React.FunctionComponent<{
return <div style={{ flex: 'auto', backgroundColor: 'var(--vscode-sideBar-background)', padding: '0 10px 10px 10px', overflow: 'auto' }}>
<div className='hbox' style={{ lineHeight: '28px', color: 'var(--vscode-editorCodeLens-foreground)' }}>
- <div style={{ flex: 'auto' }}>Locator</div>
+ <div>Locator</div>
+ <ToolbarButton style={{ margin: '0 4px' }} title='Pick locator' icon='target' toggled={isInspecting} onClick={() => setIsInspecting(!isInspecting)} />
+ <div style={{ flex: 'auto' }}></div>
<ToolbarButton icon='files' title='Copy locator' onClick={() => {
copy(highlightedElement.locator || '');
}}></ToolbarButton>
diff --git a/packages/trace-viewer/src/ui/workbench.tsx b/packages/trace-viewer/src/ui/workbench.tsx
index bd23dcac77..b529746094 100644
--- a/packages/trace-viewer/src/ui/workbench.tsx
+++ b/packages/trace-viewer/src/ui/workbench.tsx
@@ -182,6 +182,7 @@ export const Workbench: React.FunctionComponent<{
title: 'Locator',
render: () => <InspectorTab
sdkLanguage={sdkLanguage}
+ isInspecting={isInspecting}
setIsInspecting={setIsInspecting}
highlightedElement={highlightedElement}
setHighlightedElement={setHighlightedElement} />,