playwright-ruby-client 1.14.beta2 → 1.15.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +10 -14
  3. data/documentation/docs/api/accessibility.md +16 -17
  4. data/documentation/docs/api/browser.md +4 -0
  5. data/documentation/docs/api/browser_context.md +5 -1
  6. data/documentation/docs/api/browser_type.md +2 -0
  7. data/documentation/docs/api/element_handle.md +30 -5
  8. data/documentation/docs/api/experimental/android.md +15 -2
  9. data/documentation/docs/api/experimental/android_device.md +2 -0
  10. data/documentation/docs/api/frame.md +86 -104
  11. data/documentation/docs/api/locator.md +69 -40
  12. data/documentation/docs/api/mouse.md +3 -4
  13. data/documentation/docs/api/page.md +38 -7
  14. data/documentation/docs/api/request.md +42 -20
  15. data/documentation/docs/api/response.md +18 -1
  16. data/documentation/docs/api/selectors.md +29 -3
  17. data/documentation/docs/api/tracing.md +51 -16
  18. data/documentation/docs/api/worker.md +12 -11
  19. data/documentation/docs/article/getting_started.md +10 -1
  20. data/documentation/docs/article/guides/download_playwright_driver.md +9 -0
  21. data/documentation/docs/article/guides/inspector.md +1 -1
  22. data/documentation/docs/article/guides/playwright_on_alpine_linux.md +56 -3
  23. data/documentation/docs/article/guides/rails_integration.md +4 -2
  24. data/documentation/docs/article/guides/rails_integration_with_null_driver.md +86 -0
  25. data/documentation/docs/article/guides/recording_video.md +1 -1
  26. data/documentation/docs/article/guides/semi_automation.md +2 -2
  27. data/documentation/docs/article/guides/use_storage_state.md +78 -0
  28. data/documentation/docs/include/api_coverage.md +11 -0
  29. data/documentation/docusaurus.config.js +1 -0
  30. data/documentation/package.json +2 -2
  31. data/documentation/src/pages/index.js +0 -1
  32. data/documentation/static/img/playwright-ruby-client.png +0 -0
  33. data/documentation/yarn.lock +625 -549
  34. data/lib/playwright/channel.rb +36 -2
  35. data/lib/playwright/channel_owners/artifact.rb +6 -2
  36. data/lib/playwright/channel_owners/browser.rb +4 -0
  37. data/lib/playwright/channel_owners/browser_context.rb +21 -14
  38. data/lib/playwright/channel_owners/browser_type.rb +0 -1
  39. data/lib/playwright/channel_owners/element_handle.rb +10 -2
  40. data/lib/playwright/channel_owners/frame.rb +8 -0
  41. data/lib/playwright/channel_owners/page.rb +20 -4
  42. data/lib/playwright/channel_owners/playwright.rb +9 -0
  43. data/lib/playwright/channel_owners/request.rb +46 -25
  44. data/lib/playwright/channel_owners/response.rb +41 -5
  45. data/lib/playwright/connection.rb +8 -11
  46. data/lib/playwright/http_headers.rb +9 -4
  47. data/lib/playwright/locator_impl.rb +11 -3
  48. data/lib/playwright/{route_handler_entry.rb → route_handler.rb} +30 -2
  49. data/lib/playwright/tracing_impl.rb +18 -7
  50. data/lib/playwright/transport.rb +2 -0
  51. data/lib/playwright/utils.rb +8 -1
  52. data/lib/playwright/version.rb +2 -2
  53. data/lib/playwright/web_socket_transport.rb +2 -0
  54. data/lib/playwright.rb +45 -5
  55. data/lib/playwright_api/android.rb +21 -8
  56. data/lib/playwright_api/android_device.rb +11 -9
  57. data/lib/playwright_api/browser.rb +12 -8
  58. data/lib/playwright_api/browser_context.rb +12 -8
  59. data/lib/playwright_api/browser_type.rb +9 -7
  60. data/lib/playwright_api/cdp_session.rb +6 -6
  61. data/lib/playwright_api/console_message.rb +6 -6
  62. data/lib/playwright_api/dialog.rb +6 -6
  63. data/lib/playwright_api/element_handle.rb +31 -8
  64. data/lib/playwright_api/frame.rb +35 -12
  65. data/lib/playwright_api/js_handle.rb +6 -6
  66. data/lib/playwright_api/locator.rb +41 -2
  67. data/lib/playwright_api/page.rb +43 -15
  68. data/lib/playwright_api/playwright.rb +6 -6
  69. data/lib/playwright_api/request.rb +29 -7
  70. data/lib/playwright_api/response.rb +23 -7
  71. data/lib/playwright_api/route.rb +6 -6
  72. data/lib/playwright_api/selectors.rb +38 -7
  73. data/lib/playwright_api/tracing.rb +33 -4
  74. data/lib/playwright_api/web_socket.rb +6 -6
  75. data/lib/playwright_api/worker.rb +8 -8
  76. metadata +7 -4
@@ -93,20 +93,20 @@ module Playwright
93
93
 
94
94
  # -- inherited from EventEmitter --
95
95
  # @nodoc
96
- def once(event, callback)
97
- event_emitter_proxy.once(event, callback)
96
+ def off(event, callback)
97
+ event_emitter_proxy.off(event, callback)
98
98
  end
99
99
 
100
100
  # -- inherited from EventEmitter --
101
101
  # @nodoc
102
- def on(event, callback)
103
- event_emitter_proxy.on(event, callback)
102
+ def once(event, callback)
103
+ event_emitter_proxy.once(event, callback)
104
104
  end
105
105
 
106
106
  # -- inherited from EventEmitter --
107
107
  # @nodoc
108
- def off(event, callback)
109
- event_emitter_proxy.off(event, callback)
108
+ def on(event, callback)
109
+ event_emitter_proxy.on(event, callback)
110
110
  end
111
111
 
112
112
  private def event_emitter_proxy
@@ -14,6 +14,11 @@ module Playwright
14
14
  # request is issued to a redirected url.
15
15
  class Request < PlaywrightApi
16
16
 
17
+ # An object with all the request HTTP headers associated with this request. The header names are lower-cased.
18
+ def all_headers
19
+ wrap_impl(@impl.all_headers)
20
+ end
21
+
17
22
  # The method returns `null` unless this request has failed, as reported by `requestfailed` event.
18
23
  #
19
24
  # Example of logging of all the failed requests:
@@ -30,11 +35,17 @@ module Playwright
30
35
  wrap_impl(@impl.frame)
31
36
  end
32
37
 
33
- # An object with HTTP headers associated with the request. All header names are lower-case.
38
+ # **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [`method: Request.allHeaders`] instead.
34
39
  def headers
35
40
  wrap_impl(@impl.headers)
36
41
  end
37
42
 
43
+ # An array with all the request HTTP headers associated with this request. Unlike [`method: Request.allHeaders`], header
44
+ # names are not lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
45
+ def headers_array
46
+ wrap_impl(@impl.headers_array)
47
+ end
48
+
38
49
  # Whether this request is driving frame's navigation.
39
50
  def navigation_request?
40
51
  wrap_impl(@impl.navigation_request?)
@@ -109,6 +120,12 @@ module Playwright
109
120
  wrap_impl(@impl.response)
110
121
  end
111
122
 
123
+ # Returns resource size information for given request. Requires the response to be finished via
124
+ # [`method: Response.finished`] to ensure the info is available.
125
+ def sizes
126
+ wrap_impl(@impl.sizes)
127
+ end
128
+
112
129
  # Returns resource timing information for given request. Most of the timing values become available upon the response,
113
130
  # `responseEnd` becomes available when request finishes. Find more information at
114
131
  # [Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).
@@ -128,22 +145,27 @@ module Playwright
128
145
  wrap_impl(@impl.url)
129
146
  end
130
147
 
148
+ # @nodoc
149
+ def parse_headers_as_array(serialized_headers, downcase)
150
+ wrap_impl(@impl.parse_headers_as_array(unwrap_impl(serialized_headers), unwrap_impl(downcase)))
151
+ end
152
+
131
153
  # -- inherited from EventEmitter --
132
154
  # @nodoc
133
- def once(event, callback)
134
- event_emitter_proxy.once(event, callback)
155
+ def off(event, callback)
156
+ event_emitter_proxy.off(event, callback)
135
157
  end
136
158
 
137
159
  # -- inherited from EventEmitter --
138
160
  # @nodoc
139
- def on(event, callback)
140
- event_emitter_proxy.on(event, callback)
161
+ def once(event, callback)
162
+ event_emitter_proxy.once(event, callback)
141
163
  end
142
164
 
143
165
  # -- inherited from EventEmitter --
144
166
  # @nodoc
145
- def off(event, callback)
146
- event_emitter_proxy.off(event, callback)
167
+ def on(event, callback)
168
+ event_emitter_proxy.on(event, callback)
147
169
  end
148
170
 
149
171
  private def event_emitter_proxy
@@ -2,6 +2,11 @@ module Playwright
2
2
  # `Response` class represents responses which are received by page.
3
3
  class Response < PlaywrightApi
4
4
 
5
+ # An object with all the response HTTP headers associated with this response.
6
+ def all_headers
7
+ wrap_impl(@impl.all_headers)
8
+ end
9
+
5
10
  # Returns the buffer with response body.
6
11
  def body
7
12
  wrap_impl(@impl.body)
@@ -17,11 +22,17 @@ module Playwright
17
22
  wrap_impl(@impl.frame)
18
23
  end
19
24
 
20
- # Returns the object with HTTP headers associated with the response. All header names are lower-case.
25
+ # **DEPRECATED** Incomplete list of headers as seen by the rendering engine. Use [`method: Response.allHeaders`] instead.
21
26
  def headers
22
27
  wrap_impl(@impl.headers)
23
28
  end
24
29
 
30
+ # An array with all the request HTTP headers associated with this response. Unlike [`method: Response.allHeaders`], header
31
+ # names are not lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
32
+ def headers_array
33
+ wrap_impl(@impl.headers_array)
34
+ end
35
+
25
36
  # Returns the JSON representation of response body.
26
37
  #
27
38
  # This method will throw if the response body is not parsable via `JSON.parse`.
@@ -74,22 +85,27 @@ module Playwright
74
85
  wrap_impl(@impl.ok?)
75
86
  end
76
87
 
88
+ # @nodoc
89
+ def parse_headers_as_array(serialized_headers, downcase)
90
+ wrap_impl(@impl.parse_headers_as_array(unwrap_impl(serialized_headers), unwrap_impl(downcase)))
91
+ end
92
+
77
93
  # -- inherited from EventEmitter --
78
94
  # @nodoc
79
- def once(event, callback)
80
- event_emitter_proxy.once(event, callback)
95
+ def off(event, callback)
96
+ event_emitter_proxy.off(event, callback)
81
97
  end
82
98
 
83
99
  # -- inherited from EventEmitter --
84
100
  # @nodoc
85
- def on(event, callback)
86
- event_emitter_proxy.on(event, callback)
101
+ def once(event, callback)
102
+ event_emitter_proxy.once(event, callback)
87
103
  end
88
104
 
89
105
  # -- inherited from EventEmitter --
90
106
  # @nodoc
91
- def off(event, callback)
92
- event_emitter_proxy.off(event, callback)
107
+ def on(event, callback)
108
+ event_emitter_proxy.on(event, callback)
93
109
  end
94
110
 
95
111
  private def event_emitter_proxy
@@ -58,20 +58,20 @@ module Playwright
58
58
 
59
59
  # -- inherited from EventEmitter --
60
60
  # @nodoc
61
- def once(event, callback)
62
- event_emitter_proxy.once(event, callback)
61
+ def off(event, callback)
62
+ event_emitter_proxy.off(event, callback)
63
63
  end
64
64
 
65
65
  # -- inherited from EventEmitter --
66
66
  # @nodoc
67
- def on(event, callback)
68
- event_emitter_proxy.on(event, callback)
67
+ def once(event, callback)
68
+ event_emitter_proxy.once(event, callback)
69
69
  end
70
70
 
71
71
  # -- inherited from EventEmitter --
72
72
  # @nodoc
73
- def off(event, callback)
74
- event_emitter_proxy.off(event, callback)
73
+ def on(event, callback)
74
+ event_emitter_proxy.on(event, callback)
75
75
  end
76
76
 
77
77
  private def event_emitter_proxy
@@ -6,7 +6,38 @@ module Playwright
6
6
  # An example of registering selector engine that queries elements based on a tag name:
7
7
  #
8
8
  # ```python sync
9
- # # FIXME: add snippet
9
+ # from playwright.sync_api import sync_playwright
10
+ #
11
+ # def run(playwright):
12
+ # tag_selector = """
13
+ # {
14
+ # // Returns the first element matching given selector in the root's subtree.
15
+ # query(root, selector) {
16
+ # return root.querySelector(selector);
17
+ # },
18
+ # // Returns all elements matching given selector in the root's subtree.
19
+ # queryAll(root, selector) {
20
+ # return Array.from(root.querySelectorAll(selector));
21
+ # }
22
+ # }"""
23
+ #
24
+ # # Register the engine. Selectors will be prefixed with "tag=".
25
+ # playwright.selectors.register("tag", tag_selector)
26
+ # browser = playwright.chromium.launch()
27
+ # page = browser.new_page()
28
+ # page.set_content('<div><button>Click me</button></div>')
29
+ #
30
+ # # Use the selector prefixed with its name.
31
+ # button = page.query_selector('tag=button')
32
+ # # Combine it with other selector engines.
33
+ # page.click('tag=div >> text="Click me"')
34
+ # # Can use it in any methods supporting selectors.
35
+ # button_count = page.eval_on_selector_all('tag=button', 'buttons => buttons.length')
36
+ # print(button_count)
37
+ # browser.close()
38
+ #
39
+ # with sync_playwright() as playwright:
40
+ # run(playwright)
10
41
  # ```
11
42
  def register(name, contentScript: nil, path: nil, script: nil)
12
43
  wrap_impl(@impl.register(unwrap_impl(name), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path), script: unwrap_impl(script)))
@@ -14,20 +45,20 @@ module Playwright
14
45
 
15
46
  # -- inherited from EventEmitter --
16
47
  # @nodoc
17
- def once(event, callback)
18
- event_emitter_proxy.once(event, callback)
48
+ def off(event, callback)
49
+ event_emitter_proxy.off(event, callback)
19
50
  end
20
51
 
21
52
  # -- inherited from EventEmitter --
22
53
  # @nodoc
23
- def on(event, callback)
24
- event_emitter_proxy.on(event, callback)
54
+ def once(event, callback)
55
+ event_emitter_proxy.once(event, callback)
25
56
  end
26
57
 
27
58
  # -- inherited from EventEmitter --
28
59
  # @nodoc
29
- def off(event, callback)
30
- event_emitter_proxy.off(event, callback)
60
+ def on(event, callback)
61
+ event_emitter_proxy.on(event, callback)
31
62
  end
32
63
 
33
64
  private def event_emitter_proxy
@@ -1,13 +1,14 @@
1
1
  module Playwright
2
- # API for collecting and saving Playwright traces. Playwright traces can be opened using the Playwright CLI after
3
- # Playwright script runs.
2
+ # API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](./trace-viewer.md)
3
+ # after Playwright script runs.
4
4
  #
5
- # Start with specifying the folder traces will be stored in:
5
+ # Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
6
6
  #
7
7
  # ```python sync
8
8
  # browser = chromium.launch()
9
9
  # context = browser.new_context()
10
10
  # context.tracing.start(screenshots=True, snapshots=True)
11
+ # page = context.new_page()
11
12
  # page.goto("https://playwright.dev")
12
13
  # context.tracing.stop(path = "trace.zip")
13
14
  # ```
@@ -17,17 +18,45 @@ module Playwright
17
18
  #
18
19
  # ```python sync
19
20
  # context.tracing.start(name="trace", screenshots=True, snapshots=True)
21
+ # page = context.new_page()
20
22
  # page.goto("https://playwright.dev")
21
- # context.tracing.stop()
22
23
  # context.tracing.stop(path = "trace.zip")
23
24
  # ```
24
25
  def start(name: nil, screenshots: nil, snapshots: nil)
25
26
  wrap_impl(@impl.start(name: unwrap_impl(name), screenshots: unwrap_impl(screenshots), snapshots: unwrap_impl(snapshots)))
26
27
  end
27
28
 
29
+ # Start a new trace chunk. If you'd like to record multiple traces on the same `BrowserContext`, use
30
+ # [`method: Tracing.start`] once, and then create multiple trace chunks with [`method: Tracing.startChunk`] and
31
+ # [`method: Tracing.stopChunk`].
32
+ #
33
+ # ```python sync
34
+ # context.tracing.start(name="trace", screenshots=True, snapshots=True)
35
+ # page = context.new_page()
36
+ # page.goto("https://playwright.dev")
37
+ #
38
+ # context.tracing.start_chunk()
39
+ # page.click("text=Get Started")
40
+ # # Everything between start_chunk and stop_chunk will be recorded in the trace.
41
+ # context.tracing.stop_chunk(path = "trace1.zip")
42
+ #
43
+ # context.tracing.start_chunk()
44
+ # page.goto("http://example.com")
45
+ # # Save a second trace file with different actions.
46
+ # context.tracing.stop_chunk(path = "trace2.zip")
47
+ # ```
48
+ def start_chunk
49
+ wrap_impl(@impl.start_chunk)
50
+ end
51
+
28
52
  # Stop tracing.
29
53
  def stop(path: nil)
30
54
  wrap_impl(@impl.stop(path: unwrap_impl(path)))
31
55
  end
56
+
57
+ # Stop the trace chunk. See [`method: Tracing.startChunk`] for more details about multiple trace chunks.
58
+ def stop_chunk(path: nil)
59
+ wrap_impl(@impl.stop_chunk(path: unwrap_impl(path)))
60
+ end
32
61
  end
33
62
  end
@@ -29,20 +29,20 @@ module Playwright
29
29
 
30
30
  # -- inherited from EventEmitter --
31
31
  # @nodoc
32
- def once(event, callback)
33
- event_emitter_proxy.once(event, callback)
32
+ def off(event, callback)
33
+ event_emitter_proxy.off(event, callback)
34
34
  end
35
35
 
36
36
  # -- inherited from EventEmitter --
37
37
  # @nodoc
38
- def on(event, callback)
39
- event_emitter_proxy.on(event, callback)
38
+ def once(event, callback)
39
+ event_emitter_proxy.once(event, callback)
40
40
  end
41
41
 
42
42
  # -- inherited from EventEmitter --
43
43
  # @nodoc
44
- def off(event, callback)
45
- event_emitter_proxy.off(event, callback)
44
+ def on(event, callback)
45
+ event_emitter_proxy.on(event, callback)
46
46
  end
47
47
 
48
48
  private def event_emitter_proxy
@@ -43,14 +43,20 @@ module Playwright
43
43
  wrap_impl(@impl.url)
44
44
  end
45
45
 
46
+ # @nodoc
47
+ def page=(req)
48
+ wrap_impl(@impl.page=(unwrap_impl(req)))
49
+ end
50
+
46
51
  # @nodoc
47
52
  def context=(req)
48
53
  wrap_impl(@impl.context=(unwrap_impl(req)))
49
54
  end
50
55
 
56
+ # -- inherited from EventEmitter --
51
57
  # @nodoc
52
- def page=(req)
53
- wrap_impl(@impl.page=(unwrap_impl(req)))
58
+ def off(event, callback)
59
+ event_emitter_proxy.off(event, callback)
54
60
  end
55
61
 
56
62
  # -- inherited from EventEmitter --
@@ -65,12 +71,6 @@ module Playwright
65
71
  event_emitter_proxy.on(event, callback)
66
72
  end
67
73
 
68
- # -- inherited from EventEmitter --
69
- # @nodoc
70
- def off(event, callback)
71
- event_emitter_proxy.off(event, callback)
72
- end
73
-
74
74
  private def event_emitter_proxy
75
75
  @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
76
76
  end
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.14.beta2
4
+ version: 1.15.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-06 00:00:00.000000000 Z
11
+ date: 2021-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -248,8 +248,10 @@ files:
248
248
  - documentation/docs/article/guides/launch_browser.md
249
249
  - documentation/docs/article/guides/playwright_on_alpine_linux.md
250
250
  - documentation/docs/article/guides/rails_integration.md
251
+ - documentation/docs/article/guides/rails_integration_with_null_driver.md
251
252
  - documentation/docs/article/guides/recording_video.md
252
253
  - documentation/docs/article/guides/semi_automation.md
254
+ - documentation/docs/article/guides/use_storage_state.md
253
255
  - documentation/docs/include/api_coverage.md
254
256
  - documentation/docusaurus.config.js
255
257
  - documentation/package.json
@@ -262,6 +264,7 @@ files:
262
264
  - documentation/src/pages/markdown-page.md
263
265
  - documentation/static/.nojekyll
264
266
  - documentation/static/img/playwright-logo.svg
267
+ - documentation/static/img/playwright-ruby-client.png
265
268
  - documentation/static/img/undraw_dropdown_menu.svg
266
269
  - documentation/static/img/undraw_web_development.svg
267
270
  - documentation/static/img/undraw_windows.svg
@@ -312,7 +315,7 @@ files:
312
315
  - lib/playwright/locator_impl.rb
313
316
  - lib/playwright/mouse_impl.rb
314
317
  - lib/playwright/playwright_api.rb
315
- - lib/playwright/route_handler_entry.rb
318
+ - lib/playwright/route_handler.rb
316
319
  - lib/playwright/select_option_values.rb
317
320
  - lib/playwright/timeout_settings.rb
318
321
  - lib/playwright/touchscreen_impl.rb
@@ -378,5 +381,5 @@ requirements: []
378
381
  rubygems_version: 3.2.22
379
382
  signing_key:
380
383
  specification_version: 4
381
- summary: The Ruby binding of playwright driver 1.14.0
384
+ summary: The Ruby binding of playwright driver 1.15.0
382
385
  test_files: []