playwright-ruby-client 1.28.0 → 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.
- checksums.yaml +4 -4
- data/documentation/docs/api/accessibility.md +9 -14
- data/documentation/docs/api/api_request_context.md +44 -41
- data/documentation/docs/api/api_response.md +13 -3
- data/documentation/docs/api/browser.md +24 -23
- data/documentation/docs/api/browser_context.md +71 -45
- data/documentation/docs/api/browser_type.md +21 -14
- data/documentation/docs/api/cdp_session.md +3 -5
- data/documentation/docs/api/console_message.md +7 -4
- data/documentation/docs/api/dialog.md +9 -5
- data/documentation/docs/api/download.md +19 -11
- data/documentation/docs/api/element_handle.md +125 -116
- data/documentation/docs/api/experimental/android.md +4 -5
- data/documentation/docs/api/experimental/android_device.md +11 -2
- data/documentation/docs/api/experimental/android_input.md +5 -0
- data/documentation/docs/api/file_chooser.md +6 -3
- data/documentation/docs/api/frame.md +182 -171
- data/documentation/docs/api/frame_locator.md +27 -38
- data/documentation/docs/api/js_handle.md +16 -10
- data/documentation/docs/api/keyboard.md +29 -16
- data/documentation/docs/api/locator.md +189 -140
- data/documentation/docs/api/mouse.md +9 -4
- data/documentation/docs/api/page.md +304 -289
- data/documentation/docs/api/playwright.md +8 -5
- data/documentation/docs/api/request.md +34 -15
- data/documentation/docs/api/response.md +27 -10
- data/documentation/docs/api/route.md +44 -12
- data/documentation/docs/api/selectors.md +5 -3
- data/documentation/docs/api/touchscreen.md +2 -0
- data/documentation/docs/api/tracing.md +11 -11
- data/documentation/docs/api/web_socket.md +9 -4
- data/documentation/docs/api/worker.md +12 -11
- data/documentation/docs/include/api_coverage.md +2 -0
- data/lib/playwright/channel_owners/android.rb +2 -2
- data/lib/playwright/channel_owners/android_device.rb +14 -55
- data/lib/playwright/channel_owners/api_request_context.rb +37 -2
- data/lib/playwright/channel_owners/browser_context.rb +22 -26
- data/lib/playwright/channel_owners/page.rb +35 -25
- data/lib/playwright/channel_owners/playwright.rb +7 -0
- data/lib/playwright/channel_owners/route.rb +28 -8
- data/lib/playwright/event_emitter.rb +6 -1
- data/lib/playwright/input_files.rb +3 -1
- data/lib/playwright/locator_impl.rb +8 -0
- data/lib/playwright/select_option_values.rb +2 -0
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright/web_socket_transport.rb +1 -1
- data/lib/playwright.rb +55 -0
- data/lib/playwright_api/accessibility.rb +9 -13
- data/lib/playwright_api/android.rb +8 -6
- data/lib/playwright_api/android_device.rb +37 -7
- data/lib/playwright_api/android_input.rb +5 -0
- data/lib/playwright_api/android_socket.rb +4 -2
- data/lib/playwright_api/android_web_view.rb +5 -2
- data/lib/playwright_api/api_request.rb +6 -3
- data/lib/playwright_api/api_request_context.rb +46 -36
- data/lib/playwright_api/api_response.rb +13 -2
- data/lib/playwright_api/browser.rb +24 -16
- data/lib/playwright_api/browser_context.rb +76 -39
- data/lib/playwright_api/browser_type.rb +23 -13
- data/lib/playwright_api/cdp_session.rb +3 -4
- data/lib/playwright_api/console_message.rb +7 -2
- data/lib/playwright_api/dialog.rb +8 -4
- data/lib/playwright_api/download.rb +19 -9
- data/lib/playwright_api/element_handle.rb +116 -93
- data/lib/playwright_api/file_chooser.rb +6 -1
- data/lib/playwright_api/frame.rb +180 -135
- data/lib/playwright_api/frame_locator.rb +29 -32
- data/lib/playwright_api/js_handle.rb +16 -6
- data/lib/playwright_api/keyboard.rb +29 -14
- data/lib/playwright_api/locator.rb +183 -112
- data/lib/playwright_api/mouse.rb +9 -2
- data/lib/playwright_api/page.rb +301 -253
- data/lib/playwright_api/playwright.rb +11 -4
- data/lib/playwright_api/request.rb +34 -7
- data/lib/playwright_api/response.rb +27 -10
- data/lib/playwright_api/route.rb +44 -11
- data/lib/playwright_api/selectors.rb +6 -1
- data/lib/playwright_api/touchscreen.rb +2 -0
- data/lib/playwright_api/tracing.rb +11 -5
- data/lib/playwright_api/web_socket.rb +9 -4
- data/lib/playwright_api/worker.rb +16 -13
- data/playwright.gemspec +1 -1
- metadata +7 -7
@@ -1,7 +1,4 @@
|
|
1
1
|
module Playwright
|
2
|
-
# **DEPRECATED** This class is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you
|
3
|
-
# need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for
|
4
|
-
# integration with Axe.
|
5
2
|
#
|
6
3
|
# The Accessibility class provides methods for inspecting Chromium's accessibility tree. The accessibility tree is used by
|
7
4
|
# assistive technology such as [screen readers](https://en.wikipedia.org/wiki/Screen_reader) or
|
@@ -10,23 +7,22 @@ module Playwright
|
|
10
7
|
# Accessibility is a very platform-specific thing. On different platforms, there are different screen readers that might
|
11
8
|
# have wildly different output.
|
12
9
|
#
|
13
|
-
# Rendering engines of Chromium, Firefox and WebKit have a concept of "accessibility tree", which is then translated into
|
14
|
-
#
|
10
|
+
# Rendering engines of Chromium, Firefox and WebKit have a concept of "accessibility tree", which is then translated into different
|
11
|
+
# platform-specific APIs. Accessibility namespace gives access to this Accessibility Tree.
|
15
12
|
#
|
16
|
-
# Most of the accessibility tree gets filtered out when converting from internal browser AX Tree to Platform-specific
|
17
|
-
#
|
18
|
-
#
|
13
|
+
# Most of the accessibility tree gets filtered out when converting from internal browser AX Tree to Platform-specific AX-Tree or by
|
14
|
+
# assistive technologies themselves. By default, Playwright tries to approximate this filtering, exposing only the
|
15
|
+
# "interesting" nodes of the tree.
|
19
16
|
class Accessibility < PlaywrightApi
|
20
17
|
|
21
|
-
# **DEPRECATED** This method is deprecated. Please use other libraries such as [Axe](https://www.deque.com/axe/) if you
|
22
|
-
# need to test page accessibility. See our Node.js [guide](https://playwright.dev/docs/accessibility-testing) for
|
23
|
-
# integration with Axe.
|
24
18
|
#
|
25
19
|
# Captures the current state of the accessibility tree. The returned object represents the root accessible node of the
|
26
20
|
# page.
|
27
21
|
#
|
28
|
-
#
|
29
|
-
#
|
22
|
+
# **NOTE**: The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers. Playwright
|
23
|
+
# will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`.
|
24
|
+
#
|
25
|
+
# **Usage**
|
30
26
|
#
|
31
27
|
# An example of dumping the entire accessibility tree:
|
32
28
|
#
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Playwright
|
2
|
+
#
|
2
3
|
# Playwright has **experimental** support for Android automation. This includes Chrome for Android and Android WebView.
|
3
4
|
#
|
4
5
|
# *Requirements*
|
5
6
|
# - Android device or AVD Emulator.
|
6
|
-
# - [ADB daemon](https://developer.android.com/studio/command-line/adb) running and authenticated with your device.
|
7
|
-
# Typically running `adb devices` is all you need to do.
|
7
|
+
# - [ADB daemon](https://developer.android.com/studio/command-line/adb) running and authenticated with your device. Typically running `adb devices` is all you need to do.
|
8
8
|
# - [`Chrome 87`](https://play.google.com/store/apps/details?id=com.android.chrome) or newer installed on the device
|
9
9
|
# - "Enable command line on non-rooted devices" enabled in `chrome://flags`.
|
10
10
|
#
|
@@ -17,25 +17,27 @@ module Playwright
|
|
17
17
|
#
|
18
18
|
# An example of the Android automation script would be:
|
19
19
|
#
|
20
|
-
# Note that since you don't need Playwright to install web browsers when testing Android, you can omit browser download
|
21
|
-
# via setting the following environment variable when installing Playwright:
|
20
|
+
# Note that since you don't need Playwright to install web browsers when testing Android, you can omit browser download via setting the following environment variable when installing Playwright:
|
22
21
|
#
|
23
22
|
# ```bash js
|
24
23
|
# PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
|
25
24
|
# ```
|
26
25
|
class Android < PlaywrightApi
|
27
26
|
|
28
|
-
#
|
29
|
-
# Android
|
27
|
+
#
|
28
|
+
# This methods attaches Playwright to an existing Android device.
|
29
|
+
# Use [`method: Android.launchServer`] to launch a new Android server instance.
|
30
30
|
def connect(wsEndpoint, headers: nil, slowMo: nil, timeout: nil)
|
31
31
|
raise NotImplementedError.new('connect is not implemented yet.')
|
32
32
|
end
|
33
33
|
|
34
|
+
#
|
34
35
|
# Returns the list of detected Android devices.
|
35
36
|
def devices(host: nil, omitDriverInstall: nil, port: nil)
|
36
37
|
wrap_impl(@impl.devices(host: unwrap_impl(host), omitDriverInstall: unwrap_impl(omitDriverInstall), port: unwrap_impl(port)))
|
37
38
|
end
|
38
39
|
|
40
|
+
#
|
39
41
|
# This setting will change the default maximum time for all the methods accepting `timeout` option.
|
40
42
|
def set_default_timeout(timeout)
|
41
43
|
raise NotImplementedError.new('set_default_timeout is not implemented yet.')
|
@@ -1,45 +1,53 @@
|
|
1
1
|
module Playwright
|
2
|
-
#
|
3
|
-
# [`method: Android.devices`].
|
2
|
+
#
|
3
|
+
# `AndroidDevice` represents a connected device, either real hardware or emulated. Devices can be obtained using [`method: Android.devices`].
|
4
4
|
class AndroidDevice < PlaywrightApi
|
5
5
|
|
6
6
|
def input # property
|
7
7
|
wrap_impl(@impl.input)
|
8
8
|
end
|
9
9
|
|
10
|
+
#
|
10
11
|
# Disconnects from the device.
|
11
12
|
def close
|
12
13
|
wrap_impl(@impl.close)
|
13
14
|
end
|
14
15
|
|
16
|
+
#
|
15
17
|
# Drags the widget defined by `selector` towards `dest` point.
|
16
18
|
def drag(selector, dest, speed: nil)
|
17
19
|
raise NotImplementedError.new('drag is not implemented yet.')
|
18
20
|
end
|
19
21
|
|
22
|
+
#
|
20
23
|
# Fills the specific `selector` input box with `text`.
|
21
24
|
def fill(selector, text)
|
22
25
|
raise NotImplementedError.new('fill is not implemented yet.')
|
23
26
|
end
|
24
27
|
|
28
|
+
#
|
25
29
|
# Flings the widget defined by `selector` in the specified `direction`.
|
26
30
|
def fling(selector, direction, speed: nil)
|
27
31
|
raise NotImplementedError.new('fling is not implemented yet.')
|
28
32
|
end
|
29
33
|
|
34
|
+
#
|
30
35
|
# Returns information about a widget defined by `selector`.
|
31
36
|
def info(selector)
|
32
37
|
wrap_impl(@impl.info(unwrap_impl(selector)))
|
33
38
|
end
|
34
39
|
|
40
|
+
#
|
35
41
|
# Installs an apk on the device.
|
36
42
|
def install_apk(file, args: nil)
|
37
43
|
raise NotImplementedError.new('install_apk is not implemented yet.')
|
38
44
|
end
|
39
45
|
|
46
|
+
#
|
40
47
|
# Launches Chrome browser on the device, and returns its persistent context.
|
41
48
|
def launch_browser(
|
42
49
|
acceptDownloads: nil,
|
50
|
+
args: nil,
|
43
51
|
baseURL: nil,
|
44
52
|
bypassCSP: nil,
|
45
53
|
colorScheme: nil,
|
@@ -57,6 +65,7 @@ module Playwright
|
|
57
65
|
noViewport: nil,
|
58
66
|
offline: nil,
|
59
67
|
permissions: nil,
|
68
|
+
proxy: nil,
|
60
69
|
record_har_content: nil,
|
61
70
|
record_har_mode: nil,
|
62
71
|
record_har_omit_content: nil,
|
@@ -72,102 +81,123 @@ module Playwright
|
|
72
81
|
userAgent: nil,
|
73
82
|
viewport: nil,
|
74
83
|
&block)
|
75
|
-
wrap_impl(@impl.launch_browser(acceptDownloads: unwrap_impl(acceptDownloads), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), command: unwrap_impl(command), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), record_har_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
|
84
|
+
wrap_impl(@impl.launch_browser(acceptDownloads: unwrap_impl(acceptDownloads), args: unwrap_impl(args), baseURL: unwrap_impl(baseURL), bypassCSP: unwrap_impl(bypassCSP), colorScheme: unwrap_impl(colorScheme), command: unwrap_impl(command), deviceScaleFactor: unwrap_impl(deviceScaleFactor), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), forcedColors: unwrap_impl(forcedColors), geolocation: unwrap_impl(geolocation), hasTouch: unwrap_impl(hasTouch), httpCredentials: unwrap_impl(httpCredentials), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), isMobile: unwrap_impl(isMobile), javaScriptEnabled: unwrap_impl(javaScriptEnabled), locale: unwrap_impl(locale), noViewport: unwrap_impl(noViewport), offline: unwrap_impl(offline), permissions: unwrap_impl(permissions), proxy: unwrap_impl(proxy), record_har_content: unwrap_impl(record_har_content), record_har_mode: unwrap_impl(record_har_mode), record_har_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_har_url_filter: unwrap_impl(record_har_url_filter), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), serviceWorkers: unwrap_impl(serviceWorkers), strictSelectors: unwrap_impl(strictSelectors), timezoneId: unwrap_impl(timezoneId), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
|
76
85
|
end
|
77
86
|
|
87
|
+
#
|
78
88
|
# Performs a long tap on the widget defined by `selector`.
|
79
89
|
def long_tap(selector)
|
80
90
|
raise NotImplementedError.new('long_tap is not implemented yet.')
|
81
91
|
end
|
82
92
|
|
93
|
+
#
|
83
94
|
# Device model.
|
84
95
|
def model
|
85
96
|
wrap_impl(@impl.model)
|
86
97
|
end
|
87
98
|
|
99
|
+
#
|
88
100
|
# Launches a process in the shell on the device and returns a socket to communicate with the launched process.
|
89
101
|
def open(command)
|
90
102
|
raise NotImplementedError.new('open is not implemented yet.')
|
91
103
|
end
|
92
104
|
|
105
|
+
#
|
93
106
|
# Pinches the widget defined by `selector` in the closing direction.
|
94
107
|
def pinch_close(selector, percent, speed: nil)
|
95
108
|
raise NotImplementedError.new('pinch_close is not implemented yet.')
|
96
109
|
end
|
97
110
|
|
111
|
+
#
|
98
112
|
# Pinches the widget defined by `selector` in the open direction.
|
99
113
|
def pinch_open(selector, percent, speed: nil)
|
100
114
|
raise NotImplementedError.new('pinch_open is not implemented yet.')
|
101
115
|
end
|
102
116
|
|
117
|
+
#
|
103
118
|
# Presses the specific `key` in the widget defined by `selector`.
|
104
119
|
def press(selector, key)
|
105
120
|
raise NotImplementedError.new('press is not implemented yet.')
|
106
121
|
end
|
107
122
|
|
123
|
+
#
|
108
124
|
# Copies a file to the device.
|
109
125
|
def push(file, path, mode: nil)
|
110
126
|
raise NotImplementedError.new('push is not implemented yet.')
|
111
127
|
end
|
112
128
|
|
129
|
+
#
|
113
130
|
# Returns the buffer with the captured screenshot of the device.
|
114
131
|
def screenshot(path: nil)
|
115
132
|
wrap_impl(@impl.screenshot(path: unwrap_impl(path)))
|
116
133
|
end
|
117
134
|
|
135
|
+
#
|
118
136
|
# Scrolls the widget defined by `selector` in the specified `direction`.
|
119
137
|
def scroll(selector, direction, percent, speed: nil)
|
120
138
|
raise NotImplementedError.new('scroll is not implemented yet.')
|
121
139
|
end
|
122
140
|
|
141
|
+
#
|
123
142
|
# Device serial number.
|
124
143
|
def serial
|
125
144
|
wrap_impl(@impl.serial)
|
126
145
|
end
|
127
146
|
|
147
|
+
#
|
128
148
|
# This setting will change the default maximum time for all the methods accepting `timeout` option.
|
129
149
|
def set_default_timeout(timeout)
|
130
150
|
raise NotImplementedError.new('set_default_timeout is not implemented yet.')
|
131
151
|
end
|
132
152
|
alias_method :default_timeout=, :set_default_timeout
|
133
153
|
|
154
|
+
#
|
134
155
|
# Executes a shell command on the device and returns its output.
|
135
156
|
def shell(command)
|
136
157
|
wrap_impl(@impl.shell(unwrap_impl(command)))
|
137
158
|
end
|
138
159
|
|
160
|
+
#
|
139
161
|
# Swipes the widget defined by `selector` in the specified `direction`.
|
140
162
|
def swipe(selector, direction, percent, speed: nil)
|
141
163
|
raise NotImplementedError.new('swipe is not implemented yet.')
|
142
164
|
end
|
143
165
|
|
166
|
+
#
|
144
167
|
# Taps on the widget defined by `selector`.
|
145
168
|
def tap_point(selector, duration: nil)
|
146
169
|
raise NotImplementedError.new('tap_point is not implemented yet.')
|
147
170
|
end
|
148
171
|
|
172
|
+
#
|
149
173
|
# Waits for the specific `selector` to either appear or disappear, depending on the `state`.
|
150
174
|
def wait(selector, state: nil)
|
151
175
|
raise NotImplementedError.new('wait is not implemented yet.')
|
152
176
|
end
|
153
177
|
|
154
|
-
#
|
155
|
-
# value.
|
178
|
+
#
|
179
|
+
# Waits for event to fire and passes its value into the predicate function. Returns when the predicate returns truthy value.
|
156
180
|
def wait_for_event(event, optionsOrPredicate: nil)
|
157
181
|
raise NotImplementedError.new('wait_for_event is not implemented yet.')
|
158
182
|
end
|
159
183
|
|
160
|
-
#
|
161
|
-
# `AndroidWebView` matching the `selector`, returns immediately.
|
184
|
+
#
|
185
|
+
# This method waits until `AndroidWebView` matching the `selector` is opened and returns it. If there is already an open `AndroidWebView` matching the `selector`, returns immediately.
|
162
186
|
def web_view(selector)
|
163
187
|
raise NotImplementedError.new('web_view is not implemented yet.')
|
164
188
|
end
|
165
189
|
|
190
|
+
#
|
166
191
|
# Currently open WebViews.
|
167
192
|
def web_views
|
168
193
|
raise NotImplementedError.new('web_views is not implemented yet.')
|
169
194
|
end
|
170
195
|
|
196
|
+
# @nodoc
|
197
|
+
def should_close_connection_on_close!
|
198
|
+
wrap_impl(@impl.should_close_connection_on_close!)
|
199
|
+
end
|
200
|
+
|
171
201
|
# @nodoc
|
172
202
|
def tap_on(selector, duration: nil, timeout: nil)
|
173
203
|
wrap_impl(@impl.tap_on(unwrap_impl(selector), duration: unwrap_impl(duration), timeout: unwrap_impl(timeout)))
|
@@ -1,26 +1,31 @@
|
|
1
1
|
module Playwright
|
2
2
|
class AndroidInput < PlaywrightApi
|
3
3
|
|
4
|
+
#
|
4
5
|
# Performs a drag between `from` and `to` points.
|
5
6
|
def drag(from, to, steps)
|
6
7
|
wrap_impl(@impl.drag(unwrap_impl(from), unwrap_impl(to), unwrap_impl(steps)))
|
7
8
|
end
|
8
9
|
|
10
|
+
#
|
9
11
|
# Presses the `key`.
|
10
12
|
def press(key)
|
11
13
|
wrap_impl(@impl.press(unwrap_impl(key)))
|
12
14
|
end
|
13
15
|
|
16
|
+
#
|
14
17
|
# Swipes following the path defined by `segments`.
|
15
18
|
def swipe(from, segments, steps)
|
16
19
|
raise NotImplementedError.new('swipe is not implemented yet.')
|
17
20
|
end
|
18
21
|
|
22
|
+
#
|
19
23
|
# Taps at the specified `point`.
|
20
24
|
def tap_point(point)
|
21
25
|
wrap_impl(@impl.tap_point(unwrap_impl(point)))
|
22
26
|
end
|
23
27
|
|
28
|
+
#
|
24
29
|
# Types `text` into currently focused widget.
|
25
30
|
def type(text)
|
26
31
|
wrap_impl(@impl.type(unwrap_impl(text)))
|
@@ -1,13 +1,15 @@
|
|
1
1
|
module Playwright
|
2
|
-
#
|
3
|
-
# [`method: AndroidDevice.open`] to open a socket.
|
2
|
+
#
|
3
|
+
# `AndroidSocket` is a way to communicate with a process launched on the `AndroidDevice`. Use [`method: AndroidDevice.open`] to open a socket.
|
4
4
|
class AndroidSocket < PlaywrightApi
|
5
5
|
|
6
|
+
#
|
6
7
|
# Closes the socket.
|
7
8
|
def close
|
8
9
|
raise NotImplementedError.new('close is not implemented yet.')
|
9
10
|
end
|
10
11
|
|
12
|
+
#
|
11
13
|
# Writes some `data` to the socket.
|
12
14
|
def write(data)
|
13
15
|
raise NotImplementedError.new('write is not implemented yet.')
|
@@ -1,18 +1,21 @@
|
|
1
1
|
module Playwright
|
2
|
-
#
|
3
|
-
# [`method: AndroidDevice.webView`].
|
2
|
+
#
|
3
|
+
# `AndroidWebView` represents a WebView open on the `AndroidDevice`. WebView is usually obtained using [`method: AndroidDevice.webView`].
|
4
4
|
class AndroidWebView < PlaywrightApi
|
5
5
|
|
6
|
+
#
|
6
7
|
# Connects to the WebView and returns a regular Playwright `Page` to interact with.
|
7
8
|
def page
|
8
9
|
raise NotImplementedError.new('page is not implemented yet.')
|
9
10
|
end
|
10
11
|
|
12
|
+
#
|
11
13
|
# WebView process PID.
|
12
14
|
def pid
|
13
15
|
raise NotImplementedError.new('pid is not implemented yet.')
|
14
16
|
end
|
15
17
|
|
18
|
+
#
|
16
19
|
# WebView package identifier.
|
17
20
|
def pkg
|
18
21
|
raise NotImplementedError.new('pkg is not implemented yet.')
|
@@ -1,9 +1,12 @@
|
|
1
1
|
module Playwright
|
2
|
-
#
|
3
|
-
#
|
4
|
-
#
|
2
|
+
#
|
3
|
+
# Exposes API that can be used for the Web API testing. This class is used for creating
|
4
|
+
# `APIRequestContext` instance which in turn can be used for sending web requests. An instance
|
5
|
+
# of this class can be obtained via [`property: Playwright.request`]. For more information
|
6
|
+
# see `APIRequestContext`.
|
5
7
|
class APIRequest < PlaywrightApi
|
6
8
|
|
9
|
+
#
|
7
10
|
# Creates new instances of `APIRequestContext`.
|
8
11
|
def new_context(
|
9
12
|
baseURL: nil,
|
@@ -1,21 +1,23 @@
|
|
1
1
|
module Playwright
|
2
|
+
#
|
2
3
|
# This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
|
3
4
|
# environment or the service to your e2e test.
|
4
5
|
#
|
5
|
-
# Each Playwright browser context has associated with it `APIRequestContext` instance which shares cookie storage with
|
6
|
-
# browser context and can be accessed via [`property: BrowserContext.request`] or [`property: Page.request`].
|
7
|
-
# possible to create a new APIRequestContext instance manually by calling [`method: APIRequest.newContext`].
|
6
|
+
# Each Playwright browser context has associated with it `APIRequestContext` instance which shares cookie storage with
|
7
|
+
# the browser context and can be accessed via [`property: BrowserContext.request`] or [`property: Page.request`].
|
8
|
+
# It is also possible to create a new APIRequestContext instance manually by calling [`method: APIRequest.newContext`].
|
8
9
|
#
|
9
10
|
# **Cookie management**
|
10
11
|
#
|
11
12
|
# `APIRequestContext` returned by [`property: BrowserContext.request`] and [`property: Page.request`] shares cookie
|
12
|
-
# storage with the corresponding `BrowserContext`. Each API request will have `Cookie` header populated with the
|
13
|
-
# from the browser context. If the API response contains `Set-Cookie` header it will automatically update
|
14
|
-
# cookies and requests made from the page will pick them up. This means that if you log in using
|
15
|
-
# will be logged in and vice versa.
|
13
|
+
# storage with the corresponding `BrowserContext`. Each API request will have `Cookie` header populated with the
|
14
|
+
# values from the browser context. If the API response contains `Set-Cookie` header it will automatically update
|
15
|
+
# `BrowserContext` cookies and requests made from the page will pick them up. This means that if you log in using
|
16
|
+
# this API, your e2e test will be logged in and vice versa.
|
16
17
|
#
|
17
18
|
# If you want API requests to not interfere with the browser cookies you should create a new `APIRequestContext` by
|
18
|
-
# calling [`method: APIRequest.newContext`]. Such `APIRequestContext` object will have its own isolated cookie
|
19
|
+
# calling [`method: APIRequest.newContext`]. Such `APIRequestContext` object will have its own isolated cookie
|
20
|
+
# storage.
|
19
21
|
#
|
20
22
|
# ```python sync
|
21
23
|
# import os
|
@@ -65,9 +67,10 @@ module Playwright
|
|
65
67
|
# ```
|
66
68
|
class APIRequestContext < PlaywrightApi
|
67
69
|
|
68
|
-
#
|
69
|
-
#
|
70
|
-
# method will
|
70
|
+
#
|
71
|
+
# Sends HTTP(S) [DELETE](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/DELETE) request and returns its response.
|
72
|
+
# The method will populate request cookies from the context and update
|
73
|
+
# context cookies from the response. The method will automatically follow redirects.
|
71
74
|
def delete(
|
72
75
|
url,
|
73
76
|
data: nil,
|
@@ -82,17 +85,18 @@ module Playwright
|
|
82
85
|
wrap_impl(@impl.delete(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
|
83
86
|
end
|
84
87
|
|
85
|
-
#
|
86
|
-
# can later call [`method: APIResponse.body`]. This method
|
87
|
-
# [`method: APIResponse.body`] throw "Response disposed" error.
|
88
|
+
#
|
89
|
+
# All responses returned by [`method: APIRequestContext.get`] and similar methods are stored in the memory, so that you can later call [`method: APIResponse.body`]. This method
|
90
|
+
# discards all stored responses, and makes [`method: APIResponse.body`] throw "Response disposed" error.
|
88
91
|
def dispose
|
89
92
|
wrap_impl(@impl.dispose)
|
90
93
|
end
|
91
94
|
|
95
|
+
#
|
92
96
|
# Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
|
93
|
-
# context cookies from the response. The method will automatically follow redirects.
|
97
|
+
# context cookies from the response. The method will automatically follow redirects. JSON objects can be passed directly to the request.
|
94
98
|
#
|
95
|
-
#
|
99
|
+
# **Usage**
|
96
100
|
#
|
97
101
|
# ```python
|
98
102
|
# data = {
|
@@ -102,8 +106,7 @@ module Playwright
|
|
102
106
|
# api_request_context.fetch("https://example.com/api/createBook", method="post", data=data)
|
103
107
|
# ```
|
104
108
|
#
|
105
|
-
# The common way to send file(s) in the body of a request is to encode it as form fields with `multipart/form-data`
|
106
|
-
# encoding. You can achieve that with Playwright API like this:
|
109
|
+
# The common way to send file(s) in the body of a request is to encode it as form fields with `multipart/form-data` encoding. You can achieve that with Playwright API like this:
|
107
110
|
#
|
108
111
|
# ```python
|
109
112
|
# api_request_context.fetch(
|
@@ -132,9 +135,12 @@ module Playwright
|
|
132
135
|
wrap_impl(@impl.fetch(unwrap_impl(urlOrRequest), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), method: unwrap_impl(method), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
|
133
136
|
end
|
134
137
|
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
+
#
|
139
|
+
# Sends HTTP(S) [GET](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/GET) request and returns its response.
|
140
|
+
# The method will populate request cookies from the context and update
|
141
|
+
# context cookies from the response. The method will automatically follow redirects.
|
142
|
+
#
|
143
|
+
# **Usage**
|
138
144
|
#
|
139
145
|
# Request parameters can be configured with `params` option, they will be serialized into the URL search parameters:
|
140
146
|
#
|
@@ -159,9 +165,10 @@ module Playwright
|
|
159
165
|
wrap_impl(@impl.get(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
|
160
166
|
end
|
161
167
|
|
168
|
+
#
|
162
169
|
# Sends HTTP(S) [HEAD](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD) request and returns its response.
|
163
|
-
# The method will populate request cookies from the context and update
|
164
|
-
# automatically follow redirects.
|
170
|
+
# The method will populate request cookies from the context and update
|
171
|
+
# context cookies from the response. The method will automatically follow redirects.
|
165
172
|
def head(
|
166
173
|
url,
|
167
174
|
data: nil,
|
@@ -176,9 +183,10 @@ module Playwright
|
|
176
183
|
wrap_impl(@impl.head(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
|
177
184
|
end
|
178
185
|
|
186
|
+
#
|
179
187
|
# Sends HTTP(S) [PATCH](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PATCH) request and returns its response.
|
180
|
-
# The method will populate request cookies from the context and update
|
181
|
-
# automatically follow redirects.
|
188
|
+
# The method will populate request cookies from the context and update
|
189
|
+
# context cookies from the response. The method will automatically follow redirects.
|
182
190
|
def patch(
|
183
191
|
url,
|
184
192
|
data: nil,
|
@@ -193,9 +201,12 @@ module Playwright
|
|
193
201
|
wrap_impl(@impl.patch(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
|
194
202
|
end
|
195
203
|
|
204
|
+
#
|
196
205
|
# Sends HTTP(S) [POST](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) request and returns its response.
|
197
|
-
# The method will populate request cookies from the context and update
|
198
|
-
# automatically follow redirects.
|
206
|
+
# The method will populate request cookies from the context and update
|
207
|
+
# context cookies from the response. The method will automatically follow redirects.
|
208
|
+
#
|
209
|
+
# **Usage**
|
199
210
|
#
|
200
211
|
# JSON objects can be passed directly to the request:
|
201
212
|
#
|
@@ -207,8 +218,7 @@ module Playwright
|
|
207
218
|
# api_request_context.post("https://example.com/api/createBook", data=data)
|
208
219
|
# ```
|
209
220
|
#
|
210
|
-
# To send form data to the server use `form` option. Its value will be encoded into the request body with
|
211
|
-
# `application/x-www-form-urlencoded` encoding (see below how to use `multipart/form-data` form encoding to send files):
|
221
|
+
# To send form data to the server use `form` option. Its value will be encoded into the request body with `application/x-www-form-urlencoded` encoding (see below how to use `multipart/form-data` form encoding to send files):
|
212
222
|
#
|
213
223
|
# ```python
|
214
224
|
# formData = {
|
@@ -218,8 +228,7 @@ module Playwright
|
|
218
228
|
# api_request_context.post("https://example.com/api/findBook", form=formData)
|
219
229
|
# ```
|
220
230
|
#
|
221
|
-
# The common way to send file(s) in the body of a request is to upload them as form fields with `multipart/form-data`
|
222
|
-
# encoding. You can achieve that with Playwright API like this:
|
231
|
+
# The common way to send file(s) in the body of a request is to upload them as form fields with `multipart/form-data` encoding. You can achieve that with Playwright API like this:
|
223
232
|
#
|
224
233
|
# ```python
|
225
234
|
# api_request_context.post(
|
@@ -246,9 +255,10 @@ module Playwright
|
|
246
255
|
wrap_impl(@impl.post(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
|
247
256
|
end
|
248
257
|
|
249
|
-
#
|
250
|
-
#
|
251
|
-
#
|
258
|
+
#
|
259
|
+
# Sends HTTP(S) [PUT](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/PUT) request and returns its response.
|
260
|
+
# The method will populate request cookies from the context and update
|
261
|
+
# context cookies from the response. The method will automatically follow redirects.
|
252
262
|
def put(
|
253
263
|
url,
|
254
264
|
data: nil,
|
@@ -263,8 +273,8 @@ module Playwright
|
|
263
273
|
wrap_impl(@impl.put(unwrap_impl(url), data: unwrap_impl(data), failOnStatusCode: unwrap_impl(failOnStatusCode), form: unwrap_impl(form), headers: unwrap_impl(headers), ignoreHTTPSErrors: unwrap_impl(ignoreHTTPSErrors), maxRedirects: unwrap_impl(maxRedirects), multipart: unwrap_impl(multipart), params: unwrap_impl(params), timeout: unwrap_impl(timeout)))
|
264
274
|
end
|
265
275
|
|
266
|
-
#
|
267
|
-
# the constructor.
|
276
|
+
#
|
277
|
+
# Returns storage state for this request context, contains current cookies and local storage snapshot if it was passed to the constructor.
|
268
278
|
def storage_state(path: nil)
|
269
279
|
raise NotImplementedError.new('storage_state is not implemented yet.')
|
270
280
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
module Playwright
|
2
|
+
#
|
2
3
|
# `APIResponse` class represents responses returned by [`method: APIRequestContext.get`] and similar methods.
|
3
4
|
#
|
4
5
|
# ```python sync
|
@@ -15,27 +16,32 @@ module Playwright
|
|
15
16
|
# ```
|
16
17
|
class APIResponse < PlaywrightApi
|
17
18
|
|
19
|
+
#
|
18
20
|
# Returns the buffer with response body.
|
19
21
|
def body
|
20
22
|
wrap_impl(@impl.body)
|
21
23
|
end
|
22
24
|
|
25
|
+
#
|
23
26
|
# Disposes the body of this response. If not called then the body will stay in memory until the context closes.
|
24
27
|
def dispose
|
25
28
|
wrap_impl(@impl.dispose)
|
26
29
|
end
|
27
30
|
|
31
|
+
#
|
28
32
|
# An object with all the response HTTP headers associated with this response.
|
29
33
|
def headers
|
30
34
|
wrap_impl(@impl.headers)
|
31
35
|
end
|
32
36
|
|
33
|
-
#
|
34
|
-
#
|
37
|
+
#
|
38
|
+
# An array with all the request HTTP headers associated with this response. Header names are not lower-cased.
|
39
|
+
# Headers with multiple entries, such as `Set-Cookie`, appear in the array multiple times.
|
35
40
|
def headers_array
|
36
41
|
wrap_impl(@impl.headers_array)
|
37
42
|
end
|
38
43
|
|
44
|
+
#
|
39
45
|
# Returns the JSON representation of response body.
|
40
46
|
#
|
41
47
|
# This method will throw if the response body is not parsable via `JSON.parse`.
|
@@ -43,26 +49,31 @@ module Playwright
|
|
43
49
|
wrap_impl(@impl.json)
|
44
50
|
end
|
45
51
|
|
52
|
+
#
|
46
53
|
# Contains a boolean stating whether the response was successful (status in the range 200-299) or not.
|
47
54
|
def ok
|
48
55
|
wrap_impl(@impl.ok)
|
49
56
|
end
|
50
57
|
|
58
|
+
#
|
51
59
|
# Contains the status code of the response (e.g., 200 for a success).
|
52
60
|
def status
|
53
61
|
wrap_impl(@impl.status)
|
54
62
|
end
|
55
63
|
|
64
|
+
#
|
56
65
|
# Contains the status text of the response (e.g. usually an "OK" for a success).
|
57
66
|
def status_text
|
58
67
|
wrap_impl(@impl.status_text)
|
59
68
|
end
|
60
69
|
|
70
|
+
#
|
61
71
|
# Returns the text representation of response body.
|
62
72
|
def text
|
63
73
|
wrap_impl(@impl.text)
|
64
74
|
end
|
65
75
|
|
76
|
+
#
|
66
77
|
# Contains the URL of the response.
|
67
78
|
def url
|
68
79
|
wrap_impl(@impl.url)
|