playwright-ruby-client 1.28.0 → 1.28.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/playwright/channel_owners/android.rb +2 -2
- data/lib/playwright/channel_owners/android_device.rb +14 -55
- data/lib/playwright/channel_owners/playwright.rb +7 -0
- data/lib/playwright/input_files.rb +3 -1
- data/lib/playwright/version.rb +1 -1
- data/lib/playwright/web_socket_transport.rb +1 -1
- data/lib/playwright.rb +55 -0
- data/lib/playwright_api/android_device.rb +5 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f6b579547c4cff2fbaf98b5c2796c8689f655f316b391b7127891fd03212cea4
|
4
|
+
data.tar.gz: c32a3787fa3f6c2e874844f94deef249c335cee4f6efcc8d23e8045bfd6346f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7481f324212879e913399614beab51affce2c8dc05040ac0d506d9b583fcf48c897bd1a1f3b7f332212497db2000e538a1cf1fd19c60d5ddf7c884e2e366d687
|
7
|
+
data.tar.gz: 58eb07d5abb6307bd15464b6f33d8c0d0cc4110cf80c26915cecc00be911fba8e6240687cb46698c81fda29651718b4039f8ca1530661e5ccd4a7d1632bd6ef3
|
@@ -4,8 +4,8 @@ module Playwright
|
|
4
4
|
@timeout_settings = TimeoutSettings.new
|
5
5
|
end
|
6
6
|
|
7
|
-
def devices(port: nil)
|
8
|
-
params = { port: port }.compact
|
7
|
+
def devices(host: nil, omitDriverInstall: nil, port: nil)
|
8
|
+
params = { host: host, port: port, omitDriverInstall: omitDriverInstall }.compact
|
9
9
|
resp = @channel.send_message_to_server('devices', params)
|
10
10
|
resp.map { |device| ChannelOwners::AndroidDevice.from(device) }
|
11
11
|
end
|
@@ -4,6 +4,11 @@ module Playwright
|
|
4
4
|
|
5
5
|
private def after_initialize
|
6
6
|
@input = AndroidInputImpl.new(@channel)
|
7
|
+
@should_close_connection_on_close = false
|
8
|
+
end
|
9
|
+
|
10
|
+
def should_close_connection_on_close!
|
11
|
+
@should_close_connection_on_close = true
|
7
12
|
end
|
8
13
|
|
9
14
|
attr_reader :input
|
@@ -77,8 +82,12 @@ module Playwright
|
|
77
82
|
end
|
78
83
|
|
79
84
|
def close
|
80
|
-
@channel.send_message_to_server('close')
|
81
85
|
emit(Events::AndroidDevice::Close)
|
86
|
+
if @should_close_connection_on_close
|
87
|
+
@connection.stop
|
88
|
+
else
|
89
|
+
@channel.send_message_to_server('close')
|
90
|
+
end
|
82
91
|
end
|
83
92
|
|
84
93
|
def shell(command)
|
@@ -86,60 +95,10 @@ module Playwright
|
|
86
95
|
Base64.strict_decode64(resp)
|
87
96
|
end
|
88
97
|
|
89
|
-
def launch_browser(
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
colorScheme: nil,
|
94
|
-
deviceScaleFactor: nil,
|
95
|
-
extraHTTPHeaders: nil,
|
96
|
-
geolocation: nil,
|
97
|
-
hasTouch: nil,
|
98
|
-
httpCredentials: nil,
|
99
|
-
ignoreHTTPSErrors: nil,
|
100
|
-
isMobile: nil,
|
101
|
-
javaScriptEnabled: nil,
|
102
|
-
locale: nil,
|
103
|
-
noViewport: nil,
|
104
|
-
offline: nil,
|
105
|
-
permissions: nil,
|
106
|
-
proxy: nil,
|
107
|
-
record_har_omit_content: nil,
|
108
|
-
record_har_path: nil,
|
109
|
-
record_video_dir: nil,
|
110
|
-
record_video_size: nil,
|
111
|
-
storageState: nil,
|
112
|
-
timezoneId: nil,
|
113
|
-
userAgent: nil,
|
114
|
-
viewport: nil,
|
115
|
-
&block)
|
116
|
-
params = {
|
117
|
-
pkg: pkg,
|
118
|
-
acceptDownloads: acceptDownloads,
|
119
|
-
bypassCSP: bypassCSP,
|
120
|
-
colorScheme: colorScheme,
|
121
|
-
deviceScaleFactor: deviceScaleFactor,
|
122
|
-
extraHTTPHeaders: extraHTTPHeaders,
|
123
|
-
geolocation: geolocation,
|
124
|
-
hasTouch: hasTouch,
|
125
|
-
httpCredentials: httpCredentials,
|
126
|
-
ignoreHTTPSErrors: ignoreHTTPSErrors,
|
127
|
-
isMobile: isMobile,
|
128
|
-
javaScriptEnabled: javaScriptEnabled,
|
129
|
-
locale: locale,
|
130
|
-
noViewport: noViewport,
|
131
|
-
offline: offline,
|
132
|
-
permissions: permissions,
|
133
|
-
proxy: proxy,
|
134
|
-
record_har_omit_content: record_har_omit_content,
|
135
|
-
record_har_path: record_har_path,
|
136
|
-
record_video_dir: record_video_dir,
|
137
|
-
record_video_size: record_video_size,
|
138
|
-
storageState: storageState,
|
139
|
-
timezoneId: timezoneId,
|
140
|
-
userAgent: userAgent,
|
141
|
-
viewport: viewport,
|
142
|
-
}.compact
|
98
|
+
def launch_browser(pkg: nil, **options, &block)
|
99
|
+
params = options.dup
|
100
|
+
params[:pkg] = pkg
|
101
|
+
params.compact!
|
143
102
|
prepare_browser_context_options(params)
|
144
103
|
|
145
104
|
resp = @channel.send_message_to_server('launchBrowser', params)
|
@@ -39,6 +39,13 @@ module Playwright
|
|
39
39
|
::Playwright::ChannelOwners::Browser.from(@initializer['preLaunchedBrowser'])
|
40
40
|
end
|
41
41
|
|
42
|
+
private def pre_connected_android_device
|
43
|
+
unless @initializer['preConnectedAndroidDevice']
|
44
|
+
raise 'Malformed endpoint. Did you use Android.launchServer method?'
|
45
|
+
end
|
46
|
+
::Playwright::ChannelOwners::AndroidDevice.from(@initializer['preConnectedAndroidDevice'])
|
47
|
+
end
|
48
|
+
|
42
49
|
private def parse_device_descriptor(descriptor)
|
43
50
|
# This return value can be passed into Browser#new_context as it is.
|
44
51
|
# ex:
|
data/lib/playwright/version.rb
CHANGED
data/lib/playwright.rb
CHANGED
@@ -51,6 +51,22 @@ module Playwright
|
|
51
51
|
attr_reader :playwright, :browser
|
52
52
|
end
|
53
53
|
|
54
|
+
class AndroidExecution
|
55
|
+
def initialize(connection, playwright, device = nil)
|
56
|
+
@connection = connection
|
57
|
+
@playwright = playwright
|
58
|
+
@device = device
|
59
|
+
end
|
60
|
+
|
61
|
+
def stop
|
62
|
+
@device&.close
|
63
|
+
@connection.stop
|
64
|
+
end
|
65
|
+
|
66
|
+
attr_reader :playwright, :device
|
67
|
+
end
|
68
|
+
|
69
|
+
|
54
70
|
# Recommended to call this method with block.
|
55
71
|
#
|
56
72
|
# Playwright.create(...) do |playwright|
|
@@ -161,4 +177,43 @@ module Playwright
|
|
161
177
|
execution
|
162
178
|
end
|
163
179
|
end
|
180
|
+
|
181
|
+
# Connects to Playwright server, launched by `npx playwright launch-server chromium` or `playwright.chromium.launchServer()`
|
182
|
+
#
|
183
|
+
# Playwright.connect_to_browser_server('ws://....') do |browser|
|
184
|
+
# page = browser.new_page
|
185
|
+
# ...
|
186
|
+
# end
|
187
|
+
#
|
188
|
+
# @experimental
|
189
|
+
module_function def connect_to_android_server(ws_endpoint, &block)
|
190
|
+
require 'playwright/web_socket_client'
|
191
|
+
require 'playwright/web_socket_transport'
|
192
|
+
|
193
|
+
transport = WebSocketTransport.new(ws_endpoint: ws_endpoint)
|
194
|
+
connection = Connection.new(transport)
|
195
|
+
connection.mark_as_remote
|
196
|
+
connection.async_run
|
197
|
+
|
198
|
+
execution =
|
199
|
+
begin
|
200
|
+
playwright = connection.initialize_playwright
|
201
|
+
android_device = playwright.send(:pre_connected_android_device)
|
202
|
+
android_device.should_close_connection_on_close!
|
203
|
+
AndroidExecution.new(connection, PlaywrightApi.wrap(playwright), PlaywrightApi.wrap(android_device))
|
204
|
+
rescue
|
205
|
+
connection.stop
|
206
|
+
raise
|
207
|
+
end
|
208
|
+
|
209
|
+
if block
|
210
|
+
begin
|
211
|
+
block.call(execution.device)
|
212
|
+
ensure
|
213
|
+
execution.stop
|
214
|
+
end
|
215
|
+
else
|
216
|
+
execution
|
217
|
+
end
|
218
|
+
end
|
164
219
|
end
|
@@ -168,6 +168,11 @@ module Playwright
|
|
168
168
|
raise NotImplementedError.new('web_views is not implemented yet.')
|
169
169
|
end
|
170
170
|
|
171
|
+
# @nodoc
|
172
|
+
def should_close_connection_on_close!
|
173
|
+
wrap_impl(@impl.should_close_connection_on_close!)
|
174
|
+
end
|
175
|
+
|
171
176
|
# @nodoc
|
172
177
|
def tap_on(selector, duration: nil, timeout: nil)
|
173
178
|
wrap_impl(@impl.tap_on(unwrap_impl(selector), duration: unwrap_impl(duration), timeout: unwrap_impl(timeout)))
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playwright-ruby-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.28.
|
4
|
+
version: 1.28.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YusukeIwaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|