playwright-ruby-client 1.28.1 → 1.29.0

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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/accessibility.md +9 -14
  3. data/documentation/docs/api/api_request_context.md +44 -41
  4. data/documentation/docs/api/api_response.md +13 -3
  5. data/documentation/docs/api/browser.md +24 -23
  6. data/documentation/docs/api/browser_context.md +71 -45
  7. data/documentation/docs/api/browser_type.md +21 -14
  8. data/documentation/docs/api/cdp_session.md +3 -5
  9. data/documentation/docs/api/console_message.md +7 -4
  10. data/documentation/docs/api/dialog.md +9 -5
  11. data/documentation/docs/api/download.md +19 -11
  12. data/documentation/docs/api/element_handle.md +125 -116
  13. data/documentation/docs/api/experimental/android.md +4 -5
  14. data/documentation/docs/api/experimental/android_device.md +11 -2
  15. data/documentation/docs/api/experimental/android_input.md +5 -0
  16. data/documentation/docs/api/file_chooser.md +6 -3
  17. data/documentation/docs/api/frame.md +182 -171
  18. data/documentation/docs/api/frame_locator.md +27 -38
  19. data/documentation/docs/api/js_handle.md +16 -10
  20. data/documentation/docs/api/keyboard.md +29 -16
  21. data/documentation/docs/api/locator.md +189 -140
  22. data/documentation/docs/api/mouse.md +9 -4
  23. data/documentation/docs/api/page.md +304 -289
  24. data/documentation/docs/api/playwright.md +8 -5
  25. data/documentation/docs/api/request.md +34 -15
  26. data/documentation/docs/api/response.md +27 -10
  27. data/documentation/docs/api/route.md +44 -12
  28. data/documentation/docs/api/selectors.md +5 -3
  29. data/documentation/docs/api/touchscreen.md +2 -0
  30. data/documentation/docs/api/tracing.md +11 -11
  31. data/documentation/docs/api/web_socket.md +9 -4
  32. data/documentation/docs/api/worker.md +12 -11
  33. data/documentation/docs/include/api_coverage.md +2 -0
  34. data/lib/playwright/channel_owners/api_request_context.rb +37 -2
  35. data/lib/playwright/channel_owners/browser_context.rb +22 -26
  36. data/lib/playwright/channel_owners/page.rb +35 -25
  37. data/lib/playwright/channel_owners/route.rb +28 -8
  38. data/lib/playwright/event_emitter.rb +6 -1
  39. data/lib/playwright/locator_impl.rb +8 -0
  40. data/lib/playwright/select_option_values.rb +2 -0
  41. data/lib/playwright/version.rb +2 -2
  42. data/lib/playwright_api/accessibility.rb +9 -13
  43. data/lib/playwright_api/android.rb +8 -6
  44. data/lib/playwright_api/android_device.rb +32 -7
  45. data/lib/playwright_api/android_input.rb +5 -0
  46. data/lib/playwright_api/android_socket.rb +4 -2
  47. data/lib/playwright_api/android_web_view.rb +5 -2
  48. data/lib/playwright_api/api_request.rb +6 -3
  49. data/lib/playwright_api/api_request_context.rb +46 -36
  50. data/lib/playwright_api/api_response.rb +13 -2
  51. data/lib/playwright_api/browser.rb +24 -16
  52. data/lib/playwright_api/browser_context.rb +76 -39
  53. data/lib/playwright_api/browser_type.rb +23 -13
  54. data/lib/playwright_api/cdp_session.rb +3 -4
  55. data/lib/playwright_api/console_message.rb +7 -2
  56. data/lib/playwright_api/dialog.rb +8 -4
  57. data/lib/playwright_api/download.rb +19 -9
  58. data/lib/playwright_api/element_handle.rb +116 -93
  59. data/lib/playwright_api/file_chooser.rb +6 -1
  60. data/lib/playwright_api/frame.rb +180 -135
  61. data/lib/playwright_api/frame_locator.rb +29 -32
  62. data/lib/playwright_api/js_handle.rb +16 -6
  63. data/lib/playwright_api/keyboard.rb +29 -14
  64. data/lib/playwright_api/locator.rb +183 -112
  65. data/lib/playwright_api/mouse.rb +9 -2
  66. data/lib/playwright_api/page.rb +301 -253
  67. data/lib/playwright_api/playwright.rb +11 -4
  68. data/lib/playwright_api/request.rb +34 -7
  69. data/lib/playwright_api/response.rb +27 -10
  70. data/lib/playwright_api/route.rb +44 -11
  71. data/lib/playwright_api/selectors.rb +6 -1
  72. data/lib/playwright_api/touchscreen.rb +2 -0
  73. data/lib/playwright_api/tracing.rb +11 -5
  74. data/lib/playwright_api/web_socket.rb +9 -4
  75. data/lib/playwright_api/worker.rb +16 -13
  76. data/playwright.gemspec +1 -1
  77. metadata +7 -7
@@ -1,4 +1,5 @@
1
1
  module Playwright
2
+ #
2
3
  # Playwright module provides a method to launch a browser instance. The following is a typical example of using Playwright
3
4
  # to drive automation:
4
5
  #
@@ -18,11 +19,13 @@ module Playwright
18
19
  # ```
19
20
  class Playwright < PlaywrightApi
20
21
 
22
+ #
21
23
  # This object can be used to launch or connect to Chromium, returning instances of `Browser`.
22
24
  def chromium # property
23
25
  wrap_impl(@impl.chromium)
24
26
  end
25
27
 
28
+ #
26
29
  # Returns a dictionary of devices to be used with [`method: Browser.newContext`] or [`method: Browser.newPage`].
27
30
  #
28
31
  # ```python sync
@@ -45,29 +48,33 @@ module Playwright
45
48
  wrap_impl(@impl.devices)
46
49
  end
47
50
 
51
+ #
48
52
  # This object can be used to launch or connect to Firefox, returning instances of `Browser`.
49
53
  def firefox # property
50
54
  wrap_impl(@impl.firefox)
51
55
  end
52
56
 
57
+ #
53
58
  # Exposes API that can be used for the Web API testing.
54
59
  def request # property
55
60
  raise NotImplementedError.new('request is not implemented yet.')
56
61
  end
57
62
 
58
- # Selectors can be used to install custom selector engines. See [Working with selectors](../selectors.md) for more
59
- # information.
63
+ #
64
+ # Selectors can be used to install custom selector engines. See
65
+ # [extensibility](../extensibility.md) for more information.
60
66
  def selectors # property
61
67
  wrap_impl(@impl.selectors)
62
68
  end
63
69
 
70
+ #
64
71
  # This object can be used to launch or connect to WebKit, returning instances of `Browser`.
65
72
  def webkit # property
66
73
  wrap_impl(@impl.webkit)
67
74
  end
68
75
 
69
- # Terminates this instance of Playwright in case it was created bypassing the Python context manager. This is useful in
70
- # REPL applications.
76
+ #
77
+ # Terminates this instance of Playwright in case it was created bypassing the Python context manager. This is useful in REPL applications.
71
78
  #
72
79
  # ```py
73
80
  # >>> from playwright.sync_api import sync_playwright
@@ -1,4 +1,5 @@
1
1
  module Playwright
2
+ #
2
3
  # Whenever the page sends a request for a network resource the following sequence of events are emitted by `Page`:
3
4
  # - [`event: Page.request`] emitted when the request is issued by the page.
4
5
  # - [`event: Page.response`] emitted when/if the response status and headers are received for the request.
@@ -7,20 +8,24 @@ module Playwright
7
8
  # If request fails at some point, then instead of `'requestfinished'` event (and possibly instead of 'response' event),
8
9
  # the [`event: Page.requestFailed`] event is emitted.
9
10
  #
10
- # > NOTE: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will
11
- # complete with `'requestfinished'` event.
11
+ # **NOTE**: HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request will complete
12
+ # with `'requestfinished'` event.
12
13
  #
13
14
  # If request gets a 'redirect' response, the request is successfully finished with the `requestfinished` event, and a new
14
15
  # request is issued to a redirected url.
15
16
  class Request < PlaywrightApi
16
17
 
18
+ #
17
19
  # An object with all the request HTTP headers associated with this request. The header names are lower-cased.
18
20
  def all_headers
19
21
  wrap_impl(@impl.all_headers)
20
22
  end
21
23
 
24
+ #
22
25
  # The method returns `null` unless this request has failed, as reported by `requestfailed` event.
23
26
  #
27
+ # **Usage**
28
+ #
24
29
  # Example of logging of all the failed requests:
25
30
  #
26
31
  # ```py
@@ -30,49 +35,58 @@ module Playwright
30
35
  wrap_impl(@impl.failure)
31
36
  end
32
37
 
38
+ #
33
39
  # Returns the `Frame` that initiated this request.
34
40
  def frame
35
41
  wrap_impl(@impl.frame)
36
42
  end
37
43
 
38
- # An object with the request HTTP headers. The header names are lower-cased. Note that this method does not return
39
- # security-related headers, including cookie-related ones. You can use [`method: Request.allHeaders`] for complete list of
40
- # headers that include `cookie` information.
44
+ #
45
+ # An object with the request HTTP headers. The header names are lower-cased.
46
+ # Note that this method does not return security-related headers, including cookie-related ones.
47
+ # You can use [`method: Request.allHeaders`] for complete list of headers that include `cookie` information.
41
48
  def headers
42
49
  wrap_impl(@impl.headers)
43
50
  end
44
51
 
45
- # An array with all the request HTTP headers associated with this request. Unlike [`method: Request.allHeaders`], header
46
- # names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
52
+ #
53
+ # An array with all the request HTTP headers associated with this request. Unlike [`method: Request.allHeaders`], header names are NOT lower-cased.
54
+ # Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
47
55
  def headers_array
48
56
  wrap_impl(@impl.headers_array)
49
57
  end
50
58
 
59
+ #
51
60
  # Returns the value of the header matching the name. The name is case insensitive.
52
61
  def header_value(name)
53
62
  wrap_impl(@impl.header_value(unwrap_impl(name)))
54
63
  end
55
64
 
65
+ #
56
66
  # Whether this request is driving frame's navigation.
57
67
  def navigation_request?
58
68
  wrap_impl(@impl.navigation_request?)
59
69
  end
60
70
 
71
+ #
61
72
  # Request's method (GET, POST, etc.)
62
73
  def method
63
74
  wrap_impl(@impl.method)
64
75
  end
65
76
 
77
+ #
66
78
  # Request's post body, if any.
67
79
  def post_data
68
80
  wrap_impl(@impl.post_data)
69
81
  end
70
82
 
83
+ #
71
84
  # Request's post body in a binary form, if any.
72
85
  def post_data_buffer
73
86
  wrap_impl(@impl.post_data_buffer)
74
87
  end
75
88
 
89
+ #
76
90
  # Returns parsed request's body for `form-urlencoded` and JSON as a fallback if any.
77
91
  #
78
92
  # When the response is `application/x-www-form-urlencoded` then a key/value object of the values will be returned.
@@ -81,12 +95,15 @@ module Playwright
81
95
  wrap_impl(@impl.post_data_json)
82
96
  end
83
97
 
98
+ #
84
99
  # Request that was redirected by the server to this one, if any.
85
100
  #
86
101
  # When the server responds with a redirect, Playwright creates a new `Request` object. The two requests are connected by
87
102
  # `redirectedFrom()` and `redirectedTo()` methods. When multiple server redirects has happened, it is possible to
88
103
  # construct the whole redirect chain by repeatedly calling `redirectedFrom()`.
89
104
  #
105
+ # **Usage**
106
+ #
90
107
  # For example, if the website `http://example.com` redirects to `https://example.com`:
91
108
  #
92
109
  # ```python sync
@@ -104,8 +121,11 @@ module Playwright
104
121
  wrap_impl(@impl.redirected_from)
105
122
  end
106
123
 
124
+ #
107
125
  # New request issued by the browser if the server responded with redirect.
108
126
  #
127
+ # **Usage**
128
+ #
109
129
  # This method is the opposite of [`method: Request.redirectedFrom`]:
110
130
  #
111
131
  # ```py
@@ -115,6 +135,7 @@ module Playwright
115
135
  wrap_impl(@impl.redirected_to)
116
136
  end
117
137
 
138
+ #
118
139
  # Contains the request's resource type as it was perceived by the rendering engine. ResourceType will be one of the
119
140
  # following: `document`, `stylesheet`, `image`, `media`, `font`, `script`, `texttrack`, `xhr`, `fetch`, `eventsource`,
120
141
  # `websocket`, `manifest`, `other`.
@@ -122,20 +143,25 @@ module Playwright
122
143
  wrap_impl(@impl.resource_type)
123
144
  end
124
145
 
146
+ #
125
147
  # Returns the matching `Response` object, or `null` if the response was not received due to error.
126
148
  def response
127
149
  wrap_impl(@impl.response)
128
150
  end
129
151
 
152
+ #
130
153
  # Returns resource size information for given request.
131
154
  def sizes
132
155
  wrap_impl(@impl.sizes)
133
156
  end
134
157
 
158
+ #
135
159
  # Returns resource timing information for given request. Most of the timing values become available upon the response,
136
160
  # `responseEnd` becomes available when request finishes. Find more information at
137
161
  # [Resource Timing API](https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming).
138
162
  #
163
+ # **Usage**
164
+ #
139
165
  # ```python sync
140
166
  # with page.expect_event("requestfinished") as request_info:
141
167
  # page.goto("http://example.com")
@@ -146,6 +172,7 @@ module Playwright
146
172
  wrap_impl(@impl.timing)
147
173
  end
148
174
 
175
+ #
149
176
  # URL of the request.
150
177
  def url
151
178
  wrap_impl(@impl.url)
@@ -1,58 +1,67 @@
1
1
  module Playwright
2
+ #
2
3
  # `Response` class represents responses which are received by page.
3
4
  class Response < PlaywrightApi
4
5
 
6
+ #
5
7
  # An object with all the response HTTP headers associated with this response.
6
8
  def all_headers
7
9
  wrap_impl(@impl.all_headers)
8
10
  end
9
11
 
12
+ #
10
13
  # Returns the buffer with response body.
11
14
  def body
12
15
  wrap_impl(@impl.body)
13
16
  end
14
17
 
18
+ #
15
19
  # Waits for this response to finish, returns always `null`.
16
20
  def finished
17
21
  wrap_impl(@impl.finished)
18
22
  end
19
23
 
24
+ #
20
25
  # Returns the `Frame` that initiated this response.
21
26
  def frame
22
27
  wrap_impl(@impl.frame)
23
28
  end
24
29
 
25
- # Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via
26
- # [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).
30
+ #
31
+ # Indicates whether this Response was fulfilled by a Service Worker's Fetch Handler (i.e. via [FetchEvent.respondWith](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent/respondWith)).
27
32
  def from_service_worker
28
33
  wrap_impl(@impl.from_service_worker)
29
34
  end
30
35
 
31
- # An object with the response HTTP headers. The header names are lower-cased. Note that this method does not return
32
- # security-related headers, including cookie-related ones. You can use [`method: Response.allHeaders`] for complete list
33
- # of headers that include `cookie` information.
36
+ #
37
+ # An object with the response HTTP headers. The header names are lower-cased.
38
+ # Note that this method does not return security-related headers, including cookie-related ones.
39
+ # You can use [`method: Response.allHeaders`] for complete list of headers that include `cookie` information.
34
40
  def headers
35
41
  wrap_impl(@impl.headers)
36
42
  end
37
43
 
38
- # An array with all the request HTTP headers associated with this response. Unlike [`method: Response.allHeaders`], header
39
- # names are NOT lower-cased. Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
44
+ #
45
+ # An array with all the request HTTP headers associated with this response. Unlike [`method: Response.allHeaders`], header names are NOT lower-cased.
46
+ # Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
40
47
  def headers_array
41
48
  wrap_impl(@impl.headers_array)
42
49
  end
43
50
 
44
- # Returns the value of the header matching the name. The name is case insensitive. If multiple headers have the same name
45
- # (except `set-cookie`), they are returned as a list separated by `, `. For `set-cookie`, the `\n` separator is used. If
46
- # no headers are found, `null` is returned.
51
+ #
52
+ # Returns the value of the header matching the name. The name is case insensitive. If multiple headers have
53
+ # the same name (except `set-cookie`), they are returned as a list separated by `, `. For `set-cookie`, the `\n` separator is used. If no headers are found, `null` is returned.
47
54
  def header_value(name)
48
55
  wrap_impl(@impl.header_value(unwrap_impl(name)))
49
56
  end
50
57
 
58
+ #
51
59
  # Returns all values of the headers matching the name, for example `set-cookie`. The name is case insensitive.
52
60
  def header_values(name)
53
61
  wrap_impl(@impl.header_values(unwrap_impl(name)))
54
62
  end
55
63
 
64
+ #
56
65
  # Returns the JSON representation of response body.
57
66
  #
58
67
  # This method will throw if the response body is not parsable via `JSON.parse`.
@@ -60,41 +69,49 @@ module Playwright
60
69
  wrap_impl(@impl.json)
61
70
  end
62
71
 
72
+ #
63
73
  # Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
64
74
  def ok
65
75
  wrap_impl(@impl.ok)
66
76
  end
67
77
 
78
+ #
68
79
  # Returns the matching `Request` object.
69
80
  def request
70
81
  wrap_impl(@impl.request)
71
82
  end
72
83
 
84
+ #
73
85
  # Returns SSL and other security information.
74
86
  def security_details
75
87
  wrap_impl(@impl.security_details)
76
88
  end
77
89
 
90
+ #
78
91
  # Returns the IP address and port of the server.
79
92
  def server_addr
80
93
  wrap_impl(@impl.server_addr)
81
94
  end
82
95
 
96
+ #
83
97
  # Contains the status code of the response (e.g., 200 for a success).
84
98
  def status
85
99
  wrap_impl(@impl.status)
86
100
  end
87
101
 
102
+ #
88
103
  # Contains the status text of the response (e.g. usually an "OK" for a success).
89
104
  def status_text
90
105
  wrap_impl(@impl.status_text)
91
106
  end
92
107
 
108
+ #
93
109
  # Returns the text representation of response body.
94
110
  def text
95
111
  wrap_impl(@impl.text)
96
112
  end
97
113
 
114
+ #
98
115
  # Contains the URL of the response.
99
116
  def url
100
117
  wrap_impl(@impl.url)
@@ -1,17 +1,22 @@
1
1
  module Playwright
2
+ #
2
3
  # Whenever a network route is set up with [`method: Page.route`] or [`method: BrowserContext.route`], the `Route` object
3
4
  # allows to handle the route.
4
5
  #
5
6
  # Learn more about [networking](../network.md).
6
7
  class Route < PlaywrightApi
7
8
 
9
+ #
8
10
  # Aborts the route's request.
9
11
  def abort(errorCode: nil)
10
12
  wrap_impl(@impl.abort(errorCode: unwrap_impl(errorCode)))
11
13
  end
12
14
 
15
+ #
13
16
  # Continues route's request with optional overrides.
14
17
  #
18
+ # **Usage**
19
+ #
15
20
  # ```python sync
16
21
  # def handle(route, request):
17
22
  # # override headers
@@ -21,17 +26,20 @@ module Playwright
21
26
  # "bar": None # remove "bar" header
22
27
  # }
23
28
  # route.continue_(headers=headers)
24
- # }
29
+ #
25
30
  # page.route("**/*", handle)
26
31
  # ```
27
32
  def continue(headers: nil, method: nil, postData: nil, url: nil)
28
33
  wrap_impl(@impl.continue(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
29
34
  end
30
35
 
31
- # When several routes match the given pattern, they run in the order opposite to their registration. That way the last
32
- # registered route can always override all the previous ones. In the example below, request will be handled by the
33
- # bottom-most handler first, then it'll fall back to the previous one and in the end will be aborted by the first
34
- # registered route.
36
+ #
37
+ # When several routes match the given pattern, they run in the order opposite to their registration.
38
+ # That way the last registered route can always override all the previous ones. In the example below,
39
+ # request will be handled by the bottom-most handler first, then it'll fall back to the previous one and
40
+ # in the end will be aborted by the first registered route.
41
+ #
42
+ # **Usage**
35
43
  #
36
44
  # ```python sync
37
45
  # page.route("**/*", lambda route: route.abort()) # Runs last.
@@ -39,8 +47,9 @@ module Playwright
39
47
  # page.route("**/*", lambda route: route.fallback()) # Runs first.
40
48
  # ```
41
49
  #
42
- # Registering multiple routes is useful when you want separate handlers to handle different kinds of requests, for example
43
- # API calls vs page resources or GET requests vs POST requests as in the example below.
50
+ # Registering multiple routes is useful when you want separate handlers to
51
+ # handle different kinds of requests, for example API calls vs page resources or
52
+ # GET requests vs POST requests as in the example below.
44
53
  #
45
54
  # ```python sync
46
55
  # # Handle GET requests.
@@ -63,8 +72,8 @@ module Playwright
63
72
  # page.route("**/*", handle_post)
64
73
  # ```
65
74
  #
66
- # One can also modify request while falling back to the subsequent handler, that way intermediate route handler can modify
67
- # url, method, headers and postData of the request.
75
+ # One can also modify request while falling back to the subsequent handler, that way intermediate
76
+ # route handler can modify url, method, headers and postData of the request.
68
77
  #
69
78
  # ```python sync
70
79
  # def handle(route, request):
@@ -75,15 +84,37 @@ module Playwright
75
84
  # "bar": None # remove "bar" header
76
85
  # }
77
86
  # route.fallback(headers=headers)
78
- # }
87
+ #
79
88
  # page.route("**/*", handle)
80
89
  # ```
81
90
  def fallback(headers: nil, method: nil, postData: nil, url: nil)
82
91
  wrap_impl(@impl.fallback(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
83
92
  end
84
93
 
94
+ #
95
+ # Performs the request and fetches result without fulfilling it, so that the response
96
+ # could be modified and then fulfilled.
97
+ #
98
+ # **Usage**
99
+ #
100
+ # ```python sync
101
+ # def handle(route):
102
+ # response = route.fulfill()
103
+ # json = response.json()
104
+ # json["message"]["big_red_dog"] = []
105
+ # route.fulfill(response=response, json=json)
106
+ #
107
+ # page.route("https://dog.ceo/api/breeds/list/all", handle)
108
+ # ```
109
+ def fetch(headers: nil, method: nil, postData: nil, url: nil)
110
+ wrap_impl(@impl.fetch(headers: unwrap_impl(headers), method: unwrap_impl(method), postData: unwrap_impl(postData), url: unwrap_impl(url)))
111
+ end
112
+
113
+ #
85
114
  # Fulfills route's request with given response.
86
115
  #
116
+ # **Usage**
117
+ #
87
118
  # An example of fulfilling all requests with 404 responses:
88
119
  #
89
120
  # ```python sync
@@ -102,12 +133,14 @@ module Playwright
102
133
  body: nil,
103
134
  contentType: nil,
104
135
  headers: nil,
136
+ json: nil,
105
137
  path: nil,
106
138
  response: nil,
107
139
  status: nil)
108
- wrap_impl(@impl.fulfill(body: unwrap_impl(body), contentType: unwrap_impl(contentType), headers: unwrap_impl(headers), path: unwrap_impl(path), response: unwrap_impl(response), status: unwrap_impl(status)))
140
+ wrap_impl(@impl.fulfill(body: unwrap_impl(body), contentType: unwrap_impl(contentType), headers: unwrap_impl(headers), json: unwrap_impl(json), path: unwrap_impl(path), response: unwrap_impl(response), status: unwrap_impl(status)))
109
141
  end
110
142
 
143
+ #
111
144
  # A request to be routed.
112
145
  def request
113
146
  wrap_impl(@impl.request)
@@ -1,8 +1,12 @@
1
1
  module Playwright
2
- # Selectors can be used to install custom selector engines. See [Working with selectors](../selectors.md) for more
2
+ #
3
+ # Selectors can be used to install custom selector engines. See [extensibility](../extensibility.md) for more
3
4
  # information.
4
5
  class Selectors < PlaywrightApi
5
6
 
7
+ #
8
+ # **Usage**
9
+ #
6
10
  # An example of registering selector engine that queries elements based on a tag name:
7
11
  #
8
12
  # ```python sync
@@ -43,6 +47,7 @@ module Playwright
43
47
  wrap_impl(@impl.register(unwrap_impl(name), contentScript: unwrap_impl(contentScript), path: unwrap_impl(path), script: unwrap_impl(script)))
44
48
  end
45
49
 
50
+ #
46
51
  # Defines custom attribute name to be used in [`method: Page.getByTestId`]. `data-testid` is used by default.
47
52
  def set_test_id_attribute(attributeName)
48
53
  raise NotImplementedError.new('set_test_id_attribute is not implemented yet.')
@@ -1,8 +1,10 @@
1
1
  module Playwright
2
+ #
2
3
  # The Touchscreen class operates in main-frame CSS pixels relative to the top-left corner of the viewport. Methods on the
3
4
  # touchscreen can only be used in browser contexts that have been initialized with `hasTouch` set to true.
4
5
  class Touchscreen < PlaywrightApi
5
6
 
7
+ #
6
8
  # Dispatches a `touchstart` and `touchend` event with a single touch at the position (`x`,`y`).
7
9
  def tap_point(x, y)
8
10
  wrap_impl(@impl.tap_point(unwrap_impl(x), unwrap_impl(y)))
@@ -1,6 +1,6 @@
1
1
  module Playwright
2
- # API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](../trace-viewer.md)
3
- # after Playwright script runs.
2
+ #
3
+ # API for collecting and saving Playwright traces. Playwright traces can be opened in [Trace Viewer](../trace-viewer.md) after Playwright script runs.
4
4
  #
5
5
  # Start recording a trace before performing actions. At the end, stop tracing and save it to a file.
6
6
  #
@@ -14,8 +14,11 @@ module Playwright
14
14
  # ```
15
15
  class Tracing < PlaywrightApi
16
16
 
17
+ #
17
18
  # Start tracing.
18
19
  #
20
+ # **Usage**
21
+ #
19
22
  # ```python sync
20
23
  # context.tracing.start(name="trace", screenshots=True, snapshots=True)
21
24
  # page = context.new_page()
@@ -31,9 +34,10 @@ module Playwright
31
34
  wrap_impl(@impl.start(name: unwrap_impl(name), screenshots: unwrap_impl(screenshots), snapshots: unwrap_impl(snapshots), sources: unwrap_impl(sources), title: unwrap_impl(title)))
32
35
  end
33
36
 
34
- # Start a new trace chunk. If you'd like to record multiple traces on the same `BrowserContext`, use
35
- # [`method: Tracing.start`] once, and then create multiple trace chunks with [`method: Tracing.startChunk`] and
36
- # [`method: Tracing.stopChunk`].
37
+ #
38
+ # Start a new trace chunk. If you'd like to record multiple traces on the same `BrowserContext`, use [`method: Tracing.start`] once, and then create multiple trace chunks with [`method: Tracing.startChunk`] and [`method: Tracing.stopChunk`].
39
+ #
40
+ # **Usage**
37
41
  #
38
42
  # ```python sync
39
43
  # context.tracing.start(name="trace", screenshots=True, snapshots=True)
@@ -54,11 +58,13 @@ module Playwright
54
58
  wrap_impl(@impl.start_chunk(title: unwrap_impl(title)))
55
59
  end
56
60
 
61
+ #
57
62
  # Stop tracing.
58
63
  def stop(path: nil)
59
64
  wrap_impl(@impl.stop(path: unwrap_impl(path)))
60
65
  end
61
66
 
67
+ #
62
68
  # Stop the trace chunk. See [`method: Tracing.startChunk`] for more details about multiple trace chunks.
63
69
  def stop_chunk(path: nil)
64
70
  wrap_impl(@impl.stop_chunk(path: unwrap_impl(path)))
@@ -1,28 +1,33 @@
1
1
  module Playwright
2
+ #
2
3
  # The `WebSocket` class represents websocket connections in the page.
3
4
  class WebSocket < PlaywrightApi
4
5
 
6
+ #
5
7
  # Indicates that the web socket has been closed.
6
8
  def closed?
7
9
  wrap_impl(@impl.closed?)
8
10
  end
9
11
 
12
+ #
10
13
  # Contains the URL of the WebSocket.
11
14
  def url
12
15
  wrap_impl(@impl.url)
13
16
  end
14
17
 
18
+ #
15
19
  # Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy
16
20
  # value. Will throw an error if the webSocket is closed before the event is fired. Returns the event data value.
17
21
  def expect_event(event, predicate: nil, timeout: nil, &block)
18
22
  wrap_impl(@impl.expect_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
19
23
  end
20
24
 
21
- # > NOTE: In most cases, you should use [`method: WebSocket.waitForEvent`].
22
25
  #
23
- # Waits for given `event` to fire. If predicate is provided, it passes event's value into the `predicate` function and
24
- # waits for `predicate(event)` to return a truthy value. Will throw an error if the socket is closed before the `event` is
25
- # fired.
26
+ # **NOTE**: In most cases, you should use [`method: WebSocket.waitForEvent`].
27
+ #
28
+ # Waits for given `event` to fire. If predicate is provided, it passes
29
+ # event's value into the `predicate` function and waits for `predicate(event)` to return a truthy value.
30
+ # Will throw an error if the socket is closed before the `event` is fired.
26
31
  def wait_for_event(event, predicate: nil, timeout: nil, &block)
27
32
  wrap_impl(@impl.wait_for_event(unwrap_impl(event), predicate: unwrap_impl(predicate), timeout: unwrap_impl(timeout), &wrap_block_call(block)))
28
33
  end
@@ -1,4 +1,5 @@
1
1
  module Playwright
2
+ #
2
3
  # The Worker class represents a [WebWorker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). `worker`
3
4
  # event is emitted on the page object to signal a worker creation. `close` event is emitted on the worker object when the
4
5
  # worker is gone.
@@ -16,25 +17,27 @@ module Playwright
16
17
  # ```
17
18
  class Worker < PlaywrightApi
18
19
 
20
+ #
19
21
  # Returns the return value of `expression`.
20
22
  #
21
- # If the function passed to the [`method: Worker.evaluate`] returns a [Promise], then [`method: Worker.evaluate`] would
22
- # wait for the promise to resolve and return its value.
23
+ # If the function passed to the [`method: Worker.evaluate`] returns a [Promise], then [`method: Worker.evaluate`] would wait for the promise
24
+ # to resolve and return its value.
23
25
  #
24
- # If the function passed to the [`method: Worker.evaluate`] returns a non-[Serializable] value, then
25
- # [`method: Worker.evaluate`] returns `undefined`. Playwright also supports transferring some additional values that are
26
- # not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
26
+ # If the function passed to the [`method: Worker.evaluate`] returns a non-[Serializable] value, then [`method: Worker.evaluate`] returns `undefined`. Playwright also supports transferring some
27
+ # additional values that are not serializable by `JSON`: `-0`, `NaN`, `Infinity`, `-Infinity`.
27
28
  def evaluate(expression, arg: nil)
28
29
  wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg)))
29
30
  end
30
31
 
32
+ #
31
33
  # Returns the return value of `expression` as a `JSHandle`.
32
34
  #
33
- # The only difference between [`method: Worker.evaluate`] and [`method: Worker.evaluateHandle`] is that
34
- # [`method: Worker.evaluateHandle`] returns `JSHandle`.
35
+ # The only difference between [`method: Worker.evaluate`] and
36
+ # [`method: Worker.evaluateHandle`] is that [`method: Worker.evaluateHandle`]
37
+ # returns `JSHandle`.
35
38
  #
36
- # If the function passed to the [`method: Worker.evaluateHandle`] returns a [Promise], then
37
- # [`method: Worker.evaluateHandle`] would wait for the promise to resolve and return its value.
39
+ # If the function passed to the [`method: Worker.evaluateHandle`] returns a [Promise], then [`method: Worker.evaluateHandle`] would wait for
40
+ # the promise to resolve and return its value.
38
41
  def evaluate_handle(expression, arg: nil)
39
42
  wrap_impl(@impl.evaluate_handle(unwrap_impl(expression), arg: unwrap_impl(arg)))
40
43
  end
@@ -44,13 +47,13 @@ module Playwright
44
47
  end
45
48
 
46
49
  # @nodoc
47
- def context=(req)
48
- wrap_impl(@impl.context=(unwrap_impl(req)))
50
+ def page=(req)
51
+ wrap_impl(@impl.page=(unwrap_impl(req)))
49
52
  end
50
53
 
51
54
  # @nodoc
52
- def page=(req)
53
- wrap_impl(@impl.page=(unwrap_impl(req)))
55
+ def context=(req)
56
+ wrap_impl(@impl.context=(unwrap_impl(req)))
54
57
  end
55
58
 
56
59
  # -- inherited from EventEmitter --
data/playwright.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.required_ruby_version = '>= 2.4'
28
28
  spec.add_dependency 'concurrent-ruby', '>= 1.1.6'
29
29
  spec.add_dependency 'mime-types', '>= 3.0'
30
- spec.add_development_dependency 'bundler', '~> 2.3.0'
30
+ spec.add_development_dependency 'bundler'
31
31
  spec.add_development_dependency 'chunky_png'
32
32
  spec.add_development_dependency 'dry-inflector'
33
33
  spec.add_development_dependency 'faye-websocket'