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: move expect log statements out of frame/page into dispatchers (#40727)
Dmitry Gozmanbd35ed9b7df3
diff --git a/packages/injected/src/injectedScript.ts b/packages/injected/src/injectedScript.tsindex 3d15105369..bea9f9e0c5 100644--- a/packages/injected/src/injectedScript.ts+++ b/packages/injected/src/injectedScript.ts@@ -47,7 +47,6 @@ import type { Builtins } from './utilityScript';export type FrameExpectParams = Omit<channels.FrameExpectParams, 'expectedValue' | 'timeout'> & {expectedValue?: any;- timeoutForLogs?: number;noAutoWaiting?: boolean;};diff --git a/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts b/packages/playwright-core/src/server/dispatchers/frameDispatcher.tsindex 33b88d7633..82c5fb61f6 100644--- a/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts+++ b/packages/playwright-core/src/server/dispatchers/frameDispatcher.ts@@ -16,6 +16,7 @@import yaml from 'yaml';import { parseAriaSnapshotUnsafe } from '@isomorphic/ariaSnapshot';+import { renderTitleForCall } from '@isomorphic/protocolFormatter';import { Frame } from '../frames';import { Dispatcher } from './dispatcher';import { ElementHandleDispatcher } from './elementHandlerDispatcher';@@ -277,7 +278,8 @@ export class FrameDispatcher extends Dispatcher<Frame, channels.FrameChannel, Brlet expectedValue = params.expectedValue ? parseArgument(params.expectedValue) : undefined;if (params.expression === 'to.match.aria' && expectedValue)expectedValue = parseAriaSnapshotUnsafe(yaml, expectedValue);- const result = await this._frame.expect(progress, params.selector, { ...params, expectedValue, timeoutForLogs: params.timeout });+ progress.log(`${renderTitleForCall(progress.metadata)}${params.timeout ? ` with timeout ${params.timeout}ms` : ''}`);+ const result = await this._frame.expect(progress, params.selector, { ...params, expectedValue });const channelResult: channels.FrameExpectResult = {matches: result.matches,log: result.log,diff --git a/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts b/packages/playwright-core/src/server/dispatchers/pageDispatcher.tsindex d393fac2d1..81b4d804e4 100644--- a/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts+++ b/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts@@ -14,6 +14,7 @@* limitations under the License.*/+import { renderTitleForCall } from '@isomorphic/protocolFormatter';import { deserializeURLMatch, urlMatches } from '@isomorphic/urlMatch';import { Page, Worker } from '../page';import { Dispatcher } from './dispatcher';@@ -232,6 +233,7 @@ export class PageDispatcher extends Dispatcher<Page, channels.PageChannel, Browsframe: (params.locator.frame as FrameDispatcher)._object,selector: params.locator.selector,} : undefined;+ progress.log(`${renderTitleForCall(progress.metadata)}${params.timeout ? ` with timeout ${params.timeout}ms` : ''}`);return await this._page.expectScreenshot(progress, {...params,locator,diff --git a/packages/playwright-core/src/server/frames.ts b/packages/playwright-core/src/server/frames.tsindex c1c556e0fe..c19c6231cd 100644--- a/packages/playwright-core/src/server/frames.ts+++ b/packages/playwright-core/src/server/frames.ts@@ -23,7 +23,6 @@ import { asLocator } from '@isomorphic/locatorGenerators';import { assert } from '@isomorphic/assert';import { constructURLBasedOnBaseURL } from '@isomorphic/urlMatch';import { makeWaitForNextTask } from '@utils/task';-import { renderTitleForCall } from '@isomorphic/protocolFormatter';import { BrowserContext } from './browserContext';import * as dom from './dom';import { TimeoutError } from './errors';@@ -1453,7 +1452,6 @@ export class Frame extends SdkObject<FrameEventMap> {}async expect(progress: Progress, selector: string | undefined, options: FrameExpectParams): Promise<ExpectResult> {- progress.log(`${renderTitleForCall(progress.metadata)}${options.timeoutForLogs ? ` with timeout ${options.timeoutForLogs}ms` : ''}`);const lastIntermediateResult: { received?: ExpectReceived, isSet: boolean, errorMessage?: string } = { isSet: false };const fixupMetadataError = (result: ExpectResult) => {// Library mode special case for the expect errors which are return values, not exceptions.diff --git a/packages/playwright-core/src/server/page.ts b/packages/playwright-core/src/server/page.tsindex 2c604e778f..32309184c7 100644--- a/packages/playwright-core/src/server/page.ts+++ b/packages/playwright-core/src/server/page.ts@@ -22,7 +22,6 @@ import { getComparator } from '@utils/comparators';import { debugLogger } from '@utils/debugLogger';import { LongStandingScope } from '@isomorphic/manualPromise';import { assert } from '@isomorphic/assert';-import { renderTitleForCall } from '@isomorphic/protocolFormatter';import { trimStringWithEllipsis } from '@isomorphic/stringUtils';import { asLocator } from '@isomorphic/locatorGenerators';import { BrowserContext } from './browserContext';@@ -739,7 +738,6 @@ export class Page extends SdkObject<PageEventMap> {let actual: Buffer | undefined;let previous: Buffer | undefined;const pollIntervals = [0, 100, 250, 500];- progress.log(`${renderTitleForCall(progress.metadata)}${options.timeout ? ` with timeout ${options.timeout}ms` : ''}`);if (options.expected)progress.log(` verifying given screenshot expectation`);else