Skip to content

Commit 600e08b

Browse files
authored
chore: roll to playwright v1.50.1 (#529)
1 parent 4b99890 commit 600e08b

9 files changed

+211
-86
lines changed

README.md

+3-3
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-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 -->
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 -->
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 -->131.0.6778.33<!-- GEN:stop --> ||||
16+
| Chromium <!-- GEN:chromium-version -->133.0.6943.16<!-- GEN:stop --> ||||
1717
| WebKit <!-- GEN:webkit-version -->18.2<!-- GEN:stop --> ||||
18-
| Firefox <!-- GEN:firefox-version -->132.0<!-- GEN:stop --> ||||
18+
| Firefox <!-- GEN:firefox-version -->134.0<!-- GEN:stop --> ||||
1919

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

assertions.go

+14-13
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,29 @@ func (pa *playwrightAssertionsImpl) Page(page Page) PageAssertions {
3636
}
3737

3838
type expectedTextValue struct {
39-
Str *string `json:"string"`
40-
RegexSource *string `json:"regexSource"`
41-
RegexFlags *string `json:"regexFlags"`
42-
MatchSubstring *bool `json:"matchSubstring"`
43-
IgnoreCase *bool `json:"ignoreCase"`
44-
NormalizeWhiteSpace *bool `json:"normalizeWhiteSpace"`
39+
Str *string `json:"string,omitempty"`
40+
RegexSource *string `json:"regexSource,omitempty"`
41+
RegexFlags *string `json:"regexFlags,omitempty"`
42+
MatchSubstring *bool `json:"matchSubstring,omitempty"`
43+
IgnoreCase *bool `json:"ignoreCase,omitempty"`
44+
NormalizeWhiteSpace *bool `json:"normalizeWhiteSpace,omitempty"`
4545
}
4646

4747
type frameExpectOptions struct {
48-
ExpressionArg interface{} `json:"expressionArg"`
49-
ExpectedText []expectedTextValue `json:"expectedText"`
50-
ExpectedNumber *float64 `json:"expectedNumber"`
51-
ExpectedValue interface{} `json:"expectedValue"`
52-
UseInnerText *bool `json:"useInnerText"`
48+
ExpressionArg interface{} `json:"expressionArg,omitempty"`
49+
ExpectedText []expectedTextValue `json:"expectedText,omitempty"`
50+
ExpectedNumber *float64 `json:"expectedNumber,omitempty"`
51+
ExpectedValue interface{} `json:"expectedValue,omitempty"`
52+
UseInnerText *bool `json:"useInnerText,omitempty"`
5353
IsNot bool `json:"isNot"`
5454
Timeout *float64 `json:"timeout"`
5555
}
5656

5757
type frameExpectResult struct {
5858
Matches bool `json:"matches"`
59-
Received interface{} `json:"received"`
60-
Log []string `json:"log"`
59+
Received interface{} `json:"received,omitempty"`
60+
TimedOut *bool `json:"timedOut,omitempty"`
61+
Log []string `json:"log,omitempty"`
6162
}
6263

6364
type assertionsBase struct {

generated-interfaces.go

+34-16
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ type Browser interface {
154154
// opened).
155155
// In case this browser is connected to, clears all created contexts belonging to this browser and disconnects from
156156
// the browser server.
157-
// **NOTE** This is similar to force quitting the browser. Therefore, you should call [BrowserContext.Close] on any
158-
// [BrowserContext]'s you explicitly created earlier with [Browser.NewContext] **before** calling [Browser.Close].
157+
// **NOTE** This is similar to force-quitting the browser. To close pages gracefully and ensure you receive page close
158+
// events, call [BrowserContext.Close] on any [BrowserContext] instances you explicitly created earlier using
159+
// [Browser.NewContext] **before** calling [Browser.Close].
159160
// The [Browser] object itself is considered to be disposed and cannot be used anymore.
160161
Close(options ...BrowserCloseOptions) error
161162

@@ -336,9 +337,13 @@ type BrowserContext interface {
336337
// Grants specified permissions to the browser context. Only grants corresponding permissions to the given origin if
337338
// specified.
338339
//
339-
// permissions: A permission or an array of permissions to grant. Permissions can be one of the following values:
340+
// permissions: A list of permissions to grant.
341+
//
342+
// **NOTE** Supported permissions differ between browsers, and even between different versions of the same browser.
343+
// Any permission may stop working after an update.
344+
//
345+
// Here are some permissions that may be supported by some browsers:
340346
// - `'accelerometer'`
341-
// - `'accessibility-events'`
342347
// - `'ambient-light-sensor'`
343348
// - `'background-sync'`
344349
// - `'camera'`
@@ -428,7 +433,7 @@ type BrowserContext interface {
428433
// **NOTE** [Page.SetDefaultNavigationTimeout], [Page.SetDefaultTimeout] and
429434
// [BrowserContext.SetDefaultNavigationTimeout] take priority over [BrowserContext.SetDefaultTimeout].
430435
//
431-
// timeout: Maximum time in milliseconds
436+
// timeout: Maximum time in milliseconds. Pass `0` to disable timeout.
432437
SetDefaultTimeout(timeout float64)
433438

434439
// The extra HTTP headers will be sent with every request initiated by any page in the context. These headers are
@@ -490,16 +495,19 @@ type BrowserContext interface {
490495
// BrowserType provides methods to launch a specific browser instance or connect to an existing one. The following is
491496
// a typical example of using Playwright to drive automation:
492497
type BrowserType interface {
493-
// This method attaches Playwright to an existing browser instance. When connecting to another browser launched via
494-
// `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is
495-
// compatible with 1.2.x).
498+
// This method attaches Playwright to an existing browser instance created via `BrowserType.launchServer` in Node.js.
499+
// **NOTE** The major and minor version of the Playwright instance that connects needs to match the version of
500+
// Playwright that launches the browser (1.2.3 → is compatible with 1.2.x).
496501
//
497-
// wsEndpoint: A browser websocket endpoint to connect to.
502+
// wsEndpoint: A Playwright browser websocket endpoint to connect to. You obtain this endpoint via `BrowserServer.wsEndpoint`.
498503
Connect(wsEndpoint string, options ...BrowserTypeConnectOptions) (Browser, error)
499504

500505
// This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
501506
// The default browser context is accessible via [Browser.Contexts].
502507
// **NOTE** Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
508+
// **NOTE** This connection is significantly lower fidelity than the Playwright protocol connection via
509+
// [BrowserType.Connect]. If you are experiencing issues or attempting to use advanced functionality, you probably
510+
// want to use [BrowserType.Connect].
503511
//
504512
// endpointURL: A CDP websocket endpoint or http url to connect to. For example `http://localhost:9222/` or
505513
// `ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4`.
@@ -2597,7 +2605,9 @@ type Locator interface {
25972605
// [assertions guide]: https://playwright.dev/docs/test-assertions
25982606
IsDisabled(options ...LocatorIsDisabledOptions) (bool, error)
25992607

2600-
// Returns whether the element is [editable].
2608+
// Returns whether the element is [editable]. If the target element is not an `<input>`,
2609+
// `<textarea>`, `<select>`, `[contenteditable]` and does not have a role allowing `[aria-readonly]`, this method
2610+
// throws an error.
26012611
// **NOTE** If you need to assert that an element is editable, prefer [LocatorAssertions.ToBeEditable] to avoid
26022612
// flakiness. See [assertions guide] for more details.
26032613
//
@@ -2645,12 +2655,13 @@ type Locator interface {
26452655
Nth(index int) Locator
26462656

26472657
// Creates a locator matching all elements that match one or both of the two locators.
2648-
// Note that when both locators match something, the resulting locator will have multiple matches and violate
2649-
// [locator strictness] guidelines.
2658+
// Note that when both locators match something, the resulting locator will have multiple matches, potentially causing
2659+
// a [locator strictness] violation.
26502660
//
26512661
// locator: Alternative locator to match.
26522662
//
26532663
// [locator strictness]: https://playwright.dev/docs/locators#strictness
2664+
// ["strict mode violation" error]: https://playwright.dev/docs/locators#strictness
26542665
Or(locator Locator) Locator
26552666

26562667
// A page this locator belongs to.
@@ -2911,6 +2922,14 @@ type LocatorAssertions interface {
29112922
// [accessible description]: https://w3c.github.io/accname/#dfn-accessible-description
29122923
ToHaveAccessibleDescription(description interface{}, options ...LocatorAssertionsToHaveAccessibleDescriptionOptions) error
29132924

2925+
// Ensures the [Locator] points to an element with a given
2926+
// [aria errormessage].
2927+
//
2928+
// errorMessage: Expected accessible error message.
2929+
//
2930+
// [aria errormessage]: https://w3c.github.io/aria/#aria-errormessage
2931+
ToHaveAccessibleErrorMessage(errorMessage interface{}, options ...LocatorAssertionsToHaveAccessibleErrorMessageOptions) error
2932+
29142933
// Ensures the [Locator] points to an element with a given
29152934
// [accessible name].
29162935
//
@@ -2925,8 +2944,8 @@ type LocatorAssertions interface {
29252944
// 2. value: Expected attribute value.
29262945
ToHaveAttribute(name string, value interface{}, options ...LocatorAssertionsToHaveAttributeOptions) error
29272946

2928-
// Ensures the [Locator] points to an element with given CSS classes. This needs to be a full match or using a relaxed
2929-
// regular expression.
2947+
// Ensures the [Locator] points to an element with given CSS classes. When a string is provided, it must fully match
2948+
// the element's `class` attribute. To match individual classes or perform partial matches, use a regular expression:
29302949
//
29312950
// expected: Expected class or RegExp or a list of those.
29322951
ToHaveClass(expected interface{}, options ...LocatorAssertionsToHaveClassOptions) error
@@ -3659,7 +3678,6 @@ type Page interface {
36593678
Pause() error
36603679

36613680
// Returns the PDF buffer.
3662-
// **NOTE** Generating a pdf is currently only supported in Chromium headless.
36633681
// `page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call
36643682
// [Page.EmulateMedia] before calling `page.pdf()`:
36653683
// **NOTE** By default, `page.pdf()` generates a pdf with modified colors for printing. Use the
@@ -3875,7 +3893,7 @@ type Page interface {
38753893
// This setting will change the default maximum time for all the methods accepting “[object Object]” option.
38763894
// **NOTE** [Page.SetDefaultNavigationTimeout] takes priority over [Page.SetDefaultTimeout].
38773895
//
3878-
// timeout: Maximum time in milliseconds
3896+
// timeout: Maximum time in milliseconds. Pass `0` to disable timeout.
38793897
SetDefaultTimeout(timeout float64)
38803898

38813899
// The extra HTTP headers will be sent with every request the page initiates.

generated-structs.go

+15-2
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ type BrowserTypeLaunchOptions struct {
816816
// Use "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", or
817817
// "msedge-canary" to use branded [Google Chrome and Microsoft Edge].
818818
//
819-
// [opt in to new headless mode]: https://playwright.dev/docs/browsers#opt-in-to-new-headless-mode
819+
// [opt in to new headless mode]: https://playwright.dev/docs/browsers#chromium-new-headless-mode
820820
// [Google Chrome and Microsoft Edge]: https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
821821
Channel *string `json:"channel"`
822822
// Enable Chromium sandboxing. Defaults to `false`.
@@ -902,7 +902,7 @@ type BrowserTypeLaunchPersistentContextOptions struct {
902902
// Use "chrome", "chrome-beta", "chrome-dev", "chrome-canary", "msedge", "msedge-beta", "msedge-dev", or
903903
// "msedge-canary" to use branded [Google Chrome and Microsoft Edge].
904904
//
905-
// [opt in to new headless mode]: https://playwright.dev/docs/browsers#opt-in-to-new-headless-mode
905+
// [opt in to new headless mode]: https://playwright.dev/docs/browsers#chromium-new-headless-mode
906906
// [Google Chrome and Microsoft Edge]: https://playwright.dev/docs/browsers#google-chrome--microsoft-edge
907907
Channel *string `json:"channel"`
908908
// Enable Chromium sandboxing. Defaults to `false`.
@@ -2871,7 +2871,12 @@ type LocatorAssertionsToBeAttachedOptions struct {
28712871
}
28722872

28732873
type LocatorAssertionsToBeCheckedOptions struct {
2874+
// Provides state to assert for. Asserts for input to be checked by default. This option can't be used when
2875+
// “[object Object]” is set to true.
28742876
Checked *bool `json:"checked"`
2877+
// Asserts that the element is in the indeterminate (mixed) state. Only supported for checkboxes and radio buttons.
2878+
// This option can't be true when “[object Object]” is provided.
2879+
Indeterminate *bool `json:"indeterminate"`
28752880
// Time to retry the assertion for in milliseconds. Defaults to `5000`.
28762881
Timeout *float64 `json:"timeout"`
28772882
}
@@ -2940,6 +2945,14 @@ type LocatorAssertionsToHaveAccessibleDescriptionOptions struct {
29402945
Timeout *float64 `json:"timeout"`
29412946
}
29422947

2948+
type LocatorAssertionsToHaveAccessibleErrorMessageOptions struct {
2949+
// Whether to perform case-insensitive match. “[object Object]” option takes precedence over the corresponding regular
2950+
// expression flag if specified.
2951+
IgnoreCase *bool `json:"ignoreCase"`
2952+
// Time to retry the assertion for in milliseconds. Defaults to `5000`.
2953+
Timeout *float64 `json:"timeout"`
2954+
}
2955+
29432956
type LocatorAssertionsToHaveAccessibleNameOptions struct {
29442957
// Whether to perform case-insensitive match. “[object Object]” option takes precedence over the corresponding regular
29452958
// expression flag if specified.

locator_assertions.go

+42-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package playwright
22

33
import (
4+
"fmt"
45
"regexp"
56
)
67

@@ -36,19 +37,35 @@ func (la *locatorAssertionsImpl) ToBeAttached(options ...LocatorAssertionsToBeAt
3637
}
3738

3839
func (la *locatorAssertionsImpl) ToBeChecked(options ...LocatorAssertionsToBeCheckedOptions) error {
39-
expression := "to.be.checked"
4040
var timeout *float64
41+
42+
expectedValue := map[string]interface{}{}
43+
expected := "checked"
44+
4145
if len(options) == 1 {
42-
if options[0].Checked != nil && !*options[0].Checked {
43-
expression = "to.be.unchecked"
46+
if options[0].Indeterminate != nil {
47+
expectedValue["indeterminate"] = *options[0].Indeterminate
48+
if *options[0].Indeterminate {
49+
expected = "indeterminate"
50+
}
51+
} else {
52+
if options[0].Checked != nil {
53+
expectedValue["checked"] = *options[0].Checked
54+
if !*options[0].Checked {
55+
expected = "unchecked"
56+
}
57+
}
4458
}
4559
timeout = options[0].Timeout
4660
}
4761
return la.expect(
48-
expression,
49-
frameExpectOptions{Timeout: timeout},
62+
"to.be.checked",
63+
frameExpectOptions{
64+
ExpectedValue: expectedValue,
65+
Timeout: timeout,
66+
},
5067
nil,
51-
"Locator expected to be checked",
68+
fmt.Sprintf("Locator expected to be %s", expected),
5269
)
5370
}
5471

@@ -228,6 +245,25 @@ func (la *locatorAssertionsImpl) ToHaveAccessibleDescription(description interfa
228245
)
229246
}
230247

248+
func (la *locatorAssertionsImpl) ToHaveAccessibleErrorMessage(errorMessage interface{}, options ...LocatorAssertionsToHaveAccessibleErrorMessageOptions) error {
249+
var timeout *float64
250+
var ignoreCase *bool
251+
if len(options) == 1 {
252+
timeout = options[0].Timeout
253+
ignoreCase = options[0].IgnoreCase
254+
}
255+
expectedText, err := toExpectedTextValues([]interface{}{errorMessage}, false, false, ignoreCase)
256+
if err != nil {
257+
return err
258+
}
259+
return la.expect(
260+
"to.have.accessible.error.message",
261+
frameExpectOptions{ExpectedText: expectedText, Timeout: timeout},
262+
errorMessage,
263+
"Locator expected to have AccessibleErrorMessage",
264+
)
265+
}
266+
231267
func (la *locatorAssertionsImpl) ToHaveAccessibleName(name interface{}, options ...LocatorAssertionsToHaveAccessibleNameOptions) error {
232268
var timeout *float64
233269
var ignoreCase *bool

0 commit comments

Comments
 (0)