Skip to content

Commit c6ac7e7

Browse files
authored
chore: roll to Playwright v1.51.1 (#536)
1 parent 600e08b commit c6ac7e7

14 files changed

+304
-111
lines changed

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-133.0.6943.16-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-134.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 -->
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-134.0.6998.35-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-135.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.4-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 -->133.0.6943.16<!-- GEN:stop --> ||||
17-
| WebKit <!-- GEN:webkit-version -->18.2<!-- GEN:stop --> ||||
18-
| Firefox <!-- GEN:firefox-version -->134.0<!-- GEN:stop --> ||||
16+
| Chromium <!-- GEN:chromium-version -->134.0.6998.35<!-- GEN:stop --> ||||
17+
| WebKit <!-- GEN:webkit-version -->18.4<!-- GEN:stop --> ||||
18+
| Firefox <!-- GEN:firefox-version -->135.0<!-- GEN:stop --> ||||
1919

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

browser_type.go

+11
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ func (b *browserTypeImpl) LaunchPersistentContext(userDataDir string, options ..
9999
func (b *browserTypeImpl) Connect(wsEndpoint string, options ...BrowserTypeConnectOptions) (Browser, error) {
100100
overrides := map[string]interface{}{
101101
"wsEndpoint": wsEndpoint,
102+
"headers": map[string]string{
103+
"x-playwright-browser": b.Name(),
104+
},
105+
}
106+
if len(options) == 1 {
107+
if options[0].Headers != nil {
108+
for k, v := range options[0].Headers {
109+
overrides["headers"].(map[string]string)[k] = v
110+
}
111+
options[0].Headers = nil
112+
}
102113
}
103114
localUtils := b.connection.LocalUtils()
104115
pipe, err := localUtils.channel.SendReturnAsDict("connect", options, overrides)

frame.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,14 @@ func (f *frameImpl) SetChecked(selector string, checked bool, options ...FrameSe
697697
}
698698

699699
func (f *frameImpl) Locator(selector string, options ...FrameLocatorOptions) Locator {
700-
var option LocatorLocatorOptions
700+
var option LocatorOptions
701701
if len(options) == 1 {
702-
option = LocatorLocatorOptions(options[0])
702+
option = LocatorOptions{
703+
Has: options[0].Has,
704+
HasNot: options[0].HasNot,
705+
HasText: options[0].HasText,
706+
HasNotText: options[0].HasNotText,
707+
}
703708
}
704709
return newLocator(f, selector, option)
705710
}

frame_locator.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,14 @@ func (fl *frameLocatorImpl) Last() FrameLocator {
8989
}
9090

9191
func (fl *frameLocatorImpl) Locator(selectorOrLocator interface{}, options ...FrameLocatorLocatorOptions) Locator {
92-
var option LocatorLocatorOptions
92+
var option LocatorOptions
9393
if len(options) == 1 {
94-
option = LocatorLocatorOptions(options[0])
94+
option = LocatorOptions{
95+
Has: options[0].Has,
96+
HasNot: options[0].HasNot,
97+
HasText: options[0].HasText,
98+
HasNotText: options[0].HasNotText,
99+
}
95100
}
96101

97102
selector, ok := selectorOrLocator.(string)

generated-enums.go

+13
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,19 @@ var (
365365
LoadStateNetworkidle = getLoadState("networkidle")
366366
)
367367

368+
func getContrast(in string) *Contrast {
369+
v := Contrast(in)
370+
return &v
371+
}
372+
373+
type Contrast string
374+
375+
var (
376+
ContrastNoPreference *Contrast = getContrast("no-preference")
377+
ContrastMore = getContrast("more")
378+
ContrastNoOverride = getContrast("no-override")
379+
)
380+
368381
func getMedia(in string) *Media {
369382
v := Media(in)
370383
return &v

generated-interfaces.go

+12-3
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,8 @@ type BrowserContext interface {
451451
// offline: Whether to emulate network being offline for the browser context.
452452
SetOffline(offline bool) error
453453

454-
// Returns storage state for this browser context, contains current cookies and local storage snapshot.
454+
// Returns storage state for this browser context, contains current cookies, local storage snapshot and IndexedDB
455+
// snapshot.
455456
StorageState(path ...string) (*StorageState, error)
456457

457458
Tracing() Tracing
@@ -2789,7 +2790,8 @@ type Locator interface {
27892790
// [control]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control
27902791
SetInputFiles(files interface{}, options ...LocatorSetInputFilesOptions) error
27912792

2792-
// Perform a tap gesture on the element matching the locator.
2793+
// Perform a tap gesture on the element matching the locator. For examples of emulating other gestures by manually
2794+
// dispatching touch events, see the [emulating legacy touch events] page.
27932795
//
27942796
// # Details
27952797
//
@@ -2802,6 +2804,7 @@ type Locator interface {
28022804
// [TimeoutError]. Passing zero timeout disables this.
28032805
// **NOTE** `element.tap()` requires that the `hasTouch` option of the browser context be set to true.
28042806
//
2807+
// [emulating legacy touch events]: https://playwright.dev/docs/touch-events
28052808
// [actionability]: https://playwright.dev/docs/actionability
28062809
Tap(options ...LocatorTapOptions) error
28072810

@@ -4416,6 +4419,10 @@ type Selectors interface {
44164419

44174420
// The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on
44184421
// the touchscreen can only be used in browser contexts that have been initialized with `hasTouch` set to true.
4422+
// This class is limited to emulating tap gestures. For examples of other gestures simulated by manually dispatching
4423+
// touch events, see the [emulating legacy touch events] page.
4424+
//
4425+
// [emulating legacy touch events]: https://playwright.dev/docs/touch-events
44194426
type Touchscreen interface {
44204427
// Dispatches a `touchstart` and `touchend` event with a single touch at the position
44214428
// (“[object Object]”,“[object Object]”).
@@ -4482,7 +4489,9 @@ type WebError interface {
44824489
Error() error
44834490
}
44844491

4485-
// The [WebSocket] class represents websocket connections in the page.
4492+
// The [WebSocket] class represents WebSocket connections within a page. It provides the ability to inspect and
4493+
// manipulate the data being transmitted and received.
4494+
// If you want to intercept or modify WebSocket frames, consider using [WebSocketRoute].
44864495
type WebSocket interface {
44874496
// Fired when the websocket closes.
44884497
OnClose(fn func(WebSocket))

generated-structs.go

+27-5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ type APIRequestNewContextOptions struct {
2525
ClientCertificates []ClientCertificate `json:"clientCertificates"`
2626
// An object containing additional HTTP headers to be sent with every request. Defaults to none.
2727
ExtraHttpHeaders map[string]string `json:"extraHTTPHeaders"`
28+
// Whether to throw on response codes other than 2xx and 3xx. By default response object is returned for all status
29+
// codes.
30+
FailOnStatusCode *bool `json:"failOnStatusCode"`
2831
// Credentials for [HTTP authentication]. If no
2932
// origin is specified, the username and password are sent to any servers upon unauthorized responses.
3033
//
@@ -1261,7 +1264,11 @@ type ElementHandleScreenshotOptions struct {
12611264
// changed. Defaults to `"hide"`.
12621265
Caret *ScreenshotCaret `json:"caret"`
12631266
// Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink
1264-
// box `#FF00FF` (customized by “[object Object]”) that completely covers its bounding box.
1267+
// box `#FF00FF` (customized by “[object Object]”) that completely covers its bounding box. The mask is also applied
1268+
// to invisible elements, see [Matching only visible elements] to
1269+
// disable that.
1270+
//
1271+
// [Matching only visible elements]: https://playwright.dev/docs/locators#matching-only-visible-elements
12651272
Mask []Locator `json:"mask"`
12661273
// Specify the color of the overlay box for masked elements, in
12671274
// [CSS color format]. Default color is pink `#FF00FF`.
@@ -2451,6 +2458,8 @@ type LocatorFilterOptions struct {
24512458
// passed a [string], matching is case-insensitive and searches for a substring. For example, `"Playwright"` matches
24522459
// `<article><div>Playwright</div></article>`.
24532460
HasText interface{} `json:"hasText"`
2461+
// Only matches visible or invisible elements.
2462+
Visible *bool `json:"visible"`
24542463
}
24552464

24562465
type LocatorFocusOptions struct {
@@ -2688,7 +2697,11 @@ type LocatorScreenshotOptions struct {
26882697
// changed. Defaults to `"hide"`.
26892698
Caret *ScreenshotCaret `json:"caret"`
26902699
// Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink
2691-
// box `#FF00FF` (customized by “[object Object]”) that completely covers its bounding box.
2700+
// box `#FF00FF` (customized by “[object Object]”) that completely covers its bounding box. The mask is also applied
2701+
// to invisible elements, see [Matching only visible elements] to
2702+
// disable that.
2703+
//
2704+
// [Matching only visible elements]: https://playwright.dev/docs/locators#matching-only-visible-elements
26922705
Mask []Locator `json:"mask"`
26932706
// Specify the color of the overlay box for masked elements, in
26942707
// [CSS color format]. Default color is pink `#FF00FF`.
@@ -3236,7 +3249,12 @@ type PageEmulateMediaOptions struct {
32363249
// emulation. `no-preference` is deprecated.
32373250
//
32383251
// [prefers-colors-scheme]: https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
3239-
ColorScheme *ColorScheme `json:"colorScheme"`
3252+
ColorScheme *ColorScheme `json:"colorScheme"`
3253+
// Emulates `prefers-contrast` media feature, supported values are `no-preference`, `more`. Passing
3254+
// `no-override` disables contrast emulation.
3255+
Contrast *Contrast `json:"contrast"`
3256+
// Emulates `forced-colors` media feature, supported values are `active` and `none`. Passing `no-override`
3257+
// disables forced colors emulation.
32403258
ForcedColors *ForcedColors `json:"forcedColors"`
32413259
// Changes the CSS media type of the page. The only allowed values are `screen`, `print` and `no-override`.
32423260
// Passing `no-override` disables CSS media emulation.
@@ -3683,7 +3701,11 @@ type PageScreenshotOptions struct {
36833701
// `false`.
36843702
FullPage *bool `json:"fullPage"`
36853703
// Specify locators that should be masked when the screenshot is taken. Masked elements will be overlaid with a pink
3686-
// box `#FF00FF` (customized by “[object Object]”) that completely covers its bounding box.
3704+
// box `#FF00FF` (customized by “[object Object]”) that completely covers its bounding box. The mask is also applied
3705+
// to invisible elements, see [Matching only visible elements] to
3706+
// disable that.
3707+
//
3708+
// [Matching only visible elements]: https://playwright.dev/docs/locators#matching-only-visible-elements
36873709
Mask []Locator `json:"mask"`
36883710
// Specify the color of the overlay box for masked elements, in
36893711
// [CSS color format]. Default color is pink `#FF00FF`.
@@ -4048,7 +4070,7 @@ type PageAssertionsToHaveTitleOptions struct {
40484070

40494071
type PageAssertionsToHaveURLOptions struct {
40504072
// Whether to perform case-insensitive match. “[object Object]” option takes precedence over the corresponding regular
4051-
// expression flag if specified.
4073+
// expression parameter if specified. A provided predicate ignores this flag.
40524074
IgnoreCase *bool `json:"ignoreCase"`
40534075
// Time to retry the assertion for in milliseconds. Defaults to `5000`.
40544076
Timeout *float64 `json:"timeout"`

locator.go

+22-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ var (
1414
type locatorImpl struct {
1515
frame *frameImpl
1616
selector string
17-
options *LocatorLocatorOptions
17+
options *LocatorOptions
1818
err error
1919
}
2020

21-
func newLocator(frame *frameImpl, selector string, options ...LocatorLocatorOptions) *locatorImpl {
22-
option := &LocatorLocatorOptions{}
21+
type LocatorOptions LocatorFilterOptions
22+
23+
func newLocator(frame *frameImpl, selector string, options ...LocatorOptions) *locatorImpl {
24+
option := &LocatorOptions{}
2325
if len(options) == 1 {
2426
option = &options[0]
2527
}
@@ -46,6 +48,10 @@ func newLocator(frame *frameImpl, selector string, options ...LocatorLocatorOpti
4648
selector += fmt.Sprintf(` >> internal:has-not=%s`, escapeText(hasNot.selector))
4749
}
4850
}
51+
if option.Visible != nil {
52+
selector += fmt.Sprintf(` >> visible=%s`, strconv.FormatBool(*option.Visible))
53+
}
54+
4955
locator.selector = selector
5056

5157
return locator
@@ -339,7 +345,7 @@ func (l *locatorImpl) Fill(value string, options ...LocatorFillOptions) error {
339345

340346
func (l *locatorImpl) Filter(options ...LocatorFilterOptions) Locator {
341347
if len(options) == 1 {
342-
return newLocator(l.frame, l.selector, LocatorLocatorOptions(options[0]))
348+
return newLocator(l.frame, l.selector, LocatorOptions(options[0]))
343349
}
344350
return newLocator(l.frame, l.selector)
345351
}
@@ -602,9 +608,19 @@ func (l *locatorImpl) Last() Locator {
602608
}
603609

604610
func (l *locatorImpl) Locator(selectorOrLocator interface{}, options ...LocatorLocatorOptions) Locator {
611+
var option LocatorOptions
612+
if len(options) == 1 {
613+
option = LocatorOptions{
614+
Has: options[0].Has,
615+
HasNot: options[0].HasNot,
616+
HasText: options[0].HasText,
617+
HasNotText: options[0].HasNotText,
618+
}
619+
}
620+
605621
selector, ok := selectorOrLocator.(string)
606622
if ok {
607-
return newLocator(l.frame, l.selector+" >> "+selector, options...)
623+
return newLocator(l.frame, l.selector+" >> "+selector, option)
608624
}
609625
locator, ok := selectorOrLocator.(*locatorImpl)
610626
if ok {
@@ -614,7 +630,7 @@ func (l *locatorImpl) Locator(selectorOrLocator interface{}, options ...LocatorL
614630
}
615631
return newLocator(l.frame,
616632
l.selector+" >> internal:chain="+escapeText(locator.selector),
617-
options...,
633+
option,
618634
)
619635
}
620636
l.err = errors.Join(l.err, fmt.Errorf("invalid locator parameter: %v", selectorOrLocator))

0 commit comments

Comments
 (0)