playwright-ruby-client 1.19.1 → 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68d737d7d01fd92889e417be20bca72ee6247258d07dc8b18f44a1b07967a2c1
4
- data.tar.gz: 18522777dc4ef3e19a9be4a17710cfdef404fc441dcf2a5a28b82138175dfebd
3
+ metadata.gz: 4fa3fb99ecc1273e529e04b47bebf13546ecfcfc930b10b14c5fe3d0816af724
4
+ data.tar.gz: 6c74c799eccc9cf4c0c7dd120e10cdd0bfdc8dbd3e23713d2a0842fc53edb6f2
5
5
  SHA512:
6
- metadata.gz: bf0887d285eabec5cf17b380d99e566f1b1399e089614adf23d99a38f0975e5f1b9fb6eb8891d67857b21945b5ad00772202caf337aeac53439407f20f5386f9
7
- data.tar.gz: 95553f620063bbd52ded34d1f260a920fd82ba127868f1c85c43ac0b466ed9e93a1fce5d6319805e8f13ade1f3ad3c0aa03795be4387b3354664e26c2c1f4e00
6
+ metadata.gz: bcf0cf470b95f65380b584a3f6d4489be51f5479d23695ca8f6dd16549df1d9a4af07b112a5e5ca779d7915b86cd77b5644becea1b58fdddf527638e547734e3
7
+ data.tar.gz: 389a1c2b5e73fa6cd62703d487b864af1135822aaeaebeedcef24a6911c23cdd4f39e4353ea3d36a7ca367b5ae4fe8d88b65eb98336bd2a4afcfe5740dea3866
data/README.md CHANGED
@@ -162,7 +162,7 @@ If your environment doesn't accept installing browser or creating browser proces
162
162
  For launching Playwright server, just execute:
163
163
 
164
164
  ```
165
- npx playwright install && npx playwright run-server 8080
165
+ npx playwright install && npx playwright run-server --port 8080
166
166
  ```
167
167
 
168
168
  and we can connect to the server with the code like this:
@@ -435,6 +435,8 @@ The method finds all elements matching the specified selector in the [ElementHan
435
435
 
436
436
  ```
437
437
  def screenshot(
438
+ animations: nil,
439
+ mask: nil,
438
440
  omitBackground: nil,
439
441
  path: nil,
440
442
  quality: nil,
@@ -33,7 +33,7 @@ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
33
33
  ## devices
34
34
 
35
35
  ```
36
- def devices
36
+ def devices(port: nil)
37
37
  ```
38
38
 
39
39
  Returns the list of detected Android devices.
@@ -325,6 +325,15 @@ def get_attribute(name, timeout: nil)
325
325
 
326
326
  Returns element attribute value.
327
327
 
328
+ ## highlight
329
+
330
+ ```
331
+ def highlight
332
+ ```
333
+
334
+ Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses
335
+ [Locator#highlight](./locator#highlight).
336
+
328
337
  ## hover
329
338
 
330
339
  ```
@@ -480,6 +489,8 @@ modifier, modifier is pressed and being held while the subsequent key is being p
480
489
 
481
490
  ```
482
491
  def screenshot(
492
+ animations: nil,
493
+ mask: nil,
483
494
  omitBackground: nil,
484
495
  path: nil,
485
496
  quality: nil,
@@ -1012,8 +1012,10 @@ To remove a route with its handler you can use [Page#unroute](./page#unroute).
1012
1012
 
1013
1013
  ```
1014
1014
  def screenshot(
1015
+ animations: nil,
1015
1016
  clip: nil,
1016
1017
  fullPage: nil,
1018
+ mask: nil,
1017
1019
  omitBackground: nil,
1018
1020
  path: nil,
1019
1021
  quality: nil,
@@ -1167,9 +1169,10 @@ alias: `viewport_size=`
1167
1169
  In the case of multiple pages in a single browser, each page can have its own viewport size. However,
1168
1170
  [Browser#new_context](./browser#new_context) allows to set viewport size (and more) for all pages in the context at once.
1169
1171
 
1170
- `page.setViewportSize` will resize the page. A lot of websites don't expect phones to change size, so you should set the
1171
- viewport size before navigating to the page. [Page#set_viewport_size](./page#set_viewport_size) will also reset `screen` size, use
1172
- [Browser#new_context](./browser#new_context) with `screen` and `viewport` parameters if you need better control of these properties.
1172
+ [Page#set_viewport_size](./page#set_viewport_size) will resize the page. A lot of websites don't expect phones to change size, so you
1173
+ should set the viewport size before navigating to the page. [Page#set_viewport_size](./page#set_viewport_size) will also reset `screen`
1174
+ size, use [Browser#new_context](./browser#new_context) with `screen` and `viewport` parameters if you need better control of these
1175
+ properties.
1173
1176
 
1174
1177
  ```ruby
1175
1178
  page.viewport_size = { width: 640, height: 480 }
@@ -27,7 +27,7 @@ This article introduces a way to separate environments into client (for executin
27
27
 
28
28
  ## Overview
29
29
 
30
- Playwrignt Ruby client is running on Alpine Linux. It just sends/receives JSON messages of Playwright-protocol via WebSocket.
30
+ Playwright Ruby client is running on Alpine Linux. It just sends/receives JSON messages of Playwright-protocol via WebSocket.
31
31
 
32
32
  Playwright server is running on a container of [official Docker image](https://hub.docker.com/_/microsoft-playwright). It just operates browsers in response to the JSON messages from WebSocket.
33
33
 
@@ -69,7 +69,7 @@ end
69
69
 
70
70
  ### Server code
71
71
 
72
- With the [official Docker image](https://hub.docker.com/_/microsoft-playwright) or in the local development environment with Node.js, just execute `npx playwright install && npx playwright run-server $PORT`. (`$PORT` is a port number of the server)
72
+ With the [official Docker image](https://hub.docker.com/_/microsoft-playwright) or in the local development environment with Node.js, just execute `npx playwright install && npx playwright run-server --port $PORT --path /ws`. (`$PORT` is a port number of the server)
73
73
 
74
74
  If custom Docker image is preferred, build it as follows:
75
75
 
@@ -80,7 +80,7 @@ WORKDIR /root
80
80
  RUN npm install playwright@1.12.3 && ./node_modules/.bin/playwright install
81
81
 
82
82
  ENV PORT 8888
83
- CMD ["./node_modules/.bin/playwright", "run-server", "$PORT"]
83
+ CMD ["./node_modules/.bin/playwright", "run-server", "--port", "$PORT", "--path", "/ws"]
84
84
  ```
85
85
 
86
86
  ## Browser server/client
@@ -100,7 +100,7 @@ end
100
100
 
101
101
  ### Server code
102
102
 
103
- For instant use, `npx playwright launch-server chromium` generates a WebSocket endpoint URL with a random path.
103
+ For instant use, `npx playwright launch-server --browser chromium` generates a WebSocket endpoint URL with a random path.
104
104
 
105
105
  More customization can be done by implementing JavaScript server like below:
106
106
 
@@ -138,7 +138,7 @@ DEBUG=1 bundle exec ruby some-automation-with-playwright.rb
138
138
  Just set an environment variable `DEBUG=pw:*` or `DEBUG=pw:server`
139
139
 
140
140
  ```
141
- DEBUG=pw:* npx playwright run-server 8888
141
+ DEBUG=pw:* npx playwright run-server --port 8888 --path /ws
142
142
  ```
143
143
 
144
144
  See [the official documentation](https://playwright.dev/docs/debug/#verbose-api-logs) for details.
@@ -417,6 +417,7 @@
417
417
  * focus
418
418
  * frame_locator
419
419
  * get_attribute
420
+ * highlight
420
421
  * hover
421
422
  * inner_html
422
423
  * inner_text
@@ -4,8 +4,8 @@ module Playwright
4
4
  @timeout_settings = TimeoutSettings.new
5
5
  end
6
6
 
7
- def devices
8
- resp = @channel.send_message_to_server('devices')
7
+ def devices(port: nil)
8
+ resp = @channel.send_message_to_server('devices', port: port)
9
9
  resp.map { |device| ChannelOwners::AndroidDevice.from(device) }
10
10
  end
11
11
  end
@@ -281,6 +281,8 @@ module Playwright
281
281
  end
282
282
 
283
283
  def screenshot(
284
+ animations: nil,
285
+ mask: nil,
284
286
  omitBackground: nil,
285
287
  path: nil,
286
288
  quality: nil,
@@ -288,12 +290,18 @@ module Playwright
288
290
  type: nil)
289
291
 
290
292
  params = {
293
+ animations: animations,
291
294
  omitBackground: omitBackground,
292
295
  path: path,
293
296
  quality: quality,
294
297
  timeout: timeout,
295
298
  type: type,
296
299
  }.compact
300
+ if mask.is_a?(Enumerable)
301
+ params[:mask] = mask.map do |locator|
302
+ locator.send(:to_protocol)
303
+ end
304
+ end
297
305
  encoded_binary = @channel.send_message_to_server('screenshot', params)
298
306
  decoded_binary = Base64.strict_decode64(encoded_binary)
299
307
  if path
@@ -615,6 +615,10 @@ module Playwright
615
615
  @channel.send_message_to_server('title')
616
616
  end
617
617
 
618
+ def highlight(selector)
619
+ @channel.send_message_to_server('highlight', selector: selector)
620
+ end
621
+
618
622
  # @param page [Page]
619
623
  # @note This method should be used internally. Accessed via .send method, so keep private!
620
624
  private def update_page_from_page(page)
@@ -414,6 +414,8 @@ module Playwright
414
414
  fullPage: nil,
415
415
  clip: nil,
416
416
  omitBackground: nil,
417
+ animations: nil,
418
+ mask: nil,
417
419
  timeout: nil)
418
420
 
419
421
  params = {
@@ -422,8 +424,14 @@ module Playwright
422
424
  fullPage: fullPage,
423
425
  clip: clip,
424
426
  omitBackground: omitBackground,
427
+ animations: animations,
425
428
  timeout: timeout,
426
429
  }.compact
430
+ if mask.is_a?(Enumerable)
431
+ params[:mask] = mask.map do |locator|
432
+ locator.send(:to_protocol)
433
+ end
434
+ end
427
435
  encoded_binary = @channel.send_message_to_server('screenshot', params)
428
436
  decoded_binary = Base64.strict_decode64(encoded_binary)
429
437
  if path
@@ -55,6 +55,13 @@ module Playwright
55
55
  "Locator@#{@selector}"
56
56
  end
57
57
 
58
+ private def to_protocol
59
+ {
60
+ frame: @frame.channel,
61
+ selector: @selector,
62
+ }
63
+ end
64
+
58
65
  class DifferentFrameError < StandardError
59
66
  def initialize
60
67
  super('Inner "has" locator must belong to the same frame.')
@@ -306,6 +313,8 @@ module Playwright
306
313
  end
307
314
 
308
315
  def screenshot(
316
+ animations: nil,
317
+ mask: nil,
309
318
  omitBackground: nil,
310
319
  path: nil,
311
320
  quality: nil,
@@ -313,6 +322,8 @@ module Playwright
313
322
  type: nil)
314
323
  with_element(timeout: timeout) do |handle, options|
315
324
  handle.screenshot(
325
+ animations: animations,
326
+ mask: mask,
316
327
  omitBackground: omitBackground,
317
328
  path: path,
318
329
  quality: quality,
@@ -416,5 +427,9 @@ module Playwright
416
427
  def all_text_contents
417
428
  @frame.eval_on_selector_all(@selector, "ee => ee.map(e => e.textContent || '')")
418
429
  end
430
+
431
+ def highlight
432
+ @frame.highlight(@selector)
433
+ end
419
434
  end
420
435
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playwright
4
- VERSION = '1.19.1'
5
- COMPATIBLE_PLAYWRIGHT_VERSION = '1.19.2'
4
+ VERSION = '1.20.0'
5
+ COMPATIBLE_PLAYWRIGHT_VERSION = '1.20.0'
6
6
  end
@@ -26,8 +26,8 @@ module Playwright
26
26
  class Android < PlaywrightApi
27
27
 
28
28
  # Returns the list of detected Android devices.
29
- def devices
30
- wrap_impl(@impl.devices)
29
+ def devices(port: nil)
30
+ wrap_impl(@impl.devices(port: unwrap_impl(port)))
31
31
  end
32
32
 
33
33
  # This setting will change the default maximum time for all the methods accepting `timeout` option.
@@ -346,12 +346,14 @@ module Playwright
346
346
  # This method waits for the [actionability](./actionability.md) checks, then scrolls element into view before taking a
347
347
  # screenshot. If the element is detached from DOM, the method throws an error.
348
348
  def screenshot(
349
+ animations: nil,
350
+ mask: nil,
349
351
  omitBackground: nil,
350
352
  path: nil,
351
353
  quality: nil,
352
354
  timeout: nil,
353
355
  type: nil)
354
- wrap_impl(@impl.screenshot(omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
356
+ wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
355
357
  end
356
358
 
357
359
  # This method waits for [actionability](./actionability.md) checks, then tries to scroll element into view, unless it is
@@ -788,6 +788,11 @@ module Playwright
788
788
  wrap_impl(@impl.detached=(unwrap_impl(req)))
789
789
  end
790
790
 
791
+ # @nodoc
792
+ def highlight(selector)
793
+ wrap_impl(@impl.highlight(unwrap_impl(selector)))
794
+ end
795
+
791
796
  # -- inherited from EventEmitter --
792
797
  # @nodoc
793
798
  def off(event, callback)
@@ -250,6 +250,12 @@ module Playwright
250
250
  wrap_impl(@impl.get_attribute(unwrap_impl(name), timeout: unwrap_impl(timeout)))
251
251
  end
252
252
 
253
+ # Highlight the corresponding element(s) on the screen. Useful for debugging, don't commit the code that uses
254
+ # [`method: Locator.highlight`].
255
+ def highlight
256
+ wrap_impl(@impl.highlight)
257
+ end
258
+
253
259
  # This method hovers over the element by performing the following steps:
254
260
  # 1. Wait for [actionability](./actionability.md) checks on the element, unless `force` option is set.
255
261
  # 1. Scroll the element into view if needed.
@@ -361,12 +367,14 @@ module Playwright
361
367
  # This method waits for the [actionability](./actionability.md) checks, then scrolls element into view before taking a
362
368
  # screenshot. If the element is detached from DOM, the method throws an error.
363
369
  def screenshot(
370
+ animations: nil,
371
+ mask: nil,
364
372
  omitBackground: nil,
365
373
  path: nil,
366
374
  quality: nil,
367
375
  timeout: nil,
368
376
  type: nil)
369
- wrap_impl(@impl.screenshot(omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
377
+ wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
370
378
  end
371
379
 
372
380
  # This method waits for [actionability](./actionability.md) checks, then tries to scroll element into view, unless it is
@@ -891,14 +891,16 @@ module Playwright
891
891
 
892
892
  # Returns the buffer with the captured screenshot.
893
893
  def screenshot(
894
+ animations: nil,
894
895
  clip: nil,
895
896
  fullPage: nil,
897
+ mask: nil,
896
898
  omitBackground: nil,
897
899
  path: nil,
898
900
  quality: nil,
899
901
  timeout: nil,
900
902
  type: nil)
901
- wrap_impl(@impl.screenshot(clip: unwrap_impl(clip), fullPage: unwrap_impl(fullPage), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
903
+ wrap_impl(@impl.screenshot(animations: unwrap_impl(animations), clip: unwrap_impl(clip), fullPage: unwrap_impl(fullPage), mask: unwrap_impl(mask), omitBackground: unwrap_impl(omitBackground), path: unwrap_impl(path), quality: unwrap_impl(quality), timeout: unwrap_impl(timeout), type: unwrap_impl(type)))
902
904
  end
903
905
 
904
906
  # This method waits for an element matching `selector`, waits for [actionability](./actionability.md) checks, waits until
@@ -1016,9 +1018,10 @@ module Playwright
1016
1018
  # In the case of multiple pages in a single browser, each page can have its own viewport size. However,
1017
1019
  # [`method: Browser.newContext`] allows to set viewport size (and more) for all pages in the context at once.
1018
1020
  #
1019
- # `page.setViewportSize` will resize the page. A lot of websites don't expect phones to change size, so you should set the
1020
- # viewport size before navigating to the page. [`method: Page.setViewportSize`] will also reset `screen` size, use
1021
- # [`method: Browser.newContext`] with `screen` and `viewport` parameters if you need better control of these properties.
1021
+ # [`method: Page.setViewportSize`] will resize the page. A lot of websites don't expect phones to change size, so you
1022
+ # should set the viewport size before navigating to the page. [`method: Page.setViewportSize`] will also reset `screen`
1023
+ # size, use [`method: Browser.newContext`] with `screen` and `viewport` parameters if you need better control of these
1024
+ # properties.
1022
1025
  #
1023
1026
  # ```python sync
1024
1027
  # page = browser.new_page()
@@ -1387,13 +1390,13 @@ module Playwright
1387
1390
  end
1388
1391
 
1389
1392
  # @nodoc
1390
- def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1391
- wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1393
+ def start_js_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1394
+ wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1392
1395
  end
1393
1396
 
1394
1397
  # @nodoc
1395
- def stop_css_coverage
1396
- wrap_impl(@impl.stop_css_coverage)
1398
+ def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1399
+ wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1397
1400
  end
1398
1401
 
1399
1402
  # @nodoc
@@ -1402,8 +1405,8 @@ module Playwright
1402
1405
  end
1403
1406
 
1404
1407
  # @nodoc
1405
- def start_js_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1406
- wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1408
+ def stop_css_coverage
1409
+ wrap_impl(@impl.stop_css_coverage)
1407
1410
  end
1408
1411
 
1409
1412
  # @nodoc
@@ -44,13 +44,13 @@ module Playwright
44
44
  end
45
45
 
46
46
  # @nodoc
47
- def page=(req)
48
- wrap_impl(@impl.page=(unwrap_impl(req)))
47
+ def context=(req)
48
+ wrap_impl(@impl.context=(unwrap_impl(req)))
49
49
  end
50
50
 
51
51
  # @nodoc
52
- def context=(req)
53
- wrap_impl(@impl.context=(unwrap_impl(req)))
52
+ def page=(req)
53
+ wrap_impl(@impl.page=(unwrap_impl(req)))
54
54
  end
55
55
 
56
56
  # -- inherited from EventEmitter --
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.19.1
4
+ version: 1.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-08 00:00:00.000000000 Z
11
+ date: 2022-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -396,5 +396,5 @@ requirements: []
396
396
  rubygems_version: 3.3.7
397
397
  signing_key:
398
398
  specification_version: 4
399
- summary: The Ruby binding of playwright driver 1.19.2
399
+ summary: The Ruby binding of playwright driver 1.20.0
400
400
  test_files: []