Skip to content

Commit

Permalink
Merge pull request #260 from YusukeIwaki/driver/1.37.0
Browse files Browse the repository at this point in the history
Update playwright driver to 1.37.0
  • Loading branch information
YusukeIwaki authored Aug 11, 2023
2 parents 1e9e2df + 26e987b commit c430525
Show file tree
Hide file tree
Showing 10 changed files with 957 additions and 118 deletions.
2 changes: 1 addition & 1 deletion development/CLI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.36.1
1.37.0
1,011 changes: 908 additions & 103 deletions development/api.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion documentation/docs/api/browser_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def route_from_har(
```


If specified the network requests that are made in the context will be served from the HAR file. Read more about [Replaying from HAR](https://playwright.dev/python/docs/network#replaying-from-har).
If specified the network requests that are made in the context will be served from the HAR file. Read more about [Replaying from HAR](https://playwright.dev/python/docs/mock#replaying-from-har).

Playwright will not serve requests intercepted by Service Worker from the HAR file. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.

Expand Down
1 change: 1 addition & 0 deletions documentation/docs/api/frame.md
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,7 @@ def set_content(html, timeout: nil, waitUntil: nil)
alias: `content=`


This method internally calls [document.write()](https://developer.mozilla.org/en-US/docs/Web/API/Document/write), inheriting all its specific characteristics and behaviors.

## set_input_files

Expand Down
7 changes: 4 additions & 3 deletions documentation/docs/api/locator.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ sidebar_position: 10


Locators are the central piece of Playwright's auto-waiting and retry-ability. In a nutshell, locators represent
a way to find element(s) on the page at any moment. Locator can be created with the [Page#locator](./page#locator) method.
a way to find element(s) on the page at any moment. A locator can be created with the [Page#locator](./page#locator) method.

[Learn more about locators](https://playwright.dev/python/docs/locators).

Expand All @@ -17,8 +17,7 @@ def all
```


When locator points to a list of elements, returns array of locators, pointing
to respective elements.
When the locator points to a list of elements, this returns an array of locators, pointing to their respective elements.

**NOTE**: [Locator#all](./locator#all) does not wait for elements to match the locator, and instead immediately returns whatever is present in the page.

Expand Down Expand Up @@ -1255,6 +1254,8 @@ def type(text, delay: nil, noWaitAfter: nil, timeout: nil)
```


**NOTE**: In most cases, you should use [Locator#fill](./locator#fill) instead. You only need to type characters if there is special keyboard handling on the page.

Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.

To press a special key, like `Control` or `ArrowDown`, use [Locator#press](./locator#press).
Expand Down
3 changes: 2 additions & 1 deletion documentation/docs/api/page.md
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ def route_from_har(
```


If specified the network requests that are made in the page will be served from the HAR file. Read more about [Replaying from HAR](https://playwright.dev/python/docs/network#replaying-from-har).
If specified the network requests that are made in the page will be served from the HAR file. Read more about [Replaying from HAR](https://playwright.dev/python/docs/mock#replaying-from-har).

Playwright will not serve requests intercepted by Service Worker from the HAR file. See [this](https://github.com/microsoft/playwright/issues/1090) issue. We recommend disabling Service Workers when using request interception by setting `Browser.newContext.serviceWorkers` to `'block'`.

Expand Down Expand Up @@ -1369,6 +1369,7 @@ def set_content(html, timeout: nil, waitUntil: nil)
alias: `content=`


This method internally calls [document.write()](https://developer.mozilla.org/en-US/docs/Web/API/Document/write), inheriting all its specific characteristics and behaviors.

## set_default_navigation_timeout

Expand Down
7 changes: 7 additions & 0 deletions lib/playwright/channel_owners/artifact.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'stringio'

module Playwright
define_channel_owner :Artifact do
private def after_initialize
Expand All @@ -18,6 +20,11 @@ def save_as(path)
stream.save_as(path)
end

def read_into_buffer
stream = ChannelOwners::Stream.from(@channel.send_message_to_server('stream'))
stream.read_all
end

def failure
@channel.send_message_to_server('failure')
end
Expand Down
15 changes: 12 additions & 3 deletions lib/playwright/channel_owners/browser.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'fileutils'

module Playwright
# @ref https://github.com/microsoft/playwright-python/blob/master/playwright/_impl/_browser.py
define_channel_owner :Browser do
Expand Down Expand Up @@ -86,16 +88,23 @@ def start_tracing(page: nil, categories: nil, path: nil, screenshots: nil)
params = {
page: page&.channel,
categories: categories,
path: path,
screenshots: screenshots,
}.compact
@cr_tracing_path = path

@channel.send_message_to_server('startTracing', params)
end

def stop_tracing
encoded_binary = @channel.send_message_to_server("stopTracing")
return Base64.strict_decode64(encoded_binary)
artifact = ChannelOwners::Artifact.from(@channel.send_message_to_server("stopTracing"))
data = artifact.read_into_buffer
if @cr_tracing_path
File.dirname(@cr_tracing_path).tap do |dir|
FileUtils.mkdir_p(dir) unless File.exist?(dir)
end
File.open(@cr_tracing_path, 'wb') { |f| f.write(data) }
end
data
end

private def on_close(_ = {})
Expand Down
23 changes: 19 additions & 4 deletions lib/playwright/channel_owners/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,27 @@ module Playwright
define_channel_owner :Stream do
def save_as(path)
File.open(path, 'wb') do |f|
loop do
binary = @channel.send_message_to_server('read')
break if !binary || binary.length == 0
f.write(Base64.strict_decode64(binary))
read_with_block do |chunk|
f.write(chunk)
end
end
end

def read_all(&block)
out = StringIO.new
read_with_block do |chunk|
out.write(chunk)
end
out.string
end

private def read_with_block(&block)
loop do
binary = @channel.send_message_to_server('read', size: 1024 * 1024)
break if !binary || binary.length == 0
decoded_chunk = Base64.strict_decode64(binary)
block.call(decoded_chunk)
end
end
end
end
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.36.0'
COMPATIBLE_PLAYWRIGHT_VERSION = '1.36.1'
VERSION = '1.37.0'
COMPATIBLE_PLAYWRIGHT_VERSION = '1.37.0'
end

1 comment on commit c430525

@vercel
Copy link

@vercel vercel bot commented on c430525 Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.