Skip to content

Commit b6313db

Browse files
authored
chore: roll to Playwright v1.49.0 (#513)
1 parent 9d886af commit b6313db

12 files changed

+492
-140
lines changed

Diff for: Dockerfile.example

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Stage 1: Modules caching
2-
FROM golang:1.21 as modules
2+
FROM golang:1.22 as modules
33
COPY go.mod go.sum /modules/
44
WORKDIR /modules
55
RUN go mod download
66

77
# Stage 2: Build
8-
FROM golang:1.21 as builder
8+
FROM golang:1.22 as builder
99
COPY --from=modules /go/pkg /go/pkg
1010
COPY . /workdir
1111
WORKDIR /workdir
@@ -16,7 +16,7 @@ RUN PWGO_VER=$(grep -oE "playwright-go v\S+" /workdir/go.mod | sed 's/playwright
1616
RUN GOOS=linux GOARCH=amd64 go build -o /bin/myapp
1717

1818
# Stage 3: Final
19-
FROM ubuntu:jammy
19+
FROM ubuntu:noble
2020
COPY --from=builder /go/bin/playwright /bin/myapp /
2121
RUN apt-get update && apt-get install -y ca-certificates tzdata \
2222
# Install dependencies and all browsers (or specify one)

Diff for: README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@
55
[![PkgGoDev](https://pkg.go.dev/badge/github.com/playwright-community/playwright-go)](https://pkg.go.dev/github.com/playwright-community/playwright-go)
66
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](http://opensource.org/licenses/MIT)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/playwright-community/playwright-go)](https://goreportcard.com/report/github.com/playwright-community/playwright-go) ![Build Status](https://github.com/playwright-community/playwright-go/workflows/Go/badge.svg)
8-
[![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://aka.ms/playwright-slack) [![Coverage Status](https://coveralls.io/repos/github/playwright-community/playwright-go/badge.svg?branch=main)](https://coveralls.io/github/playwright-community/playwright-go?branch=main) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-130.0.6723.31-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-131.0-blue.svg?logo=mozilla-firefox)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[![WebKit version](https://img.shields.io/badge/webkit-18.0-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop -->
8+
[![Join Slack](https://img.shields.io/badge/join-slack-infomational)](https://aka.ms/playwright-slack) [![Coverage Status](https://coveralls.io/repos/github/playwright-community/playwright-go/badge.svg?branch=main)](https://coveralls.io/github/playwright-community/playwright-go?branch=main) <!-- GEN:chromium-version-badge -->[![Chromium version](https://img.shields.io/badge/chromium-131.0.6778.33-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-132.0-blue.svg?logo=mozilla-firefox)](https://www.mozilla.org/en-US/firefox/new/)<!-- GEN:stop --> <!-- GEN:webkit-version-badge -->[![WebKit version](https://img.shields.io/badge/webkit-18.2-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop -->
99

1010
[API reference](https://playwright.dev/docs/api/class-playwright) | [Example recipes](https://github.com/playwright-community/playwright-go/tree/main/examples)
1111

1212
Playwright is a Go library to automate [Chromium](https://www.chromium.org/Home), [Firefox](https://www.mozilla.org/en-US/firefox/new/) and [WebKit](https://webkit.org/) with a single API. Playwright is built to enable cross-browser web automation that is **ever-green**, **capable**, **reliable** and **fast**.
1313

1414
| | Linux | macOS | Windows |
1515
| :--- | :---: | :---: | :---: |
16-
| Chromium <!-- GEN:chromium-version -->130.0.6723.31<!-- GEN:stop --> ||||
17-
| WebKit <!-- GEN:webkit-version -->18.0<!-- GEN:stop --> ||||
18-
| Firefox <!-- GEN:firefox-version -->131.0<!-- GEN:stop --> ||||
16+
| Chromium <!-- GEN:chromium-version -->131.0.6778.33<!-- GEN:stop --> ||||
17+
| WebKit <!-- GEN:webkit-version -->18.2<!-- GEN:stop --> ||||
18+
| Firefox <!-- GEN:firefox-version -->132.0<!-- GEN:stop --> ||||
1919

2020
Headless execution is supported for all the browsers on all platforms.
2121

Diff for: generated-interfaces.go

+55-4
Original file line numberDiff line numberDiff line change
@@ -602,11 +602,16 @@ type Clock interface {
602602
Resume() error
603603

604604
// Makes `Date.now` and `new Date()` return fixed fake time at all times, keeps all the timers running.
605+
// Use this method for simple scenarios where you only need to test with a predefined time. For more advanced
606+
// scenarios, use [Clock.Install] instead. Read docs on [clock emulation] to learn more.
605607
//
606608
// time: Time to be set.
609+
//
610+
// [clock emulation]: https://playwright.dev/docs/clock
607611
SetFixedTime(time interface{}) error
608612

609-
// Sets current system time but does not trigger any timers.
613+
// Sets system time, but does not trigger any timers. Use this to test how the web page reacts to a time shift, for
614+
// example switching from summer to winter time, or changing time zones.
610615
//
611616
// time: Time to be set.
612617
SetSystemTime(time interface{}) error
@@ -2179,6 +2184,37 @@ type Locator interface {
21792184
// locator: Additional locator to match.
21802185
And(locator Locator) Locator
21812186

2187+
// Captures the aria snapshot of the given element. Read more about [aria snapshots] and
2188+
// [LocatorAssertions.ToMatchAriaSnapshot] for the corresponding assertion.
2189+
//
2190+
// # Details
2191+
//
2192+
// This method captures the aria snapshot of the given element. The snapshot is a string that represents the state of
2193+
// the element and its children. The snapshot can be used to assert the state of the element in the test, or to
2194+
// compare it to state in the future.
2195+
// The ARIA snapshot is represented using [YAML] markup language:
2196+
// - The keys of the objects are the roles and optional accessible names of the elements.
2197+
// - The values are either text content or an array of child elements.
2198+
// - Generic static text can be represented with the `text` key.
2199+
// Below is the HTML markup and the respective ARIA snapshot:
2200+
// ```html
2201+
// <ul aria-label="Links">
2202+
// <li><a href="/">Home</a></li>
2203+
// <li><a href="/about">About</a></li>
2204+
// <ul>
2205+
// ```
2206+
// ```yml
2207+
// - list "Links":
2208+
// - listitem:
2209+
// - link "Home"
2210+
// - listitem:
2211+
// - link "About"
2212+
// ```
2213+
//
2214+
// [aria snapshots]: https://playwright.dev/docs/aria-snapshots
2215+
// [YAML]: https://yaml.org/spec/1.2.2/
2216+
AriaSnapshot(options ...LocatorAriaSnapshotOptions) (string, error)
2217+
21822218
// Calls [blur] on the element.
21832219
//
21842220
// [blur]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur
@@ -2949,6 +2985,11 @@ type LocatorAssertions interface {
29492985
//
29502986
// values: Expected options currently selected.
29512987
ToHaveValues(values []interface{}, options ...LocatorAssertionsToHaveValuesOptions) error
2988+
2989+
// Asserts that the target element matches the given [accessibility snapshot].
2990+
//
2991+
// [accessibility snapshot]: https://playwright.dev/docs/aria-snapshots
2992+
ToMatchAriaSnapshot(expected string, options ...LocatorAssertionsToMatchAriaSnapshotOptions) error
29522993
}
29532994

29542995
// The Mouse class operates in main-frame CSS pixels relative to the top-left corner of the viewport.
@@ -4309,9 +4350,9 @@ type Route interface {
43094350
//
43104351
// # Details
43114352
//
4312-
// Note that any overrides such as “[object Object]” or “[object Object]” only apply to the request being routed. If
4313-
// this request results in a redirect, overrides will not be applied to the new redirected request. If you want to
4314-
// propagate a header through redirects, use the combination of [Route.Fetch] and [Route.Fulfill] instead.
4353+
// The “[object Object]” option applies to both the routed request and any redirects it initiates. However,
4354+
// “[object Object]”, “[object Object]”, and “[object Object]” only apply to the original request and are not carried
4355+
// over to redirected requests.
43154356
// [Route.Continue] will immediately send the request to the network, other matching handlers won't be invoked. Use
43164357
// [Route.Fallback] If you want next matching handler in the chain to be invoked.
43174358
Continue(options ...RouteContinueOptions) error
@@ -4380,6 +4421,16 @@ type Tracing interface {
43804421
// once, and then create multiple trace chunks with [Tracing.StartChunk] and [Tracing.StopChunk].
43814422
StartChunk(options ...TracingStartChunkOptions) error
43824423

4424+
// **NOTE** Use `test.step` instead when available.
4425+
// Creates a new group within the trace, assigning any subsequent API calls to this group, until [Tracing.GroupEnd] is
4426+
// called. Groups can be nested and will be visible in the trace viewer.
4427+
//
4428+
// name: Group name shown in the trace viewer.
4429+
Group(name string, options ...TracingGroupOptions) error
4430+
4431+
// Closes the last group created by [Tracing.Group].
4432+
GroupEnd() error
4433+
43834434
// Stop tracing.
43844435
Stop(path ...string) error
43854436

Diff for: generated-structs.go

+43-11
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,11 @@ type BrowserNewContextOptions struct {
363363
// **NOTE** When using WebKit on macOS, accessing `localhost` will not pick up client certificates. You can make it
364364
// work by replacing `localhost` with `local.playwright`.
365365
ClientCertificates []ClientCertificate `json:"clientCertificates"`
366-
// Emulates `prefers-colors-scheme` media feature, supported values are `light`, `dark`, `no-preference`. See
367-
// [Page.EmulateMedia] for more details. Passing `no-override` resets emulation to system defaults. Defaults to
368-
// `light`.
366+
// Emulates [prefers-colors-scheme]
367+
// media feature, supported values are `light` and `dark`. See [Page.EmulateMedia] for more details. Passing
368+
// `no-override` resets emulation to system defaults. Defaults to `light`.
369+
//
370+
// [prefers-colors-scheme]: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
369371
ColorScheme *ColorScheme `json:"colorScheme"`
370372
// Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn more about
371373
// [emulating devices with device scale factor].
@@ -508,9 +510,11 @@ type BrowserNewPageOptions struct {
508510
// **NOTE** When using WebKit on macOS, accessing `localhost` will not pick up client certificates. You can make it
509511
// work by replacing `localhost` with `local.playwright`.
510512
ClientCertificates []ClientCertificate `json:"clientCertificates"`
511-
// Emulates `prefers-colors-scheme` media feature, supported values are `light`, `dark`, `no-preference`. See
512-
// [Page.EmulateMedia] for more details. Passing `no-override` resets emulation to system defaults. Defaults to
513-
// `light`.
513+
// Emulates [prefers-colors-scheme]
514+
// media feature, supported values are `light` and `dark`. See [Page.EmulateMedia] for more details. Passing
515+
// `no-override` resets emulation to system defaults. Defaults to `light`.
516+
//
517+
// [prefers-colors-scheme]: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
514518
ColorScheme *ColorScheme `json:"colorScheme"`
515519
// Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn more about
516520
// [emulating devices with device scale factor].
@@ -910,9 +914,11 @@ type BrowserTypeLaunchPersistentContextOptions struct {
910914
// **NOTE** When using WebKit on macOS, accessing `localhost` will not pick up client certificates. You can make it
911915
// work by replacing `localhost` with `local.playwright`.
912916
ClientCertificates []ClientCertificate `json:"clientCertificates"`
913-
// Emulates `prefers-colors-scheme` media feature, supported values are `light`, `dark`, `no-preference`. See
914-
// [Page.EmulateMedia] for more details. Passing `no-override` resets emulation to system defaults. Defaults to
915-
// `light`.
917+
// Emulates [prefers-colors-scheme]
918+
// media feature, supported values are `light` and `dark`. See [Page.EmulateMedia] for more details. Passing
919+
// `no-override` resets emulation to system defaults. Defaults to `light`.
920+
//
921+
// [prefers-colors-scheme]: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
916922
ColorScheme *ColorScheme `json:"colorScheme"`
917923
// Specify device scale factor (can be thought of as dpr). Defaults to `1`. Learn more about
918924
// [emulating devices with device scale factor].
@@ -2236,6 +2242,12 @@ type KeyboardTypeOptions struct {
22362242
Delay *float64 `json:"delay"`
22372243
}
22382244

2245+
type LocatorAriaSnapshotOptions struct {
2246+
// Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can
2247+
// be changed by using the [BrowserContext.SetDefaultTimeout] or [Page.SetDefaultTimeout] methods.
2248+
Timeout *float64 `json:"timeout"`
2249+
}
2250+
22392251
type LocatorBlurOptions struct {
22402252
// Maximum time in milliseconds. Defaults to `30000` (30 seconds). Pass `0` to disable timeout. The default value can
22412253
// be changed by using the [BrowserContext.SetDefaultTimeout] or [Page.SetDefaultTimeout] methods.
@@ -2990,6 +3002,11 @@ type LocatorAssertionsToHaveValuesOptions struct {
29903002
Timeout *float64 `json:"timeout"`
29913003
}
29923004

3005+
type LocatorAssertionsToMatchAriaSnapshotOptions struct {
3006+
// Time to retry the assertion for in milliseconds. Defaults to `5000`.
3007+
Timeout *float64 `json:"timeout"`
3008+
}
3009+
29933010
type MouseClickOptions struct {
29943011
// Defaults to `left`.
29953012
Button *MouseButton `json:"button"`
@@ -3197,8 +3214,11 @@ type PageDragAndDropOptions struct {
31973214
}
31983215

31993216
type PageEmulateMediaOptions struct {
3200-
// Emulates `prefers-colors-scheme` media feature, supported values are `light`, `dark`, `no-preference`.
3201-
// Passing `no-override` disables color scheme emulation.
3217+
// Emulates [prefers-colors-scheme]
3218+
// media feature, supported values are `light` and `dark`. Passing `no-override` disables color scheme
3219+
// emulation. `no-preference` is deprecated.
3220+
//
3221+
// [prefers-colors-scheme]: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
32023222
ColorScheme *ColorScheme `json:"colorScheme"`
32033223
ForcedColors *ForcedColors `json:"forcedColors"`
32043224
// Changes the CSS media type of the page. The only allowed values are `screen`, `print` and `no-override`.
@@ -4173,6 +4193,12 @@ type TracingStartChunkOptions struct {
41734193
Title *string `json:"title"`
41744194
}
41754195

4196+
type TracingGroupOptions struct {
4197+
// Specifies a custom location for the group to be shown in the trace viewer. Defaults to the location of the
4198+
// [Tracing.Group] call.
4199+
Location *TracingGroupOptionsLocation `json:"location"`
4200+
}
4201+
41764202
type WebSocketExpectEventOptions struct {
41774203
// Receives the event data and resolves to truthy value when the waiting should resolve.
41784204
Predicate interface{} `json:"predicate"`
@@ -4279,3 +4305,9 @@ type Margin struct {
42794305
// Left margin, accepts values labeled with units. Defaults to `0`.
42804306
Left *string `json:"left"`
42814307
}
4308+
4309+
type TracingGroupOptionsLocation struct {
4310+
File string `json:"file"`
4311+
Line *int `json:"line"`
4312+
Column *int `json:"column"`
4313+
}

Diff for: locator.go

+13
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,19 @@ func (l *locatorImpl) Blur(options ...LocatorBlurOptions) error {
128128
return err
129129
}
130130

131+
func (l *locatorImpl) AriaSnapshot(options ...LocatorAriaSnapshotOptions) (string, error) {
132+
var option LocatorAriaSnapshotOptions
133+
if len(options) == 1 {
134+
option = options[0]
135+
}
136+
ret, err := l.frame.channel.Send("ariaSnapshot", option,
137+
map[string]interface{}{"selector": l.selector})
138+
if err != nil {
139+
return "", err
140+
}
141+
return ret.(string), nil
142+
}
143+
131144
func (l *locatorImpl) BoundingBox(options ...LocatorBoundingBoxOptions) (*Rect, error) {
132145
if l.err != nil {
133146
return nil, l.err

Diff for: locator_assertions.go

+16
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,22 @@ func (la *locatorAssertionsImpl) ToHaveValues(values []interface{}, options ...L
472472
)
473473
}
474474

475+
func (la *locatorAssertionsImpl) ToMatchAriaSnapshot(expected string, options ...LocatorAssertionsToMatchAriaSnapshotOptions) error {
476+
var timeout *float64
477+
if len(options) == 1 {
478+
timeout = options[0].Timeout
479+
}
480+
return la.expect(
481+
"to.match.aria",
482+
frameExpectOptions{
483+
ExpectedValue: expected,
484+
Timeout: timeout,
485+
},
486+
expected,
487+
"Locator expected to match Aria snapshot",
488+
)
489+
}
490+
475491
func (la *locatorAssertionsImpl) Not() LocatorAssertions {
476492
return newLocatorAssertions(la.actualLocator, true, la.defaultTimeout)
477493
}

0 commit comments

Comments
 (0)