Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore: two-line trace view (2) (#36055)
Pavel Feldmane0365747ce26
diff --git a/packages/playwright-core/src/client/channelOwner.ts b/packages/playwright-core/src/client/channelOwner.tsindex 9fb73a5df0..03bde8c975 100644--- a/packages/playwright-core/src/client/channelOwner.ts+++ b/packages/playwright-core/src/client/channelOwner.ts@@ -154,9 +154,8 @@ export abstract class ChannelOwner<T extends channels.Channel = channels.Channelconst validatedParams = validator(params, '', this._validatorToWireContext());if (!apiZone.internal && !apiZone.reported) {// Reporting/tracing/logging this api call for the first time.- apiZone.params = params;apiZone.reported = true;- this._instrumentation.onApiCallBegin(apiZone);+ this._instrumentation.onApiCallBegin(apiZone, { type: this._type, method: prop, params });logApiCall(this._platform, this._logger, `=> ${apiZone.apiName} started`);return await this._connection.sendMessageToServer(this, prop, validatedParams, apiZone);}@@ -238,7 +237,6 @@ function tChannelImplToWire(names: '*' | string[], arg: any, path: string, contetype ApiZone = {apiName: string;- params?: Record<string, any>;frames: channels.StackFrame[];title?: string;internal?: boolean;diff --git a/packages/playwright-core/src/client/clientInstrumentation.ts b/packages/playwright-core/src/client/clientInstrumentation.tsindex d17b8b85bc..b14a3de064 100644--- a/packages/playwright-core/src/client/clientInstrumentation.ts+++ b/packages/playwright-core/src/client/clientInstrumentation.ts@@ -22,7 +22,6 @@ import type { StackFrame } from '@protocol/channels';export interface ApiCallData {apiName: string;title?: string;- params?: Record<string, any>;frames: StackFrame[];userData: any;stepId?: string;@@ -33,7 +32,7 @@ export interface ClientInstrumentation {addListener(listener: ClientInstrumentationListener): void;removeListener(listener: ClientInstrumentationListener): void;removeAllListeners(): void;- onApiCallBegin(apiCall: ApiCallData): void;+ onApiCallBegin(apiCall: ApiCallData, channel: { type: string, method: string, params?: Record<string, any> }): void;onApiCallEnd(apiCal: ApiCallData): void;onWillPause(options: { keepTestTimeout: boolean }): void;@@ -44,7 +43,7 @@ export interface ClientInstrumentation {}export interface ClientInstrumentationListener {- onApiCallBegin?(apiCall: ApiCallData): void;+ onApiCallBegin?(apiCall: ApiCallData, channel: { type: string, method: string, params?: Record<string, any> }): void;onApiCallEnd?(apiCall: ApiCallData): void;onWillPause?(options: { keepTestTimeout: boolean }): void;diff --git a/packages/playwright-core/src/client/connection.ts b/packages/playwright-core/src/client/connection.tsindex cfafb4f929..2c64ebb2a4 100644--- a/packages/playwright-core/src/client/connection.ts+++ b/packages/playwright-core/src/client/connection.ts@@ -138,7 +138,7 @@ export class Connection extends EventEmitter {this._platform.log('channel', 'SEND> ' + JSON.stringify(message));}const location = options.frames?.[0] ? { file: options.frames[0].file, line: options.frames[0].line, column: options.frames[0].column } : undefined;- const metadata: channels.Metadata = { title: options.title, location, internal: options.internal, stepId: options.stepId, apiName: options.apiName };+ const metadata: channels.Metadata = { title: options.title, location, internal: options.internal, stepId: options.stepId };if (this._tracingCount && options.frames && type !== 'LocalUtils')this._localUtils?.addStackToTracingNoReply({ callData: { stack: options.frames ?? [], id } }).catch(() => {});// We need to exit zones before calling into the server, otherwisediff --git a/packages/playwright-core/src/client/locator.ts b/packages/playwright-core/src/client/locator.tsindex 08050901e6..ceb607ab5c 100644--- a/packages/playwright-core/src/client/locator.ts+++ b/packages/playwright-core/src/client/locator.ts@@ -111,9 +111,7 @@ export class Locator implements api.Locator {}async dblclick(options: channels.ElementHandleDblclickOptions & TimeoutOptions = {}): Promise<void> {- await this._frame._wrapApiCall(async () => {- return await this._frame.dblclick(this._selector, { strict: true, ...options });- }, { title: 'Double click' });+ await this._frame.dblclick(this._selector, { strict: true, ...options });}async dispatchEvent(type: string, eventInit: Object = {}, options?: TimeoutOptions) {diff --git a/packages/playwright-core/src/client/page.ts b/packages/playwright-core/src/client/page.tsindex ecb9d9cf70..6b86acdf73 100644--- a/packages/playwright-core/src/client/page.ts+++ b/packages/playwright-core/src/client/page.ts@@ -543,10 +543,8 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page}async unrouteAll(options?: { behavior?: 'wait'|'ignoreErrors'|'default' }): Promise<void> {- await this._wrapApiCall(async () => {- await this._unrouteInternal(this._routes, [], options?.behavior);- this._disposeHarRouters();- }, { title: 'Unroute all' });+ await this._unrouteInternal(this._routes, [], options?.behavior);+ this._disposeHarRouters();}async unroute(url: URLMatch, handler?: RouteHandlerCallback): Promise<void> {@@ -656,9 +654,7 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page}async dblclick(selector: string, options?: channels.FrameDblclickOptions & TimeoutOptions) {- await this._wrapApiCall(async () => {- return await this._mainFrame.dblclick(selector, options);- }, { title: 'Double click' });+ await this._mainFrame.dblclick(selector, options);}async tap(selector: string, options?: channels.FrameTapOptions & TimeoutOptions) {diff --git a/packages/playwright-core/src/protocol/debug.ts b/packages/playwright-core/src/protocol/debug.tsindex 26194db5ee..53fc12499d 100644--- a/packages/playwright-core/src/protocol/debug.ts+++ b/packages/playwright-core/src/protocol/debug.ts@@ -82,8 +82,8 @@ export const methodMetainfo = new Map<string, { internal?: boolean, title?: stri['BrowserContext.setExtraHTTPHeaders', { title: 'Set extra HTTP headers', }],['BrowserContext.setGeolocation', { title: 'Set geolocation', }],['BrowserContext.setHTTPCredentials', { title: 'Set HTTP credentials', }],- ['BrowserContext.setNetworkInterceptionPatterns', { }],- ['BrowserContext.setWebSocketInterceptionPatterns', { title: 'Route web sockets', }],+ ['BrowserContext.setNetworkInterceptionPatterns', { internal: true, }],+ ['BrowserContext.setWebSocketInterceptionPatterns', { internal: true, }],['BrowserContext.setOffline', { title: 'Set offline mode', }],['BrowserContext.storageState', { title: 'Get storage state', }],['BrowserContext.pause', { title: 'Pause', }],@@ -114,8 +114,8 @@ export const methodMetainfo = new Map<string, { internal?: boolean, title?: stri['Page.expectScreenshot', { title: 'Expect screenshot', snapshot: true, }],['Page.screenshot', { title: 'Screenshot', snapshot: true, }],['Page.setExtraHTTPHeaders', { title: 'Set extra HTTP headers', }],- ['Page.setNetworkInterceptionPatterns', { title: 'Route', }],- ['Page.setWebSocketInterceptionPatterns', { title: 'Route web sockets', }],+ ['Page.setNetworkInterceptionPatterns', { internal: true, }],+ ['Page.setWebSocketInterceptionPatterns', { internal: true, }],['Page.setViewportSize', { title: 'Set viewport size', snapshot: true, }],['Page.keyboardDown', { title: 'Key down "{key}"', slowMo: true, snapshot: true, }],['Page.keyboardUp', { title: 'Key up "{key}"', slowMo: true, snapshot: true, }],@@ -257,7 +257,7 @@ export const methodMetainfo = new Map<string, { internal?: boolean, title?: stri['Dialog.dismiss', { title: 'Dismiss dialog', }],['Tracing.tracingStart', { internal: true, }],['Tracing.tracingStartChunk', { internal: true, }],- ['Tracing.tracingGroup', { }],+ ['Tracing.tracingGroup', { title: 'Trace "{name}"', }],['Tracing.tracingGroupEnd', { title: 'Group end', }],['Tracing.tracingStopChunk', { internal: true, }],['Tracing.tracingStop', { internal: true, }],diff --git a/packages/playwright-core/src/protocol/formatter.ts b/packages/playwright-core/src/protocol/formatter.tsnew file mode 100644index 0000000000..6d273cf5a6--- /dev/null+++ b/packages/playwright-core/src/protocol/formatter.ts@@ -0,0 +1,48 @@+/**+ * Copyright (c) Microsoft Corporation.+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++export function formatProtocolParam(params: Record<string, string> | undefined, name: string): string {+ if (!params)+ return '';+ if (name === 'url') {+ try {+ const urlObject = new URL(params[name]);+ if (urlObject.protocol === 'data:')+ return urlObject.protocol;+ if (urlObject.protocol === 'about:')+ return params[name];+ return urlObject.pathname + urlObject.search;+ } catch (error) {+ return params[name];+ }+ }+ if (name === 'timeNumber')+ return new Date(params[name]).toString();+ return deepParam(params, name);+}++function deepParam(params: Record<string, any>, name: string): string {+ const tokens = name.split('.');+ let current = params;+ for (const token of tokens) {+ if (typeof current !== 'object' || current === null)+ return '';+ current = current[token];+ }+ if (current === undefined)+ return '';+ return String(current);+}diff --git a/packages/playwright-core/src/protocol/validator.ts b/packages/playwright-core/src/protocol/validator.tsindex dadc791a26..ebb415de57 100644--- a/packages/playwright-core/src/protocol/validator.ts+++ b/packages/playwright-core/src/protocol/validator.ts@@ -32,7 +32,6 @@ scheme.Metadata = tObject({line: tOptional(tNumber),column: tOptional(tNumber),})),- apiName: tOptional(tString),title: tOptional(tString),internal: tOptional(tBoolean),stepId: tOptional(tString),diff --git a/packages/playwright-core/src/server/debugger.ts b/packages/playwright-core/src/server/debugger.tsindex 2006461f4c..1bec695569 100644--- a/packages/playwright-core/src/server/debugger.ts+++ b/packages/playwright-core/src/server/debugger.ts@@ -131,7 +131,7 @@ function shouldPauseOnCall(sdkObject: SdkObject, metadata: CallMetadata): booleafunction shouldPauseBeforeStep(metadata: CallMetadata): boolean {// Don't stop on internal.- if (!metadata.apiName || metadata.internal)+ if (metadata.internal)return false;// Always stop on 'close'if (metadata.method === 'close')diff --git a/packages/playwright-core/src/server/dispatchers/dispatcher.ts b/packages/playwright-core/src/server/dispatchers/dispatcher.tsindex 72888a99d7..565fd419bd 100644--- a/packages/playwright-core/src/server/dispatchers/dispatcher.ts+++ b/packages/playwright-core/src/server/dispatchers/dispatcher.ts@@ -18,7 +18,7 @@ import { EventEmitter } from 'events';import { eventsHelper } from '../utils/eventsHelper';import { ValidationError, createMetadataValidator, findValidator } from '../../protocol/validator';-import { LongStandingScope, assert, monotonicTime, rewriteErrorMessage } from '../../utils';+import { LongStandingScope, assert, formatProtocolParam, monotonicTime, rewriteErrorMessage } from '../../utils';import { isUnderTest } from '../utils/debug';import { TargetClosedError, isTargetClosedError, serializeError } from '../errors';import { SdkObject } from '../instrumentation';@@ -309,7 +309,6 @@ export class DispatcherConnection {const callMetadata: CallMetadata = {id: `call@${id}`,location: validMetadata.location,- apiName: validMetadata.apiName,title: renderTitle(dispatcher._type, method, params, validMetadata.title),internal: validMetadata.internal,stepId: validMetadata.stepId,@@ -391,42 +390,9 @@ function closeReason(sdkObject: SdkObject): string | undefined {sdkObject.attribution.browser?._closeReason;}-function formatParam(params: Record<string, string> | undefined, name: string): string {- if (!params)- return '';- if (name === 'url') {- try {- const urlObject = new URL(params[name]);- if (urlObject.protocol === 'data:')- return urlObject.protocol;- if (urlObject.protocol === 'about:')- return params[name];- return urlObject.pathname + urlObject.search;- } catch (error) {- return params[name];- }- }- if (name === 'timeNumber')- return new Date(params[name]).toString();- return deepParam(params, name);-}--function deepParam(params: Record<string, any>, name: string): string {- const tokens = name.split('.');- let current = params;- for (const token of tokens) {- if (typeof current !== 'object' || current === null)- return '';- current = current[token];- }- if (current === undefined)- return '';- return String(current);-}-function renderTitle(type: string, method: string, params: Record<string, string> | undefined, title?: string) {const titleFormat = title ?? methodMetainfo.get(type + '.' + method)?.title ?? method;return titleFormat.replace(/\{([^}]+)\}/g, (_, p1) => {- return formatParam(params, p1);+ return formatProtocolParam(params, p1);});}diff --git a/packages/playwright-core/src/server/frames.ts b/packages/playwright-core/src/server/frames.tsindex 534992d861..6d4fc32a71 100644--- a/packages/playwright-core/src/server/frames.ts+++ b/packages/playwright-core/src/server/frames.ts@@ -1432,7 +1432,7 @@ export class Frame extends SdkObject {// Step 1: perform locator handlers checkpoint with a specified timeout.await (new ProgressController(metadata, this)).run(async progress => {- progress.log(`${metadata.apiName}${timeout ? ` with timeout ${timeout}ms` : ''}`);+ progress.log(`${metadata.title}${timeout ? ` with timeout ${timeout}ms` : ''}`);progress.log(`waiting for ${this._asLocator(selector)}`);await this._page.performActionPreChecks(progress);}, timeout);diff --git a/packages/playwright-core/src/server/page.ts b/packages/playwright-core/src/server/page.tsindex e431e48836..ae5449bbe6 100644--- a/packages/playwright-core/src/server/page.ts+++ b/packages/playwright-core/src/server/page.ts@@ -624,7 +624,7 @@ export class Page extends SdkObject {let actual: Buffer | undefined;let previous: Buffer | undefined;const pollIntervals = [0, 100, 250, 500];- progress.log(`${metadata.apiName}${callTimeout ? ` with timeout ${callTimeout}ms` : ''}`);+ progress.log(`${metadata.title}${callTimeout ? ` with timeout ${callTimeout}ms` : ''}`);if (options.expected)progress.log(` verifying given screenshot expectation`);elsediff --git a/packages/playwright-core/src/utils.ts b/packages/playwright-core/src/utils.tsindex 4f2f04fc11..090d50d42b 100644--- a/packages/playwright-core/src/utils.ts+++ b/packages/playwright-core/src/utils.ts@@ -52,4 +52,7 @@ export * from './server/utils/wsServer';export * from './server/utils/zipFile';export * from './server/utils/zones';+export * from './protocol/debug';+export * from './protocol/formatter';+export { colors } from './utilsBundle';diff --git a/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts b/packages/playwright-core/src/utils/isomorphic/locatorGenerators.tsindex 9769eca0fb..b27eba6ebb 100644--- a/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts+++ b/packages/playwright-core/src/utils/isomorphic/locatorGenerators.ts@@ -37,12 +37,12 @@ export interface LocatorFactory {chainLocators(locators: string[]): string;}-export function asLocatorDescription(selector: string): string | undefined {+export function asLocatorDescription(lang: Language, selector: string): string | undefined {const parsed = parseSelector(selector);const describe = parsed.parts.findLast(part => part.name === 'internal:describe');if (describe)return JSON.parse(describe.body as string);- return undefined;+ return asLocator(lang, selector);}export function asLocator(lang: Language, selector: string, isFrameLocator: boolean = false): string {diff --git a/packages/playwright/src/index.ts b/packages/playwright/src/index.tsindex 470a83454d..b1d907acbd 100644--- a/packages/playwright/src/index.ts+++ b/packages/playwright/src/index.ts@@ -18,7 +18,7 @@ import fs from 'fs';import path from 'path';import * as playwrightLibrary from 'playwright-core';-import { setBoxedStackPrefixes, createGuid, currentZone, debugMode, isString, jsonStringifyForceASCII, asLocator, asLocatorDescription } from 'playwright-core/lib/utils';+import { setBoxedStackPrefixes, createGuid, currentZone, debugMode, jsonStringifyForceASCII, methodMetainfo, asLocatorDescription, formatProtocolParam } from 'playwright-core/lib/utils';import { currentTestInfo } from './common/globals';import { rootTestType } from './common/testType';@@ -27,7 +27,7 @@ import { attachErrorContext } from './errorContext';import type { Fixtures, PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, ScreenshotMode, TestInfo, TestType, VideoMode } from '../types/test';import type { ContextReuseMode } from './common/config';import type { TestInfoImpl, TestStepInternal } from './worker/testInfo';-import type { ApiCallData, ClientInstrumentation, ClientInstrumentationListener } from '../../playwright-core/src/client/clientInstrumentation';+import type { ClientInstrumentation, ClientInstrumentationListener } from '../../playwright-core/src/client/clientInstrumentation';import type { Playwright as PlaywrightImpl } from '../../playwright-core/src/client/playwright';import type { APIRequestContext, Browser, BrowserContext, BrowserContextOptions, LaunchOptions, Page, Tracing, Video } from 'playwright-core';@@ -258,7 +258,7 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({const tracingGroupSteps: TestStepInternal[] = [];const csiListener: ClientInstrumentationListener = {- onApiCallBegin: (data: ApiCallData) => {+ onApiCallBegin: (data, channel) => {const testInfo = currentTestInfo();// Some special calls do not get into steps.if (!testInfo || data.apiName.includes('setTestIdAttribute') || data.apiName === 'tracing.groupEnd')@@ -274,20 +274,21 @@ const playwrightFixtures: Fixtures<TestFixtures, WorkerFixtures> = ({data.stepId = zone.stepId;return;}+// In the general case, create a step for each api call and connect them through the stepId.const step = testInfo._addStep({location: data.frames[0],category: 'pw:api',- title: renderApiCall(data.apiName, data.params),+ title: renderTitle(channel.type, channel.method, channel.params, data.title),apiName: data.apiName,- params: data.params,+ params: channel.params,}, tracingGroupSteps[tracingGroupSteps.length - 1]);data.userData = step;data.stepId = step.stepId;if (data.apiName === 'tracing.group')tracingGroupSteps.push(step);},- onApiCallEnd: (data: ApiCallData) => {+ onApiCallEnd: data => {// "tracing.group" step will end later, when "tracing.groupEnd" finishes.if (data.apiName === 'tracing.group')return;@@ -756,47 +757,13 @@ class ArtifactsRecorder {}}-function paramsToRender(apiName: string) {- switch (apiName) {- case 'locator.fill':- return ['value'];- default:- return ['url', 'selector', 'text', 'key'];- }-}--function renderApiCall(apiName: string, params: any) {- if (apiName === 'tracing.group')- return params.name;- const paramsArray = [];- if (params) {- for (const name of paramsToRender(apiName)) {- if (!(name in params))- continue;- if (name === 'selector' && isString(params[name])) {- const description = asLocatorDescription(params[name]);- if (description) {- const replacement = JSON.stringify(description);- apiName = apiName.replace(/^locator\.(.*)/, `$1 ${replacement}`);- apiName = apiName.replace(/^page\.(.*)/, `$1 ${replacement}`);- apiName = apiName.replace(/^frame\.(.*)/, `$1 ${replacement}`);- } else if (params[name].startsWith('internal:')) {- const replacement = asLocator('javascript', params[name]) + '.';- apiName = apiName.replace(/^locator\./, replacement);- apiName = apiName.replace(/^page\./, replacement);- apiName = apiName.replace(/^frame\./, replacement);- } else {- const value = params[name];- paramsArray.push(value);- }- } else {- const value = params[name];- paramsArray.push(value);- }- }- }- const paramsText = paramsArray.length ? '(' + paramsArray.join(', ') + ')' : '';- return apiName + paramsText;+function renderTitle(type: string, method: string, params: Record<string, string> | undefined, title?: string) {+ const titleFormat = title ?? methodMetainfo.get(type + '.' + method)?.title ?? method;+ const prefix = titleFormat.replace(/\{([^}]+)\}/g, (_, p1) => formatProtocolParam(params, p1));+ let selector;+ if (params?.['selector'])+ selector = asLocatorDescription('javascript', params.selector);+ return prefix + (selector ? ` ${selector}` : '');}function tracing() {diff --git a/packages/playwright/src/matchers/matchers.ts b/packages/playwright/src/matchers/matchers.tsindex 342b559fa1..5dbd98ee77 100644--- a/packages/playwright/src/matchers/matchers.ts+++ b/packages/playwright/src/matchers/matchers.ts@@ -405,7 +405,7 @@ export function toHaveTitle(return toMatchText.call(this, 'toHaveTitle', locator, 'Locator', async (isNot, timeout) => {const expectedText = serializeExpectedTextValues([expected], { normalizeWhiteSpace: true });return await locator._expect('to.have.title', { expectedText, isNot, timeout });- }, expected, options);+ }, expected, { receiverLabel: 'page', ...options });}export function toHaveURL(diff --git a/packages/playwright/src/matchers/toMatchText.ts b/packages/playwright/src/matchers/toMatchText.tsindex 142013f1b5..6aa1c111f8 100644--- a/packages/playwright/src/matchers/toMatchText.ts+++ b/packages/playwright/src/matchers/toMatchText.ts@@ -36,7 +36,7 @@ export async function toMatchText(receiverType: string,query: (isNot: boolean, timeout: number) => Promise<{ matches: boolean, received?: string, log?: string[], timedOut?: boolean }>,expected: string | RegExp,- options: { timeout?: number, matchSubstring?: boolean } = {},+ options: { timeout?: number, matchSubstring?: boolean, receiverLabel?: string } = {},): Promise<MatcherResult<string | RegExp, string>> {expectTypes(receiver, [receiverType], matcherName);@@ -71,7 +71,7 @@ export async function toMatchText(const stringSubstring = options.matchSubstring ? 'substring' : 'string';const receivedString = received || '';- const messagePrefix = matcherHint(this, receiver, matcherName, 'locator', undefined, matcherOptions, timedOut ? timeout : undefined);+ const messagePrefix = matcherHint(this, receiver, matcherName, options.receiverLabel ?? 'locator', undefined, matcherOptions, timedOut ? timeout : undefined);const notFound = received === kNoElementsFoundError;let printedReceived: string | undefined;diff --git a/packages/protocol/src/callMetadata.d.ts b/packages/protocol/src/callMetadata.d.tsindex 560d9a354f..076abd2dc6 100644--- a/packages/protocol/src/callMetadata.d.ts+++ b/packages/protocol/src/callMetadata.d.ts@@ -25,7 +25,6 @@ export type CallMetadata = {type: string;method: string;params: any;- apiName?: string;title?: string;// Client is making an internal call that should not show up in// the inspector or trace.diff --git a/packages/protocol/src/channels.d.ts b/packages/protocol/src/channels.d.tsindex 54f2bb873f..f5d2f0dd67 100644--- a/packages/protocol/src/channels.d.ts+++ b/packages/protocol/src/channels.d.ts@@ -147,7 +147,6 @@ export type Metadata = {line?: number,column?: number,},- apiName?: string,title?: string,internal?: boolean,stepId?: string,diff --git a/packages/protocol/src/protocol.yml b/packages/protocol/src/protocol.ymlindex 8704f7dc0e..27d1913b58 100644--- a/packages/protocol/src/protocol.yml+++ b/packages/protocol/src/protocol.yml@@ -31,7 +31,6 @@ Metadata:file: stringline: number?column: number?- apiName: string?title: string?internal: boolean?# Test runner step id.@@ -1308,7 +1307,7 @@ BrowserContext:origin: string?setNetworkInterceptionPatterns:- tite: Route+ internal: trueparameters:patterns:type: array@@ -1320,7 +1319,7 @@ BrowserContext:regexFlags: string?setWebSocketInterceptionPatterns:- title: Route web sockets+ internal: trueparameters:patterns:type: array@@ -1714,7 +1713,7 @@ Page:items: NameValuesetNetworkInterceptionPatterns:- title: Route+ internal: trueparameters:patterns:type: array@@ -1726,7 +1725,7 @@ Page:regexFlags: string?setWebSocketInterceptionPatterns:- title: Route web sockets+ internal: trueparameters:patterns:type: array@@ -3554,6 +3553,7 @@ Tracing:traceName: stringtracingGroup:+ title: Trace "{name}"parameters:name: stringlocation:diff --git a/packages/trace-viewer/src/ui/actionList.tsx b/packages/trace-viewer/src/ui/actionList.tsxindex ee3b819c16..5a08951a47 100644--- a/packages/trace-viewer/src/ui/actionList.tsx+++ b/packages/trace-viewer/src/ui/actionList.tsx@@ -19,7 +19,7 @@ import { clsx, msToString } from '@web/uiUtils';import * as React from 'react';import './actionList.css';import * as modelUtil from './modelUtil';-import { asLocator, asLocatorDescription, type Language } from '@isomorphic/locatorGenerators';+import { asLocatorDescription, type Language } from '@isomorphic/locatorGenerators';import type { TreeState } from '@web/components/treeView';import { TreeView } from '@web/components/treeView';import type { ActionTraceEventInContext, ActionTreeItem } from './modelUtil';@@ -118,7 +118,7 @@ export const renderAction = (const { errors, warnings } = modelUtil.stats(action);const showAttachments = !!action.attachments?.length && !!revealAttachment;- const locator = action.params.selector ? asLocatorDescription(action.params.selector) ?? asLocator(sdkLanguage || 'javascript', action.params.selector) : undefined;+ const locator = action.params.selector ? asLocatorDescription(sdkLanguage || 'javascript', action.params.selector) : undefined;const isSkipped = action.class === 'Test' && action.method === 'step' && action.annotations?.some(a => a.type === 'skip');let time: string = '';diff --git a/tests/library/trace-viewer.spec.ts b/tests/library/trace-viewer.spec.tsindex e80caa040e..d1abdb0332 100644--- a/tests/library/trace-viewer.spec.ts+++ b/tests/library/trace-viewer.spec.ts@@ -1527,7 +1527,6 @@ test('should not record route actions', {});await expect(traceViewer.actionTitles).toHaveText([- /Route/,/Navigate to "\/empty.html"/,]);});diff --git a/tests/library/tracing.spec.ts b/tests/library/tracing.spec.tsindex 9cfb2c5fff..2749876a4d 100644--- a/tests/library/tracing.spec.ts+++ b/tests/library/tracing.spec.ts@@ -84,7 +84,6 @@ test('should use the correct title for event driven callbacks', async ({ contextconst { events, actions } = await parseTraceRaw(testInfo.outputPath('trace.zip'));expect(events[0].type).toBe('context-options');expect(actions).toEqual([- 'Route','Navigate to "/empty.html"','Navigate to "/grid.html"','Evaluate',diff --git a/tests/page/expect-boolean.spec.ts b/tests/page/expect-boolean.spec.tsindex d5b4c4d3b5..e254db7a95 100644--- a/tests/page/expect-boolean.spec.ts+++ b/tests/page/expect-boolean.spec.ts@@ -14,6 +14,7 @@* limitations under the License.*/+import { stripAnsi } from '../config/utils';import { test, expect } from './pageTest';test.describe('toBeChecked', () => {@@ -54,7 +55,8 @@ test.describe('toBeChecked', () => {await page.setContent('<input type=checkbox></input>');const locator = page.locator('input');const error = await expect(locator).toBeChecked({ timeout: 1000 }).catch(e => e);- expect(error.message).toContain(`expect.toBeChecked with timeout 1000ms`);+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toBeChecked()`);+ expect(stripAnsi(error.message)).toContain(`- Expect toBeChecked with timeout 1000ms`);});test('with not', async ({ page }) => {@@ -73,30 +75,35 @@ test.describe('toBeChecked', () => {await page.setContent('<input type=checkbox checked></input>');const locator = page.locator('input');const error = await expect(locator).not.toBeChecked({ timeout: 1000 }).catch(e => e);- expect(error.message).toContain(`expect.not.toBeChecked with timeout 1000ms`);- expect(error.message).toContain(`locator resolved to <input checked type="checkbox"/>`);+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).not.toBeChecked()`);+ expect(stripAnsi(error.message)).toContain(`- Expect not toBeChecked with timeout 1000ms`);+ expect(stripAnsi(error.message)).toContain(`locator resolved to <input checked type="checkbox"/>`);});test('fail with checked:false', async ({ page }) => {await page.setContent('<input type=checkbox checked></input>');const locator = page.locator('input');const error = await expect(locator).toBeChecked({ checked: false, timeout: 1000 }).catch(e => e);- expect(error.message).toContain(`expect.toBeChecked with timeout 1000ms`);+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toBeChecked({ checked: false })`);+ expect(stripAnsi(error.message)).toContain(`- Expect toBeChecked with timeout 1000ms`);+ expect(stripAnsi(error.message)).toContain(`locator resolved to <input checked type="checkbox"/>`);});test('fail with indeterminate: true', async ({ page }) => {await page.setContent('<input type=checkbox></input>');const locator = page.locator('input');const error = await expect(locator).toBeChecked({ indeterminate: true, timeout: 1000 }).catch(e => e);- expect(error.message).toContain(`expect.toBeChecked with timeout 1000ms`);+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toBeChecked({ indeterminate: true })`);+ expect(stripAnsi(error.message)).toContain(`- Expect toBeChecked with timeout 1000ms`);});test('fail missing', async ({ page }) => {await page.setContent('<div>no inputs here</div>');const locator2 = page.locator('input2');const error = await expect(locator2).not.toBeChecked({ timeout: 1000 }).catch(e => e);- expect(error.message).toContain(`expect.not.toBeChecked with timeout 1000ms`);- expect(error.message).toContain('waiting for locator(\'input2\')');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).not.toBeChecked()`);+ expect(stripAnsi(error.message)).toContain(`- Expect not toBeChecked with timeout 1000ms`);+ expect(stripAnsi(error.message)).toContain(`- waiting for locator(\'input2\')`);});test('with role', async ({ page }) => {@@ -432,7 +439,8 @@ test.describe('toBeHidden', () => {await page.setContent('<div></div>');const locator = page.locator('button');const error = await expect(locator).not.toBeHidden({ timeout: 1000 }).catch(e => e);- expect(error.message).toContain(`expect.not.toBeHidden with timeout 1000ms`);+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).not.toBeHidden()`);+ expect(stripAnsi(error.message)).toContain(`- Expect not toBeHidden with timeout 1000ms`);});test('with impossible timeout .not', async ({ page }) => {diff --git a/tests/page/expect-misc.spec.ts b/tests/page/expect-misc.spec.tsindex 290d9f202c..4e03044cfb 100644--- a/tests/page/expect-misc.spec.ts+++ b/tests/page/expect-misc.spec.ts@@ -68,14 +68,16 @@ test.describe('toHaveCount', () => {await page.setContent('<div><span></span></div>');const locator = page.locator('span');const error = await expect(locator).toHaveCount(0, { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.toHaveCount with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toHaveCount(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveCount with timeout 1000ms`);});test('fail zero 2', async ({ page }) => {await page.setContent('<div><span></span></div>');const locator = page.locator('span');const error = await expect(locator).not.toHaveCount(1, { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.not.toHaveCount with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).not.toHaveCount(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect not toHaveCount with timeout 1000ms`);});});@@ -107,7 +109,8 @@ test.describe('toHaveJSProperty', () => {await page.$eval('div', e => (e as any).foo = 'string');const locator = page.locator('div');const error = await expect(locator).toHaveJSProperty('foo', 'error', { timeout: 200 }).catch(e => e);- expect(error.message).toContain(`expect.toHaveJSProperty with timeout 200ms`);+ expect(stripAnsi(error.message)).toContain(`Timed out 200ms waiting for expect(locator).toHaveJSProperty(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveJSProperty with timeout 200ms`);});test('pass number', async ({ page }) => {@@ -122,7 +125,8 @@ test.describe('toHaveJSProperty', () => {await page.$eval('div', e => (e as any).foo = 2021);const locator = page.locator('div');const error = await expect(locator).toHaveJSProperty('foo', 1, { timeout: 200 }).catch(e => e);- expect(error.message).toContain(`expect.toHaveJSProperty with timeout 200ms`);+ expect(stripAnsi(error.message)).toContain(`Timed out 200ms waiting for expect(locator).toHaveJSProperty(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveJSProperty with timeout 200ms`);});test('pass boolean', async ({ page }) => {@@ -137,7 +141,8 @@ test.describe('toHaveJSProperty', () => {await page.$eval('div', e => (e as any).foo = false);const locator = page.locator('div');const error = await expect(locator).toHaveJSProperty('foo', true, { timeout: 200 }).catch(e => e);- expect(error.message).toContain(`expect.toHaveJSProperty with timeout 200ms`);+ expect(stripAnsi(error.message)).toContain(`Timed out 200ms waiting for expect(locator).toHaveJSProperty(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveJSProperty with timeout 200ms`);});test('pass boolean 2', async ({ page }) => {@@ -152,7 +157,8 @@ test.describe('toHaveJSProperty', () => {await page.$eval('div', e => (e as any).foo = false);const locator = page.locator('div');const error = await expect(locator).toHaveJSProperty('foo', true, { timeout: 200 }).catch(e => e);- expect(error.message).toContain(`expect.toHaveJSProperty with timeout 200ms`);+ expect(stripAnsi(error.message)).toContain(`Timed out 200ms waiting for expect(locator).toHaveJSProperty(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveJSProperty with timeout 200ms`);});test('pass undefined', async ({ page }) => {@@ -205,7 +211,8 @@ test.describe('toHaveClass', () => {await page.setContent('<div class="bar baz"></div>');const locator = page.locator('div');const error = await expect(locator).toHaveClass('foo bar baz', { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.toHaveClass with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toHaveClass(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveClass with timeout 1000ms`);});test('pass with array', async ({ page }) => {@@ -218,7 +225,8 @@ test.describe('toHaveClass', () => {await page.setContent('<div class="foo"></div><div class="bar"></div><div class="bar"></div>');const locator = page.locator('div');const error = await expect(locator).toHaveClass(['foo', 'bar', /[a-z]az/], { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.toHaveClass with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toHaveClass(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveClass with timeout 1000ms`);});});@@ -243,7 +251,8 @@ test.describe('toContainClass', () => {await page.setContent('<div class="bar baz"></div>');const locator = page.locator('div');const error = await expect(locator).toContainClass('does-not-exist', { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.toContainClass with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toContainClass(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toContainClass with timeout 1000ms`);});test('pass with array', async ({ page }) => {@@ -259,7 +268,8 @@ test.describe('toContainClass', () => {await page.setContent('<div class="foo"></div><div class="bar"></div><div class="bar"></div>');const locator = page.locator('div');const error = await expect(locator).toContainClass(['foo', 'bar', 'baz'], { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.toContainClass with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toContainClass(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toContainClass with timeout 1000ms`);});});@@ -272,7 +282,8 @@ test.describe('toHaveTitle', () => {test('fail', async ({ page }) => {await page.setContent('<title>Bye</title>');const error = await expect(page).toHaveTitle('Hello', { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.toHaveTitle with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(page).toHaveTitle(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveTitle with timeout 1000ms`);});});@@ -341,11 +352,13 @@ test.describe('toHaveAttribute', () => {const locator = page.locator('#node');{const error = await expect(locator).toHaveAttribute('disabled', '', { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.toHaveAttribute with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toHaveAttribute(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveAttribute with timeout 1000ms`);}{const error = await expect(locator).toHaveAttribute('disabled', /.*/, { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.toHaveAttribute with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toHaveAttribute(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveAttribute with timeout 1000ms`);}await expect(locator).not.toHaveAttribute('disabled', '');await expect(locator).not.toHaveAttribute('disabled', /.*/);@@ -358,11 +371,13 @@ test.describe('toHaveAttribute', () => {await expect(locator).toHaveAttribute('checked', /.*/);{const error = await expect(locator).not.toHaveAttribute('checked', '', { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.not.toHaveAttribute with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).not.toHaveAttribute(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect not toHaveAttribute with timeout 1000ms`);}{const error = await expect(locator).not.toHaveAttribute('checked', /.*/, { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.not.toHaveAttribute with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).not.toHaveAttribute(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect not toHaveAttribute with timeout 1000ms`);}});diff --git a/tests/page/expect-timeout.spec.ts b/tests/page/expect-timeout.spec.tsindex 8ae8477e71..d8a062dd25 100644--- a/tests/page/expect-timeout.spec.ts+++ b/tests/page/expect-timeout.spec.ts@@ -47,7 +47,7 @@ test('should not print timed out error message when page closes', async ({ pageexpect(page.locator('div')).toHaveText('hey', { timeout: 100000 }).catch(e => e),page.close(),]);- expect(stripAnsi(error.message)).toContain('expect.toHaveText with timeout 100000ms');+ expect(stripAnsi(error.message)).toContain(`expect(locator).toHaveText(expected)`);expect(stripAnsi(error.message)).not.toContain('Timed out');});diff --git a/tests/page/expect-to-have-text.spec.ts b/tests/page/expect-to-have-text.spec.tsindex 45ab745579..aec9ecb24d 100644--- a/tests/page/expect-to-have-text.spec.ts+++ b/tests/page/expect-to-have-text.spec.ts@@ -208,7 +208,8 @@ test.describe('toHaveText with array', () => {await page.setContent('<div></div>');const locator = page.locator('p');const error = await expect(locator).not.toHaveText([], { timeout: 1000 }).catch(e => e);- expect(error.message).toContain('expect.not.toHaveText with timeout 1000ms');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).not.toHaveText(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect not toHaveText with timeout 1000ms`);});test('pass eventually empty', async ({ page }) => {@@ -225,9 +226,10 @@ test.describe('toHaveText with array', () => {const locator = page.locator('div');const error = await expect(locator).toHaveText(['Text 1', /Text \d/, 'Extra'], { timeout: 1000 }).catch(e => e);expect(stripAnsi(error.message)).toContain('- "Extra"');- expect(error.message).toContain('expect.toHaveText with timeout 1000ms');- expect(error.message).toContain('waiting for locator(\'div\')');- expect(error.message).toContain('locator resolved to 2 elements');+ expect(stripAnsi(error.message)).toContain(`Timed out 1000ms waiting for expect(locator).toHaveText(expected)`);+ expect(stripAnsi(error.message)).toContain(`- Expect toHaveText with timeout 1000ms`);+ expect(stripAnsi(error.message)).toContain('waiting for locator(\'div\')');+ expect(stripAnsi(error.message)).toContain('locator resolved to 2 elements');});test('fail on repeating array matchers', async ({ page }) => {diff --git a/tests/playwright-test/aria-snapshot-file.spec.ts b/tests/playwright-test/aria-snapshot-file.spec.tsindex a64945dfbe..36b8d8697b 100644--- a/tests/playwright-test/aria-snapshot-file.spec.ts+++ b/tests/playwright-test/aria-snapshot-file.spec.ts@@ -172,7 +172,7 @@ for (const updateSnapshots of ['all', 'changed', 'missing', 'none']) {const data = fs.readFileSync(snapshotOutputPath);expect(data.toString()).toBe('- heading "New content" [level=1]');} else {- expect(result.output).toContain(`expect.toMatchAriaSnapshot`);+ expect(result.output).toContain(`Expect toMatchAriaSnapshot`);}});}diff --git a/tests/playwright-test/playwright.connect.spec.ts b/tests/playwright-test/playwright.connect.spec.tsindex eaac03cfbd..b9d32c5a0f 100644--- a/tests/playwright-test/playwright.connect.spec.ts+++ b/tests/playwright-test/playwright.connect.spec.ts@@ -216,7 +216,7 @@ test('should record trace', async ({ runInlineTest }) => {expect(trace.titles).toEqual(['Before Hooks','fixture: context',- 'browser.newContext',+ 'Create context','fixture: page','Create page','Expect toBe',diff --git a/tests/playwright-test/playwright.reuse.browser.spec.ts b/tests/playwright-test/playwright.reuse.browser.spec.tsindex 4340550f64..ef66ab29cb 100644--- a/tests/playwright-test/playwright.reuse.browser.spec.ts+++ b/tests/playwright-test/playwright.reuse.browser.spec.ts@@ -127,20 +127,20 @@ test('should produce correct test steps', async ({ runInlineTest, runServer }) =expect(result.outputLines).toEqual(['onStepBegin Before Hooks','onStepBegin fixture: browser',- 'onStepBegin browserType.connect',- 'onStepEnd browserType.connect',+ 'onStepBegin connect',+ 'onStepEnd connect','onStepEnd fixture: browser','onStepBegin fixture: context','onStepEnd fixture: context','onStepBegin fixture: page',- 'onStepBegin browserContext.newPage',- 'onStepEnd browserContext.newPage',+ 'onStepBegin Create page',+ 'onStepEnd Create page','onStepEnd fixture: page','onStepEnd Before Hooks',- 'onStepBegin page.goto(about:blank)',- 'onStepEnd page.goto(about:blank)',- 'onStepBegin page.evaluate',- 'onStepEnd page.evaluate',+ 'onStepBegin Navigate to "about:blank"',+ 'onStepEnd Navigate to "about:blank"',+ 'onStepBegin Evaluate',+ 'onStepEnd Evaluate','onStepBegin After Hooks','onStepBegin fixture: page','onStepEnd fixture: page',diff --git a/tests/playwright-test/playwright.reuse.spec.ts b/tests/playwright-test/playwright.reuse.spec.tsindex 08e9ab47c3..cc2c071a07 100644--- a/tests/playwright-test/playwright.reuse.spec.ts+++ b/tests/playwright-test/playwright.reuse.spec.ts@@ -129,7 +129,7 @@ test('should reuse context with trace if mode=when-possible', async ({ runInline'Before Hooks',' beforeAll hook',' fixture: browser',- ' browserType.launch',+ ' Launch browser',' fixture: context',' fixture: page',' Create page',diff --git a/tests/playwright-test/playwright.trace.spec.ts b/tests/playwright-test/playwright.trace.spec.tsindex 6bbb2663ca..159d3cc50e 100644--- a/tests/playwright-test/playwright.trace.spec.ts+++ b/tests/playwright-test/playwright.trace.spec.ts@@ -90,11 +90,11 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {expect(trace1.actionTree).toEqual(['Before Hooks',' fixture: request',- ' apiRequest.newContext',+ ' Create request context',' fixture: browser',- ' browserType.launch',+ ' Launch browser',' fixture: context',- ' browser.newContext',+ ' Create context',' fixture: page',' Create page','Navigate to "about:blank"',@@ -107,7 +107,7 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {const trace2 = await parseTrace(testInfo.outputPath('test-results', 'a-api-pass', 'trace.zip'));expect(trace2.actionTree).toEqual(['Before Hooks',- 'apiRequest.newContext',+ 'Create request context','Fetch "/empty.html"','After Hooks',]);@@ -115,9 +115,9 @@ test('should record api trace', async ({ runInlineTest, server }, testInfo) => {expect(trace3.actionTree).toEqual(['Before Hooks',' fixture: request',- ' apiRequest.newContext',+ ' Create request context',' fixture: context',- ' browser.newContext',+ ' Create context',' fixture: page',' Create page','Navigate to "about:blank"',@@ -317,9 +317,9 @@ test('should not override trace file in afterAll', async ({ runInlineTest, serveexpect(trace1.actionTree).toEqual(['Before Hooks',' fixture: browser',- ' browserType.launch',+ ' Launch browser',' fixture: context',- ' browser.newContext',+ ' Create context',' fixture: page',' Create page','Navigate to "about:blank"',@@ -328,7 +328,7 @@ test('should not override trace file in afterAll', async ({ runInlineTest, serve' fixture: context',' afterAll hook',' fixture: request',- ' apiRequest.newContext',+ ' Create request context',' Fetch "/empty.html"',' fixture: request','Worker Cleanup',@@ -619,9 +619,9 @@ test('should expand expect.toPass', async ({ runInlineTest }, testInfo) => {expect(trace.actionTree).toEqual(['Before Hooks',' fixture: browser',- ' browserType.launch',+ ' Launch browser',' fixture: context',- ' browser.newContext',+ ' Create context',' fixture: page',' Create page','Expect toPass',@@ -658,9 +658,9 @@ test('should show non-expect error in trace', async ({ runInlineTest }, testInfoexpect(trace.actionTree).toEqual(['Before Hooks',' fixture: browser',- ' browserType.launch',+ ' Launch browser',' fixture: context',- ' browser.newContext',+ ' Create context',' fixture: page',' Create page','Expect toBe',@@ -786,9 +786,9 @@ test('should use custom expect message in trace', async ({ runInlineTest }, testexpect(trace.actionTree).toEqual(['Before Hooks',' fixture: browser',- ' browserType.launch',+ ' Launch browser',' fixture: context',- ' browser.newContext',+ ' Create context',' fixture: page',' Create page','expect to have text: find a hotel',@@ -937,10 +937,10 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },'Before Hooks',' beforeAll hook',' fixture: browser',- ' browserType.launch',+ ' Launch browser',' fixture: barPage',' barPage setup',- ' browser.newPage',+ ' Create page',' step in barPage setup',' Set content',' beforeAll start',@@ -950,10 +950,10 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },' fixture: barPage',' barPage teardown',' step in barPage teardown',- ' page.close',+ ' Close context',' beforeEach hook',' fixture: context',- ' browser.newContext',+ ' Create context',' fixture: page',' Create page',' fixture: fooPage',@@ -981,7 +981,7 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },' afterAll hook',' fixture: barPage',' barPage setup',- ' browser.newPage',+ ' Create page',' step in barPage setup',' Set content',' afterAll start',@@ -991,7 +991,7 @@ test('should record nested steps, even after timeout', async ({ runInlineTest },' fixture: barPage',' barPage teardown',' step in barPage teardown',- ' page.close',+ ' Close context','Worker Cleanup',' fixture: browser',]);@@ -1024,9 +1024,9 @@ test('should not produce an action entry for calling a binding', async ({ runInlexpect(trace.actionTree).toEqual(['Before Hooks',' fixture: browser',- ' browserType.launch',+ ' Launch browser',' fixture: context',- ' browser.newContext',+ ' Create context',' fixture: page',' Create page','Expose binding',@@ -1214,8 +1214,8 @@ test('should record trace for manually created context in a failed test', asyncexpect(trace.actionTree).toEqual(['Before Hooks',' fixture: browser',- ' browserType.launch',- 'browser.newPage',+ ' Launch browser',+ 'Create page','Set content','Expect toBe','After Hooks',@@ -1257,16 +1257,14 @@ test('should not nest top level expect into unfinished api calls ', {expect(trace.actionTree).toEqual(['Before Hooks',' fixture: browser',- ' browserType.launch',+ ' Launch browser',' fixture: context',- ' browser.newContext',+ ' Create context',' fixture: page',' Create page',- 'Route','Navigate to "/index"','Fetch "/hang"','Expect toBeVisible',- 'Unroute all','After Hooks',' fixture: page',' fixture: context',@@ -1299,9 +1297,9 @@ test('should record trace after fixture teardown timeout', {expect(trace.actionTree).toEqual(['Before Hooks',' fixture: browser',- ' browserType.launch',+ ' Launch browser',' fixture: context',- ' browser.newContext',+ ' Create context',' fixture: page',' Create page',' fixture: fixture',@@ -1336,8 +1334,8 @@ test('should record trace snapshot for more obscure commands', async ({ runInlinexpect(trace.actionTree).toEqual(['Before Hooks',' fixture: browser',- ' browserType.launch',- 'browser.newPage',+ ' Launch browser',+ 'Create page','Set content','Query count','Expect toBe',diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.tsindex e67867cb96..3bf35b26d8 100644--- a/tests/playwright-test/reporter-html.spec.ts+++ b/tests/playwright-test/reporter-html.spec.ts@@ -2972,7 +2972,7 @@ for (const useIntermediateMergeReport of [true, false] as const) {await showReport();await page.getByRole('link', { name: 'sample' }).click();await expect(page.locator('body')).toMatchAriaSnapshot(`- - treeitem "click \\\"Click me\\\""+ - treeitem "Click Click me"`);});});diff --git a/tests/playwright-test/test-step.spec.ts b/tests/playwright-test/test-step.spec.tsindex 9710da56ac..467364f905 100644--- a/tests/playwright-test/test-step.spec.ts+++ b/tests/playwright-test/test-step.spec.ts@@ -139,11 +139,11 @@ test('should report api step hierarchy', async ({ runInlineTest }) => {expect(result.output).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage+pw:api | Create pagetest.step |outer step 1 @ a.test.ts:4test.step | inner step 1.1 @ a.test.ts:5test.step | inner step 1.2 @ a.test.ts:6@@ -208,11 +208,11 @@ test('should not report nested after hooks', async ({ runInlineTest }) => {expect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage+pw:api | Create pagetest.step |my step @ a.test.ts:4hook |After Hooksfixture | fixture: page@@ -549,15 +549,15 @@ test.step | in beforeAll @ a.test.ts:4hook | beforeEach hook @ a.test.ts:11test.step | in beforeEach @ a.test.ts:12fixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage+pw:api | Create pagetest.step |grand @ a.test.ts:20test.step | parent1 @ a.test.ts:22test.step | child1 @ a.test.ts:23-pw:api | page.click(body) @ a.test.ts:24+pw:api | Click locator('body') @ a.test.ts:24test.step | parent2 @ a.test.ts:27test.step | child2 @ a.test.ts:28expect | Expect toBeVisible @ a.test.ts:29@@ -604,14 +604,14 @@ test('should not mark page.close as failed when page.click fails', async ({ runIhook |Before Hookshook | beforeAll hook @ a.test.ts:5fixture | fixture: browser-pw:api | browserType.launch-pw:api | browser.newPage @ a.test.ts:6-pw:api |page.setContent @ a.test.ts:15-pw:api |page.click(div) @ a.test.ts:16+pw:api | Launch browser+pw:api | Create page @ a.test.ts:6+pw:api |Set content @ a.test.ts:15+pw:api |Click locator('div') @ a.test.ts:16pw:api |↪ error: Error: page.click: Target page, context or browser has been closedhook |After Hookshook | afterAll hook @ a.test.ts:9-pw:api | page.close @ a.test.ts:10+pw:api | Close context @ a.test.ts:10hook |Worker Cleanupfixture | fixture: browser|Test timeout of 2000ms exceeded.@@ -883,12 +883,12 @@ test('should not generate dupes for named expects', async ({ runInlineTest }) =>expect(result.output).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage-pw:api |page.setContent @ a.test.ts:4+pw:api | Create page+pw:api |Set content @ a.test.ts:4expect |Checking color @ a.test.ts:6hook |After Hooksfixture | fixture: page@@ -972,18 +972,18 @@ test('library API call inside Expect toPass', async ({ runInlineTest }) => {expect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage+pw:api | Create pagestep |Expect toPass @ a.test.ts:11-pw:api | page.goto(about:blank) @ a.test.ts:6+pw:api | Navigate to "about:blank" @ a.test.ts:6test.step | inner step attempt: 0 @ a.test.ts:7test.step | ↪ error: Error: expect(received).toBe(expected) // Object.is equalityexpect | Expect toBe @ a.test.ts:9expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-pw:api | page.goto(about:blank) @ a.test.ts:6+pw:api | Navigate to "about:blank" @ a.test.ts:6test.step | inner step attempt: 1 @ a.test.ts:7expect | Expect toBe @ a.test.ts:9hook |After Hooks@@ -1023,18 +1023,18 @@ test('library API call inside expect.poll', async ({ runInlineTest }) => {expect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage+pw:api | Create pagestep |Expect poll toHaveLength @ a.test.ts:14-pw:api | page.goto(about:blank) @ a.test.ts:7+pw:api | Navigate to "about:blank" @ a.test.ts:7test.step | inner step attempt: 0 @ a.test.ts:8expect | Expect toBe @ a.test.ts:10expect | Expect toHaveLength @ a.test.ts:6expect | ↪ error: Error: expect(received).toHaveLength(expected)-pw:api | page.goto(about:blank) @ a.test.ts:7+pw:api | Navigate to "about:blank" @ a.test.ts:7test.step | inner step attempt: 1 @ a.test.ts:8expect | Expect toBe @ a.test.ts:10expect | Expect toHaveLength @ a.test.ts:6@@ -1074,12 +1074,12 @@ test('web assertion inside expect.poll', async ({ runInlineTest }) => {expect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage-pw:api |page.setContent @ a.test.ts:4+pw:api | Create page+pw:api |Set content @ a.test.ts:4step |Expect poll toBe @ a.test.ts:13expect | Expect toHaveText @ a.test.ts:7test.step | iteration 1 @ a.test.ts:9@@ -1133,11 +1133,11 @@ expect |Expect not toBeTruthy @ a.test.ts:8hook |After Hookshook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage+pw:api | Create pageexpect |Expect not toHaveTitle @ a.test.ts:11hook |After Hooksfixture | fixture: page@@ -1193,34 +1193,34 @@ test('should report api steps', async ({ runInlineTest, server }) => {expect(stripAnsi(result.output)).toBe(`hook |Before Hookshook | beforeAll hook @ a.test.ts:16-pw:api | browser.newPage @ a.test.ts:17-pw:api | page.setContent @ a.test.ts:18-pw:api |page.click(button) @ a.test.ts:22+pw:api | Create page @ a.test.ts:17+pw:api | Set content @ a.test.ts:18+pw:api |Click locator('button') @ a.test.ts:22hook |After Hookshook |Before Hooks-pw:api |page.click(button) @ a.test.ts:25+pw:api |Click locator('button') @ a.test.ts:25hook |After Hookshook |Before Hooks-pw:api |locator.fill(foo) @ a.test.ts:28+pw:api |Fill "foo" getByRole('textbox') @ a.test.ts:28hook |After Hookshook | afterAll hook @ a.test.ts:31-pw:api | page.close @ a.test.ts:32+pw:api | Close context @ a.test.ts:32hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage+pw:api | Create pagefixture | fixture: request-pw:api | apiRequest.newContext-pw:api |page.waitForNavigation @ a.test.ts:5-pw:api |page.goto(data:text/html,<button></button>) @ a.test.ts:6-pw:api |page.click(button) @ a.test.ts:8-pw:api |getByRole('button').click @ a.test.ts:9-pw:api |apiRequestContext.get(${server.EMPTY_PAGE}) @ a.test.ts:10+pw:api | Create request context+pw:api |Wait for navigation @ a.test.ts:5+pw:api |Navigate to "data:" @ a.test.ts:6+pw:api |Click locator('button') @ a.test.ts:8+pw:api |Click getByRole('button') @ a.test.ts:9+pw:api |Fetch "/empty.html" @ a.test.ts:10pw:api |↪ error: <error message>-pw:api |apiRequestContext.get(${server.EMPTY_PAGE}) @ a.test.ts:11+pw:api |Fetch "/empty.html" @ a.test.ts:11pw:api |↪ error: <error message>hook |After Hooksfixture | fixture: request@@ -1250,13 +1250,13 @@ test('should report api step failure', async ({ runInlineTest }) => {expect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage-pw:api |page.setContent @ a.test.ts:4-pw:api |page.click(input) @ a.test.ts:5+pw:api | Create page+pw:api |Set content @ a.test.ts:4+pw:api |Click locator('input') @ a.test.ts:5pw:api |↪ error: TimeoutError: page.click: Timeout 1ms exceeded.hook |After Hooksfixture | fixture: page@@ -1287,13 +1287,13 @@ test('should show nice stacks for locators', async ({ runInlineTest }) => {expect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage-pw:api |page.setContent @ a.test.ts:4-pw:api |locator.evaluate(button) @ a.test.ts:6+pw:api | Create page+pw:api |Set content @ a.test.ts:4+pw:api |Evaluate locator('button') @ a.test.ts:6hook |After Hooksfixture | fixture: pagefixture | fixture: context@@ -1373,16 +1373,16 @@ test('should show tracing.group nested inside test.step', async ({ runInlineTestexpect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage+pw:api | Create pagetest.step |my step 1 @ a.test.ts:4test.step | my step 2 @ a.test.ts:5-pw:api | my group 1 @ a.test.ts:6-pw:api | my group 2 @ a.test.ts:7-pw:api | page.setContent @ a.test.ts:8+pw:api | Trace "my group 1" @ a.test.ts:6+pw:api | Trace "my group 2" @ a.test.ts:7+pw:api | Set content @ a.test.ts:8hook |After Hooksfixture | fixture: pagefixture | fixture: context@@ -1423,18 +1423,18 @@ test('calls from waitForEvent callback should be under its parent step', {expect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage-pw:api |page.goto(${server.EMPTY_PAGE}) @ a.test.ts:4-pw:api |page.setContent @ a.test.ts:5+pw:api | Create page+pw:api |Navigate to "/empty.html" @ a.test.ts:4+pw:api |Set content @ a.test.ts:5test.step |custom step @ a.test.ts:6-pw:api | page.waitForResponse @ a.test.ts:7-pw:api | page.click(div) @ a.test.ts:14-pw:api | page.content @ a.test.ts:8-pw:api | page.content @ a.test.ts:9+pw:api | Wait for event "response" @ a.test.ts:7+pw:api | Click locator('div') @ a.test.ts:14+pw:api | Get content @ a.test.ts:8+pw:api | Get content @ a.test.ts:9expect | Expect toContainText @ a.test.ts:10expect |Expect toBe @ a.test.ts:18hook |After Hooks@@ -1467,12 +1467,12 @@ test('reading network request / response should not be listed as step', {expect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage-pw:api |page.goto(${server.EMPTY_PAGE}) @ a.test.ts:10+pw:api | Create page+pw:api |Navigate to "/empty.html" @ a.test.ts:10hook |After Hooksfixture | fixture: pagefixture | fixture: context@@ -1508,15 +1508,14 @@ test('calls from page.route callback should be under its parent step', {expect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage+pw:api | Create pagetest.step |custom step @ a.test.ts:4-pw:api | page.route @ a.test.ts:5-pw:api | page.goto(${server.EMPTY_PAGE}) @ a.test.ts:12-pw:api | route.fetch(${server.EMPTY_PAGE}) @ a.test.ts:6+pw:api | Navigate to "/empty.html" @ a.test.ts:12+pw:api | Fetch "/empty.html" @ a.test.ts:6expect | Expect toBe @ a.test.ts:8hook |After Hooksfixture | fixture: page@@ -1687,30 +1686,30 @@ test('show api calls inside expects', async ({ runInlineTest }) => {expect(stripAnsi(result.output)).toBe(`hook |Before Hooksfixture | fixture: browser-pw:api | browserType.launch+pw:api | Launch browserfixture | fixture: context-pw:api | browser.newContext+pw:api | Create contextfixture | fixture: page-pw:api | browserContext.newPage-pw:api |page.setContent @ a.test.ts:16+pw:api | Create page+pw:api |Set content @ a.test.ts:16expect |Expect toBeInvisible @ a.test.ts:17step | Expect poll toBe @ a.test.ts:7-pw:api | locator.isVisible(div) @ a.test.ts:7+pw:api | Is visible locator('div') @ a.test.ts:7expect | Expect toBe @ a.test.ts:7expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-pw:api | locator.isVisible(div) @ a.test.ts:7+pw:api | Is visible locator('div') @ a.test.ts:7expect | Expect toBe @ a.test.ts:7expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-pw:api | locator.isVisible(div) @ a.test.ts:7+pw:api | Is visible locator('div') @ a.test.ts:7expect | Expect toBe @ a.test.ts:7expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-pw:api | locator.isVisible(div) @ a.test.ts:7+pw:api | Is visible locator('div') @ a.test.ts:7expect | Expect toBe @ a.test.ts:7expect | ↪ error: Error: expect(received).toBe(expected) // Object.is equality-pw:api | locator.isVisible(div) @ a.test.ts:7+pw:api | Is visible locator('div') @ a.test.ts:7expect | Expect toBe @ a.test.ts:7-pw:api |page.waitForTimeout @ a.test.ts:18-pw:api |page.setContent @ a.test.ts:19+pw:api |Wait for timeout @ a.test.ts:18+pw:api |Set content @ a.test.ts:19hook |After Hooksfixture | fixture: pagefixture | fixture: contextdiff --git a/tests/playwright-test/to-have-screenshot.spec.ts b/tests/playwright-test/to-have-screenshot.spec.tsindex ce5b089b60..b91e350307 100644--- a/tests/playwright-test/to-have-screenshot.spec.ts+++ b/tests/playwright-test/to-have-screenshot.spec.ts@@ -50,7 +50,7 @@ test('should fail to screenshot a page with infinite animation', async ({ runInl});expect(result.exitCode).toBe(1);expect(result.output).toContain(`Timeout 2000ms exceeded`);- expect(result.output).toContain(`expect.toHaveScreenshot with timeout 2000ms`);+ expect(result.output).toContain(`Expect toHaveScreenshot with timeout 2000ms`);expect(result.output).toContain(`generating new stable screenshot expectation`);expect(fs.existsSync(testInfo.outputPath('test-results', 'a-is-a-test', 'is-a-test-1-actual.png'))).toBe(true);expect(fs.existsSync(testInfo.outputPath('test-results', 'a-is-a-test', 'is-a-test-1-expected.png'))).toBe(false);@@ -256,11 +256,11 @@ test('should report toHaveScreenshot step with expectation name in title', asyncexpect(result.exitCode).toBe(0);expect(result.outputLines).toEqual([- `end browserType.launch`,+ `end Launch browser`,`end fixture: browser`,- `end browser.newContext`,+ `end Create context`,`end fixture: context`,- `end browserContext.newPage`,+ `end Create page`,`end fixture: page`,`end Before Hooks`,`end Expect toHaveScreenshot(foo.png)`,@@ -389,7 +389,7 @@ test('should fail to screenshot an element with infinite animation', async ({ ru});expect(result.exitCode).toBe(1);expect(result.output).toContain(`Timeout 2000ms exceeded`);- expect(result.output).toContain(`expect.toHaveScreenshot with timeout 2000ms`);+ expect(result.output).toContain(`Expect toHaveScreenshot with timeout 2000ms`);expect(fs.existsSync(testInfo.outputPath('test-results', 'a-is-a-test', 'is-a-test-1-previous.png'))).toBe(true);expect(fs.existsSync(testInfo.outputPath('test-results', 'a-is-a-test', 'is-a-test-1-actual.png'))).toBe(true);expect(fs.existsSync(testInfo.outputPath('test-results', 'a-is-a-test', 'is-a-test-1-expected.png'))).toBe(false);diff --git a/tests/playwright-test/ui-mode-test-progress.spec.ts b/tests/playwright-test/ui-mode-test-progress.spec.tsindex c8dcc4eb97..6fcf6eccd1 100644--- a/tests/playwright-test/ui-mode-test-progress.spec.ts+++ b/tests/playwright-test/ui-mode-test-progress.spec.ts@@ -326,7 +326,7 @@ test('should show live trace from hooks', async ({ runUITest, createLatch }) =>/Before Hooks/,/beforeAll hook/,/fixture: browser/,- /browser.newPage/,+ /Create page/,]);latch1.open();await expect(@@ -336,7 +336,7 @@ test('should show live trace from hooks', async ({ runUITest, createLatch }) =>/Before Hooks/,/beforeAll hook/,/beforeEach hook/,- /browser.newPage/,+ /Create page/,]);latch2.open();await expect(diff --git a/tests/playwright-test/ui-mode-trace.spec.ts b/tests/playwright-test/ui-mode-trace.spec.tsindex 0f99bd521b..a26dc44dfd 100644--- a/tests/playwright-test/ui-mode-trace.spec.ts+++ b/tests/playwright-test/ui-mode-trace.spec.ts@@ -274,7 +274,7 @@ test('should not fail on internal page logs', async ({ runUITest, server }) => {'action list').toHaveText([/Before Hooks[\d.]+m?s/,- /browser.newContext/,+ /Create context/,/Create page/,/Navigate to "\/empty.html"/,/Get storage state/,