Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions docs/src/api/class-inspector.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,24 @@

Interface to the Playwright inspector.

## async method: Inspector.cancelPickLocator
* since: v1.59

Cancels an ongoing [`method: Inspector.pickLocator`] call by deactivating pick locator mode.
If no pick locator mode is active, this method is a no-op.

## async method: Inspector.pickLocator
* since: v1.59
- returns: <[Locator]>

Enters pick locator mode where hovering over page elements highlights them and shows the corresponding locator.
Once the user clicks an element, the mode is deactivated and the [Locator] for the picked element is returned.

**Usage**

```js
const inspector = page.inspector();
inspector.on('screencastframe', ({ data, width, height }) => {
console.log(`received frame ${width}x${height}, jpeg size: ${data.length}`);
});
await inspector.startScreencast();
// ... perform actions ...
await inspector.stopScreencast();
const locator = await page.inspector().pickLocator();
console.log(locator);
```

## event: Inspector.screencastFrame
Expand Down
24 changes: 0 additions & 24 deletions docs/src/api/class-page.md
Original file line number Diff line number Diff line change
Expand Up @@ -2864,30 +2864,6 @@ the place it was paused.
This method requires Playwright to be started in a headed mode, with a falsy [`option: BrowserType.launch.headless`] option.
:::

## async method: Page.cancelPickLocator
* since: v1.59

Cancels an ongoing [`method: Page.pickLocator`] call by deactivating pick locator mode.
If no pick locator mode is active, this method is a no-op.

## async method: Page.pickLocator
* since: v1.59
- returns: <[Locator]>

Enters pick locator mode where hovering over page elements highlights them and shows the corresponding locator.
Once the user clicks an element, the mode is deactivated and the [Locator] for the picked element is returned.

:::note
This method requires Playwright to be started in a headed mode.
:::

**Usage**

```js
const locator = await page.pickLocator();
console.log(locator);
```

## async method: Page.pdf
* since: v1.8
- returns: <[Buffer]>
Expand Down
58 changes: 22 additions & 36 deletions packages/playwright-client/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2187,12 +2187,6 @@ export interface Page {
*/
bringToFront(): Promise<void>;

/**
* Cancels an ongoing [page.pickLocator()](https://playwright.dev/docs/api/class-page#page-pick-locator) call by
* deactivating pick locator mode. If no pick locator mode is active, this method is a no-op.
*/
cancelPickLocator(): Promise<void>;

/**
* **NOTE** Use locator-based [locator.check([options])](https://playwright.dev/docs/api/class-locator#locator-check) instead.
* Read more about [locators](https://playwright.dev/docs/locators).
Expand Down Expand Up @@ -3928,23 +3922,6 @@ export interface Page {
width?: string|number;
}): Promise<Buffer>;

/**
* Enters pick locator mode where hovering over page elements highlights them and shows the corresponding locator.
* Once the user clicks an element, the mode is deactivated and the
* [Locator](https://playwright.dev/docs/api/class-locator) for the picked element is returned.
*
* **NOTE** This method requires Playwright to be started in a headed mode.
*
* **Usage**
*
* ```js
* const locator = await page.pickLocator();
* console.log(locator);
* ```
*
*/
pickLocator(): Promise<Locator>;

/**
* **NOTE** Use locator-based [locator.press(key[, options])](https://playwright.dev/docs/api/class-locator#locator-press)
* instead. Read more about [locators](https://playwright.dev/docs/locators).
Expand Down Expand Up @@ -20438,19 +20415,6 @@ export interface FrameLocator {

/**
* Interface to the Playwright inspector.
*
* **Usage**
*
* ```js
* const inspector = page.inspector();
* inspector.on('screencastframe', ({ data, width, height }) => {
* console.log(`received frame ${width}x${height}, jpeg size: ${data.length}`);
* });
* await inspector.startScreencast();
* // ... perform actions ...
* await inspector.stopScreencast();
* ```
*
*/
export interface Inspector {
/**
Expand Down Expand Up @@ -20615,6 +20579,28 @@ export interface Inspector {
height: number;
}) => any): this;

/**
* Cancels an ongoing
* [inspector.pickLocator()](https://playwright.dev/docs/api/class-inspector#inspector-pick-locator) call by
* deactivating pick locator mode. If no pick locator mode is active, this method is a no-op.
*/
cancelPickLocator(): Promise<void>;

/**
* Enters pick locator mode where hovering over page elements highlights them and shows the corresponding locator.
* Once the user clicks an element, the mode is deactivated and the
* [Locator](https://playwright.dev/docs/api/class-locator) for the picked element is returned.
*
* **Usage**
*
* ```js
* const locator = await page.inspector().pickLocator();
* console.log(locator);
* ```
*
*/
pickLocator(): Promise<Locator>;

/**
* Starts capturing screencast frames. Frames are emitted as
* [inspector.on('screencastframe')](https://playwright.dev/docs/api/class-inspector#inspector-event-screencast-frame)
Expand Down
8 changes: 4 additions & 4 deletions packages/playwright-core/browsers.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
},
{
"name": "chromium-tip-of-tree",
"revision": "1409",
"revision": "1410",
"installByDefault": false,
"browserVersion": "147.0.7705.0",
"browserVersion": "147.0.7714.0",
"title": "Chrome Canary for Testing"
},
{
"name": "chromium-tip-of-tree-headless-shell",
"revision": "1409",
"revision": "1410",
"installByDefault": false,
"browserVersion": "147.0.7705.0",
"browserVersion": "147.0.7714.0",
"title": "Chrome Canary Headless Shell"
},
{
Expand Down
10 changes: 10 additions & 0 deletions packages/playwright-core/src/client/inspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { EventEmitter } from './eventEmitter';

import type * as api from '../../types/types';
import type { Locator } from './locator';
import type { Page } from './page';

export class Inspector extends EventEmitter implements api.Inspector {
Expand All @@ -28,6 +29,15 @@ export class Inspector extends EventEmitter implements api.Inspector {
this._page._channel.on('screencastFrame', ({ data, width, height }) => this.emit('screencastframe', { data, width, height }));
}

async pickLocator(): Promise<Locator> {
const { selector } = await this._page._channel.pickLocator({});
return this._page.locator(selector);
}

async cancelPickLocator(): Promise<void> {
await this._page._channel.cancelPickLocator({});
}

async startScreencast(options: { size?: { width: number, height: number } } = {}): Promise<void> {
await this._page._channel.startScreencast(options);
}
Expand Down
9 changes: 0 additions & 9 deletions packages/playwright-core/src/client/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -826,15 +826,6 @@ export class Page extends ChannelOwner<channels.PageChannel> implements api.Page
this._browserContext.setDefaultTimeout(defaultTimeout);
}

async pickLocator(): Promise<Locator> {
const { selector } = await this._channel.pickLocator({});
return this.locator(selector);
}

async cancelPickLocator(): Promise<void> {
await this._channel.cancelPickLocator({});
}

async pdf(options: PDFOptions = {}): Promise<Buffer> {
const transportOptions: channels.PagePdfParams = { ...options } as channels.PagePdfParams;
if (transportOptions.margin)
Expand Down
10 changes: 5 additions & 5 deletions packages/playwright-core/src/server/har/harTracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,11 @@ export class HarTracer {
});
this._addBarrier(page || request.serviceWorker(), promise);

this._addBarrier(page || request.serviceWorker(), response.httpVersion().then(httpVersion => {
harEntry.request.httpVersion = httpVersion;
harEntry.response.httpVersion = httpVersion;
}));

// Response end timing is only available after the response event was received.
const timing = response.timing();
harEntry.timings.receive = response.request()._responseEndTiming !== -1 ? helper.millisToRoundishMillis(response.request()._responseEndTiming - timing.responseStart) : -1;
Expand Down Expand Up @@ -462,11 +467,6 @@ export class HarTracer {
_transferSize: this._options.omitSizes ? undefined : -1
};

this._addBarrier(page || request.serviceWorker(), response.httpVersion().then(httpVersion => {
harEntry.request.httpVersion = httpVersion;
harEntry.response.httpVersion = httpVersion;
}));

if (!this._options.omitTiming) {
const startDateTime = pageEntry ? ((pageEntry as any)[startedDateSymbol] as Date).valueOf() : 0;
const timing = response.timing();
Expand Down
1 change: 1 addition & 0 deletions packages/playwright-core/src/server/webkit/wkPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ export class WKPage implements PageDelegate {

private _handleRequestRedirect(request: WKInterceptableRequest, requestId: string, responsePayload: Protocol.Network.Response, timestamp: number) {
const response = request.createResponse(responsePayload);
response._setHttpVersion(null);
response._securityDetailsFinished();
response._serverAddrFinished();
response.setResponseHeadersSize(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export type ContextEntry = {
errors: trace.ErrorTraceEvent[];
hasSource: boolean;
contextId: string;
testTimeout?: number;
};

export type PageEntry = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class TraceModel {
resources: ResourceEntry[];
readonly actionCounters: Map<string, number>;
readonly traceUri: string;
readonly testTimeout?: number;


constructor(traceUri: string, contexts: ContextEntry[]) {
Expand All @@ -104,6 +105,7 @@ export class TraceModel {
this.playwrightVersion = contexts.find(c => c.playwrightVersion)?.playwrightVersion;
this.title = libraryContext?.title || '';
this.options = libraryContext?.options || {};
this.testTimeout = contexts.find(c => c.origin === 'testRunner')?.testTimeout;
// Next call updates all timestamps for all events in library contexts, so it must be done first.
this.actions = mergeActionsAndUpdateTiming(contexts);
this.pages = ([] as PageEntry[]).concat(...contexts.map(c => c.pages));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class TraceModernizer {
contextEntry.options = event.options;
contextEntry.testIdAttributeName = event.testIdAttributeName;
contextEntry.contextId = event.contextId ?? '';
contextEntry.testTimeout = event.testTimeout;
break;
}
case 'screencast-frame': {
Expand Down
58 changes: 22 additions & 36 deletions packages/playwright-core/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2187,12 +2187,6 @@ export interface Page {
*/
bringToFront(): Promise<void>;

/**
* Cancels an ongoing [page.pickLocator()](https://playwright.dev/docs/api/class-page#page-pick-locator) call by
* deactivating pick locator mode. If no pick locator mode is active, this method is a no-op.
*/
cancelPickLocator(): Promise<void>;

/**
* **NOTE** Use locator-based [locator.check([options])](https://playwright.dev/docs/api/class-locator#locator-check) instead.
* Read more about [locators](https://playwright.dev/docs/locators).
Expand Down Expand Up @@ -3928,23 +3922,6 @@ export interface Page {
width?: string|number;
}): Promise<Buffer>;

/**
* Enters pick locator mode where hovering over page elements highlights them and shows the corresponding locator.
* Once the user clicks an element, the mode is deactivated and the
* [Locator](https://playwright.dev/docs/api/class-locator) for the picked element is returned.
*
* **NOTE** This method requires Playwright to be started in a headed mode.
*
* **Usage**
*
* ```js
* const locator = await page.pickLocator();
* console.log(locator);
* ```
*
*/
pickLocator(): Promise<Locator>;

/**
* **NOTE** Use locator-based [locator.press(key[, options])](https://playwright.dev/docs/api/class-locator#locator-press)
* instead. Read more about [locators](https://playwright.dev/docs/locators).
Expand Down Expand Up @@ -20438,19 +20415,6 @@ export interface FrameLocator {

/**
* Interface to the Playwright inspector.
*
* **Usage**
*
* ```js
* const inspector = page.inspector();
* inspector.on('screencastframe', ({ data, width, height }) => {
* console.log(`received frame ${width}x${height}, jpeg size: ${data.length}`);
* });
* await inspector.startScreencast();
* // ... perform actions ...
* await inspector.stopScreencast();
* ```
*
*/
export interface Inspector {
/**
Expand Down Expand Up @@ -20615,6 +20579,28 @@ export interface Inspector {
height: number;
}) => any): this;

/**
* Cancels an ongoing
* [inspector.pickLocator()](https://playwright.dev/docs/api/class-inspector#inspector-pick-locator) call by
* deactivating pick locator mode. If no pick locator mode is active, this method is a no-op.
*/
cancelPickLocator(): Promise<void>;

/**
* Enters pick locator mode where hovering over page elements highlights them and shows the corresponding locator.
* Once the user clicks an element, the mode is deactivated and the
* [Locator](https://playwright.dev/docs/api/class-locator) for the picked element is returned.
*
* **Usage**
*
* ```js
* const locator = await page.inspector().pickLocator();
* console.log(locator);
* ```
*
*/
pickLocator(): Promise<Locator>;

/**
* Starts capturing screencast frames. Frames are emitted as
* [inspector.on('screencastframe')](https://playwright.dev/docs/api/class-inspector#inspector-event-screencast-frame)
Expand Down
2 changes: 2 additions & 0 deletions packages/playwright/src/worker/testTracing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ export class TestTracing {
}

async stopIfNeeded() {
this._contextCreatedEvent.testTimeout = this._testInfo.timeout;

if (!this._options)
return;

Expand Down
1 change: 1 addition & 0 deletions packages/trace-viewer/src/ui/metadataView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const MetadataView: React.FunctionComponent<{
<div className='call-section' style={{ paddingTop: 2 }}>Time</div>
{!!wallTime && <div className='call-line'>start time:<span className='call-value datetime' title={wallTime}>{wallTime}</span></div>}
<div className='call-line'>duration:<span className='call-value number' title={msToString(model.endTime - model.startTime)}>{msToString(model.endTime - model.startTime)}</span></div>
{model.testTimeout !== undefined && <div className='call-line'>test timeout:<span className='call-value number' title={msToString(model.testTimeout)}>{msToString(model.testTimeout)}</span></div>}
<div className='call-section'>Browser</div>
<div className='call-line'>engine:<span className='call-value string' title={model.browserName}>{model.browserName}</span></div>
{model.channel && <div className='call-line'>channel:<span className='call-value string' title={model.channel}>{model.channel}</span></div>}
Expand Down
1 change: 1 addition & 0 deletions packages/trace/src/trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type ContextCreatedTraceEvent = {
sdkLanguage?: Language,
testIdAttributeName?: string,
contextId?: string,
testTimeout?: number,
};

export type ScreencastFrameTraceEvent = {
Expand Down
Loading
Loading