Skip to content

Commit

Permalink
chore: roll to Playwright v1.30.0 (#352)
Browse files Browse the repository at this point in the history
  • Loading branch information
canstand authored Jun 19, 2023
1 parent 6d38177 commit e802fc1
Show file tree
Hide file tree
Showing 67 changed files with 5,276 additions and 2,212 deletions.
46 changes: 16 additions & 30 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version: ^1.19.9
id: go
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v3
with:
version: latest
test:
Expand All @@ -23,33 +28,14 @@ jobs:
runs-on: ${{ matrix.os }}
name: ${{ matrix.browser }} on ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ^1.16.1
go-version: ^1.19.9
id: go
- name: Cache modules and build
uses: actions/cache@v3
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Download modules
if: steps.cache.outputs.cache-hit != 'true'
run: go mod download
- run: |
go install ./...
playwright install --with-deps ${{ matrix.browser }}
Expand Down Expand Up @@ -77,11 +63,11 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ^1.16.1
go-version: ^1.19.9
id: go
- name: Install goveralls
env:
Expand All @@ -94,11 +80,11 @@ jobs:
test-examples:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ^1.16.1
go-version: ^1.19.9
id: go
- run: |
go install ./...
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
name: Deploy docs
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/verify_type_generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ jobs:
verify:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: true
- uses: microsoft/playwright-github-action@v1
- name: Set up Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ^1.16.1
go-version: ^1.19.9
- name: Install Browsers
run: |
go install ./...
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
[![PkgGoDev](https://pkg.go.dev/badge/github.com/playwright-community/playwright-go)](https://pkg.go.dev/github.com/playwright-community/playwright-go)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](http://opensource.org/licenses/MIT)
[![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)
[![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-105.0.5195.19-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-103.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-16.0-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop -->
[![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-110.0.5481.38-blue.svg?logo=google-chrome)](https://www.chromium.org/Home)<!-- GEN:stop --> <!-- GEN:firefox-version-badge -->[![Firefox version](https://img.shields.io/badge/firefox-108.0.2-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-16.4-blue.svg?logo=safari)](https://webkit.org/)<!-- GEN:stop -->

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

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**.

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->105.0.5195.19<!-- GEN:stop --> ||||
| WebKit <!-- GEN:webkit-version -->16.0<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->103.0<!-- GEN:stop --> ||||
| Chromium <!-- GEN:chromium-version -->110.0.5481.38<!-- GEN:stop --> ||||
| WebKit <!-- GEN:webkit-version -->16.4<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->108.0.2<!-- GEN:stop --> ||||

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

Expand Down
2 changes: 1 addition & 1 deletion artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (a *artifactImpl) SaveAs(path string) error {
if err != nil {
return err
}
stream := streamChannel.(*streamImpl)
stream := fromChannel(streamChannel).(*streamImpl)
return stream.SaveAs(path)
}

Expand Down
41 changes: 27 additions & 14 deletions browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ package playwright
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
)

type browserImpl struct {
channelOwner
isConnected bool
isClosedOrClosing bool
isConnectedOverWebSocket bool
contexts []BrowserContext
isConnected bool
isClosedOrClosing bool
shouldCloseConnectionOnClose bool
contexts []BrowserContext
browserType BrowserType
}

func (b *browserImpl) BrowserType() BrowserType {
return b.browserType
}

func (b *browserImpl) IsConnected() bool {
Expand All @@ -28,8 +33,8 @@ func (b *browserImpl) NewContext(options ...BrowserNewContextOptions) (BrowserCo
options[0].ExtraHttpHeaders = nil
}
if options[0].StorageStatePath != nil {
var storageState *BrowserNewContextOptionsStorageState
storageString, err := ioutil.ReadFile(*options[0].StorageStatePath)
var storageState *OptionalStorageState
storageString, err := os.ReadFile(*options[0].StorageStatePath)
if err != nil {
return nil, fmt.Errorf("could not read storage state file: %w", err)
}
Expand Down Expand Up @@ -102,11 +107,17 @@ func (b *browserImpl) Contexts() []BrowserContext {
}

func (b *browserImpl) Close() error {
if b.isClosedOrClosing {
return nil
}
b.Lock()
b.isClosedOrClosing = true
b.Unlock()
_, err := b.channel.Send("close")
if err != nil {
return fmt.Errorf("could not send message: %w", err)
}
if b.isConnectedOverWebSocket {
if b.shouldCloseConnectionOnClose {
return b.connection.Stop()
}
return nil
Expand All @@ -118,20 +129,22 @@ func (b *browserImpl) Version() string {

func (b *browserImpl) onClose() {
b.Lock()
if !b.isClosedOrClosing {
b.isClosedOrClosing = true
if b.isConnected {
b.isConnected = false
b.isClosedOrClosing = true
b.Emit("disconnected")
}
b.Unlock()
}

func newBrowser(parent *channelOwner, objectType string, guid string, initializer map[string]interface{}) *browserImpl {
bt := &browserImpl{
b := &browserImpl{
isConnected: true,
contexts: make([]BrowserContext, 0),
}
bt.createChannelOwner(bt, parent, objectType, guid, initializer)
bt.channel.On("close", bt.onClose)
return bt
b.createChannelOwner(b, parent, objectType, guid, initializer)
// convert parent to *browserTypeImpl
b.browserType = newBrowserType(parent.parent, parent.objectType, parent.guid, parent.initializer)
b.channel.On("close", b.onClose)
return b
}
Loading

0 comments on commit e802fc1

Please sign in to comment.