Skip to content

Commit

Permalink
Merge pull request #317 from YusukeIwaki/driver/1.49.0
Browse files Browse the repository at this point in the history
Update Playwright driver to 1.49.0
  • Loading branch information
YusukeIwaki authored Dec 3, 2024
2 parents 58c5d5b + 62451b9 commit 7a3f758
Show file tree
Hide file tree
Showing 18 changed files with 1,869 additions and 399 deletions.
2 changes: 1 addition & 1 deletion development/CLI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.48.0
1.49.0
1,466 changes: 1,082 additions & 384 deletions development/api.json

Large diffs are not rendered by default.

41 changes: 35 additions & 6 deletions development/generate_api/example_codes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,13 @@ def example_a4f00f0cd486431b7eca785304f4e9715522da45b66dda7f3a5f6899b889b9fd(pag
end

# Keyboard
def example_2deda0786a20a28cec9e8b438078a5fc567f7c7e5cf369419ab3c4d80a319ff6
# on windows and linux
def example_df65eb1dce081c61ad27e6322e441a7713c18bd842cd9c7d5f9c685ce987a5b6
# RECOMMENDED
page.keyboard.press("ControlOrMeta+A")

# or just on windows and linux
page.keyboard.press("Control+A")
# on mac_os
# or just on macOS
page.keyboard.press("Meta+A")
end

Expand Down Expand Up @@ -882,6 +885,11 @@ def example_0174039af5c928df43c04ef148ea798c5dcc7b6fc4ce4abc3a99a300f372a104(pag
button = page.get_by_role("button").and(page.get_by_title("Subscribe"))
end

# Locator#aria_snapshot
def example_c78b5ad5f44bbeed51ba622f4a74e92c4c094a787563d5e856724a6848e094c7(page:)
page.get_by_role("link").aria_snapshot
end

# Locator#bounding_box
def example_09bf5cd40405b9e5cd84333743b6ef919d0714bb4da78c86404789d26ff196ae(page:)
element = page.get_by_role("button")
Expand Down Expand Up @@ -1359,6 +1367,15 @@ def example_e5cce4bcdea914bbae14a3645b77f19c322038b0ef81d6ad2a1c9f5b0e21b1e9(pag
expect(locator).to have_values([/R/, /G/])
end

# LocatorAssertions#to_match_aria_snapshot
def example_e0bf8d0d0ca6181f89d6e14269d53e0bd13b4e5fb1d4457c443588c887ef417e(page:)
page.goto('https://demo.playwright.dev/todomvc/')
expect(page.locator('body')).to_match_aria_snapshot(<<~YAML)
- heading "todos"
- textbox "What needs to be done?"
YAML
end

# Mouse
def example_ba01da1f358cafb4c22b792488ff2f3de4dbd82d4ee1cc4050e3f0c24a2bd7dd(page:)
# using ‘page.mouse’ to trace a 100x100 square.
Expand Down Expand Up @@ -1475,11 +1492,10 @@ def example_df304caf6c61f6f44b3e2b0006a7e05552362a47b17c9ba227df76e918d88a5c(pag
end

# Page#emulate_media
def example_f0479a2ee8d8f51dab94f48b7e121cade07e5026d4f602521cc6ccc47feb5a98(page:)
page.emulate_media(colorScheme="dark")
def example_8abc1c4dd851cb7563f1f6b6489ebdc31d783b4eadbb48b0bfa0cfd2a993f788(page:)
page.emulate_media(colorScheme: "dark")
page.evaluate("matchMedia('(prefers-color-scheme: dark)').matches") # => true
page.evaluate("matchMedia('(prefers-color-scheme: light)').matches") # => false
page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches") # => false
end

# Page#eval_on_selector
Expand Down Expand Up @@ -1986,6 +2002,19 @@ def example_c74a3f913c302bc9bf81146db28832bdfe33ab7721f1343efb1e207bb070abce(con
context.tracing.stop_chunk(path: "trace2.zip")
end

# Tracing#group
def example_9bd098f4f0838dc7408dffc68bff0351714717a1fed7a909801dc263dfff2a17(context:)
# All actions between group and group_end
# will be shown in the trace viewer as a group.
context.tracing.group("Open Playwright.dev > API")

page = context.new_page
page.goto("https://playwright.dev/")
page.get_by_role("link", name: "API").click

context.tracing.group_end
end

# Worker
def example_29716fdd4471a97923a64eebeee96330ab508226a496ae8fd13f12eb07d55ee6(page:)
def handle_worker(worker)
Expand Down
4 changes: 3 additions & 1 deletion documentation/docs/api/clock.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ alias: `fixed_time=`
Makes `Date.now` and `new Date()` return fixed fake time at all times,
keeps all the timers running.

Use this method for simple scenarios where you only need to test with a predefined time. For more advanced scenarios, use [Clock#install](./clock#install) instead. Read docs on [clock emulation](https://playwright.dev/python/docs/clock) to learn more.

**Usage**

```ruby
Expand All @@ -126,7 +128,7 @@ def set_system_time(time)
alias: `system_time=`


Sets current system time but does not trigger any timers.
Sets system time, but does not trigger any timers. Use this to test how the web page reacts to a time shift, for example switching from summer to winter time, or changing time zones.

**Usage**

Expand Down
7 changes: 5 additions & 2 deletions documentation/docs/api/keyboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ page.keyboard.press("Shift+A")
An example to trigger select-all with the keyboard

```ruby
# on windows and linux
# RECOMMENDED
page.keyboard.press("ControlOrMeta+A")

# or just on windows and linux
page.keyboard.press("Control+A")
# on mac_os
# or just on macOS
page.keyboard.press("Meta+A")
```

Expand Down
43 changes: 43 additions & 0 deletions documentation/docs/api/locator.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,49 @@ The following example finds a button with a specific title.
button = page.get_by_role("button").and(page.get_by_title("Subscribe"))
```

## aria_snapshot

```
def aria_snapshot(timeout: nil)
```


Captures the aria snapshot of the given element.
Read more about [aria snapshots](https://playwright.dev/python/docs/aria-snapshots) and [LocatorAssertions#to_match_aria_snapshot](./locator_assertions#to_match_aria_snapshot) for the corresponding assertion.

**Usage**

```ruby
page.get_by_role("link").aria_snapshot
```

**Details**

This method captures the aria snapshot of the given element. The snapshot is a string that represents the state of the element and its children.
The snapshot can be used to assert the state of the element in the test, or to compare it to state in the future.

The ARIA snapshot is represented using [YAML](https://yaml.org/spec/1.2.2/) markup language:
- The keys of the objects are the roles and optional accessible names of the elements.
- The values are either text content or an array of child elements.
- Generic static text can be represented with the `text` key.

Below is the HTML markup and the respective ARIA snapshot:

```html
<ul aria-label="Links">
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<ul>
```

```yml
- list "Links":
- listitem:
- link "Home"
- listitem:
- link "About"
```
## blur
```
Expand Down
19 changes: 19 additions & 0 deletions documentation/docs/api/locator_assertions.md
Original file line number Diff line number Diff line change
Expand Up @@ -727,3 +727,22 @@ locator = page.locator("id=favorite-colors")
locator.select_option(["R", "G"])
expect(locator).to have_values([/R/, /G/])
```

## to_match_aria_snapshot

```ruby
expect(locator).to match_aria_snapshot(expected, timeout: nil)
```


Asserts that the target element matches the given [accessibility snapshot](https://playwright.dev/python/docs/aria-snapshots).

**Usage**

```ruby
page.goto('https://demo.playwright.dev/todomvc/')
expect(page.locator('body')).to_match_aria_snapshot(<<~YAML)
- heading "todos"
- textbox "What needs to be done?"
YAML
```
3 changes: 1 addition & 2 deletions documentation/docs/api/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,9 @@ page.evaluate("matchMedia('print').matches") # => false
```

```ruby
page.emulate_media(colorScheme="dark")
page.emulate_media(colorScheme: "dark")
page.evaluate("matchMedia('(prefers-color-scheme: dark)').matches") # => true
page.evaluate("matchMedia('(prefers-color-scheme: light)').matches") # => false
page.evaluate("matchMedia('(prefers-color-scheme: no-preference)').matches") # => false
```

## eval_on_selector
Expand Down
2 changes: 1 addition & 1 deletion documentation/docs/api/route.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ page.route("**/*", method(:handle))

**Details**

Note that any overrides such as `url` or `headers` only apply to the request being routed. If this request results in a redirect, overrides will not be applied to the new redirected request. If you want to propagate a header through redirects, use the combination of [Route#fetch](./route#fetch) and [Route#fulfill](./route#fulfill) instead.
The `headers` option applies to both the routed request and any redirects it initiates. However, `url`, `method`, and `postData` only apply to the original request and are not carried over to redirected requests.

[Route#continue](./route#continue) will immediately send the request to the network, other matching handlers won't be invoked. Use [Route#fallback](./route#fallback) If you want next matching handler in the chain to be invoked.

Expand Down
34 changes: 34 additions & 0 deletions documentation/docs/api/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,40 @@ page.goto("http://example.com")
context.tracing.stop_chunk(path: "trace2.zip")
```

## group

```
def group(name, location: nil)
```


**NOTE**: Use `test.step` instead when available.

Creates a new group within the trace, assigning any subsequent API calls to this group, until [Tracing#group_end](./tracing#group_end) is called. Groups can be nested and will be visible in the trace viewer.

**Usage**

```ruby
# All actions between group and group_end
# will be shown in the trace viewer as a group.
context.tracing.group("Open Playwright.dev > API")

page = context.new_page
page.goto("https://playwright.dev/")
page.get_by_role("link", name: "API").click

context.tracing.group_end
```

## group_end

```
def group_end
```


Closes the last group created by [Tracing#group](./tracing#group).

## stop

```
Expand Down
4 changes: 4 additions & 0 deletions documentation/docs/include/api_coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,8 @@

* start
* start_chunk
* group
* group_end
* stop
* stop_chunk

Expand All @@ -445,6 +447,7 @@
* all_inner_texts
* all_text_contents
* and
* aria_snapshot
* blur
* bounding_box
* check
Expand Down Expand Up @@ -596,6 +599,7 @@
* to_have_text
* to_have_value
* to_have_values
* to_match_aria_snapshot

## PageAssertions

Expand Down
12 changes: 12 additions & 0 deletions lib/playwright/channel_owners/tracing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,17 @@ def stop(path: nil)
private def update_traces_dir(traces_dir)
@traces_dir = traces_dir
end

def group(name, location: nil)
params = {
name: name,
location: location,
}.compact
@channel.send_message_to_server('tracingGroup', params)
end

def group_end
@channel.send_message_to_server('tracingGroupEnd')
end
end
end
12 changes: 12 additions & 0 deletions lib/playwright/locator_assertions_impl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,18 @@ def to_have_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
end
_define_negation :to_have_text

def to_match_aria_snapshot(expected, timeout: nil)
expect_impl(
'to.match.aria',
{
expectedValue: expected,
timeout: timeout,
},
expected,
'Locator expected to match Aria snapshot',
)
end

def to_be_attached(attached: nil, timeout: nil)
expect_impl(
(attached || attached.nil?) ? "to.be.attached" : "to.be.detached",
Expand Down
7 changes: 7 additions & 0 deletions lib/playwright/locator_impl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,13 @@ def screenshot(
end
end

def aria_snapshot(timeout: nil)
@frame.channel.send_message_to_server('ariaSnapshot', {
selector: @selector,
timeout: timeout,
}.compact)
end

def scroll_into_view_if_needed(timeout: nil)
with_element(timeout: timeout) do |handle, options|
handle.scroll_into_view_if_needed(timeout: options[:timeout])
Expand Down
4 changes: 2 additions & 2 deletions lib/playwright/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module Playwright
VERSION = '1.48.0'
COMPATIBLE_PLAYWRIGHT_VERSION = '1.48.2'
VERSION = '1.49.0'
COMPATIBLE_PLAYWRIGHT_VERSION = '1.49.0'
end
10 changes: 10 additions & 0 deletions spec/integration/example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,13 @@
end
end

it 'should work with Page#emulate_media' do
with_page do |page|
example_df304caf6c61f6f44b3e2b0006a7e05552362a47b17c9ba227df76e918d88a5c(page: page)
example_8abc1c4dd851cb7563f1f6b6489ebdc31d783b4eadbb48b0bfa0cfd2a993f788(page: page)
end
end

it 'should work with Page#press' do
with_page do |page|
with_network_retry do
Expand Down Expand Up @@ -565,6 +572,9 @@
with_context do |context|
example_c74a3f913c302bc9bf81146db28832bdfe33ab7721f1343efb1e207bb070abce(context: context)
end
with_context do |context|
example_9bd098f4f0838dc7408dffc68bff0351714717a1fed7a909801dc263dfff2a17(context: context)
end
end

it 'should work with Worker', skip: ENV['CI'] do
Expand Down
Loading

0 comments on commit 7a3f758

Please sign in to comment.