playwright-ruby-client 1.51.0 → 1.53.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/experimental/android.md +10 -0
- data/documentation/docs/api/locator.md +23 -0
- data/documentation/docs/api/locator_assertions.md +47 -1
- data/documentation/docs/api/page.md +1 -1
- data/documentation/docs/api/route.md +2 -0
- data/documentation/docs/api/selectors.md +10 -0
- data/documentation/docs/api/tracing.md +8 -0
- data/documentation/docs/include/api_coverage.md +5 -2
- data/lib/playwright/channel.rb +6 -3
- data/lib/playwright/channel_owners/android.rb +12 -0
- data/lib/playwright/channel_owners/android_device.rb +6 -5
- data/lib/playwright/channel_owners/api_request_context.rb +6 -1
- data/lib/playwright/channel_owners/browser.rb +37 -6
- data/lib/playwright/channel_owners/browser_context.rb +44 -23
- data/lib/playwright/channel_owners/browser_type.rb +45 -12
- data/lib/playwright/channel_owners/element_handle.rb +22 -17
- data/lib/playwright/channel_owners/frame.rb +40 -33
- data/lib/playwright/channel_owners/page.rb +19 -8
- data/lib/playwright/channel_owners/playwright.rb +10 -4
- data/lib/playwright/channel_owners/web_socket.rb +1 -1
- data/lib/playwright/connection.rb +3 -0
- data/lib/playwright/file_chooser_impl.rb +3 -2
- data/lib/playwright/frame_locator_impl.rb +5 -8
- data/lib/playwright/javascript/value_parser.rb +54 -2
- data/lib/playwright/locator_assertions_impl.rb +95 -32
- data/lib/playwright/locator_impl.rb +30 -18
- data/lib/playwright/page_assertions_impl.rb +10 -8
- data/lib/playwright/selectors_impl.rb +45 -0
- data/lib/playwright/test.rb +21 -3
- data/lib/playwright/timeout_settings.rb +5 -0
- data/lib/playwright/utils.rb +0 -33
- data/lib/playwright/version.rb +2 -2
- data/lib/playwright_api/android.rb +12 -7
- data/lib/playwright_api/android_device.rb +8 -8
- data/lib/playwright_api/api_request.rb +1 -0
- data/lib/playwright_api/api_request_context.rb +6 -6
- data/lib/playwright_api/browser.rb +6 -6
- data/lib/playwright_api/browser_context.rb +14 -14
- data/lib/playwright_api/browser_type.rb +6 -6
- data/lib/playwright_api/cdp_session.rb +6 -6
- data/lib/playwright_api/dialog.rb +6 -6
- data/lib/playwright_api/element_handle.rb +6 -6
- data/lib/playwright_api/frame.rb +6 -6
- data/lib/playwright_api/js_handle.rb +6 -6
- data/lib/playwright_api/locator.rb +28 -2
- data/lib/playwright_api/locator_assertions.rb +47 -3
- data/lib/playwright_api/page.rb +15 -10
- data/lib/playwright_api/playwright.rb +6 -6
- data/lib/playwright_api/request.rb +6 -6
- data/lib/playwright_api/response.rb +6 -6
- data/lib/playwright_api/route.rb +8 -6
- data/lib/playwright_api/selectors.rb +1 -28
- data/lib/playwright_api/tracing.rb +14 -6
- data/lib/playwright_api/web_socket.rb +6 -6
- data/lib/playwright_api/worker.rb +6 -6
- data/sig/playwright.rbs +7 -0
- metadata +5 -5
- data/lib/playwright/channel_owners/selectors.rb +0 -26
data/lib/playwright/test.rb
CHANGED
@@ -2,10 +2,28 @@ module Playwright
|
|
2
2
|
# this module is responsible for running playwright assertions and integrating
|
3
3
|
# with test frameworks.
|
4
4
|
module Test
|
5
|
+
@@expect_timeout = nil
|
6
|
+
|
7
|
+
def self.expect_timeout
|
8
|
+
@@expect_timeout || 5000 # default timeout is 5000ms
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.expect_timeout=(timeout)
|
12
|
+
@@expect_timeout = timeout
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.with_timeout(expect_timeout, &block)
|
16
|
+
old_timeout = @@expect_timeout
|
17
|
+
@@expect_timeout = expect_timeout
|
18
|
+
block.call
|
19
|
+
ensure
|
20
|
+
@@expect_timeout = old_timeout
|
21
|
+
end
|
22
|
+
|
5
23
|
# ref: https://github.com/microsoft/playwright-python/blob/main/playwright/sync_api/__init__.py#L90
|
6
24
|
class Expect
|
7
25
|
def initialize
|
8
|
-
@
|
26
|
+
@default_expect_timeout = ::Playwright::Test.expect_timeout
|
9
27
|
end
|
10
28
|
|
11
29
|
def call(actual, is_not)
|
@@ -14,7 +32,7 @@ module Playwright
|
|
14
32
|
PageAssertions.new(
|
15
33
|
PageAssertionsImpl.new(
|
16
34
|
actual,
|
17
|
-
@
|
35
|
+
@default_expect_timeout,
|
18
36
|
is_not,
|
19
37
|
nil,
|
20
38
|
)
|
@@ -23,7 +41,7 @@ module Playwright
|
|
23
41
|
LocatorAssertions.new(
|
24
42
|
LocatorAssertionsImpl.new(
|
25
43
|
actual,
|
26
|
-
@
|
44
|
+
@default_expect_timeout,
|
27
45
|
is_not,
|
28
46
|
nil,
|
29
47
|
)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module Playwright
|
2
2
|
class TimeoutSettings
|
3
3
|
DEFAULT_TIMEOUT = 30000
|
4
|
+
DEFAULT_LAUNCH_TIMEOUT = 180000 # 3 minutes
|
4
5
|
|
5
6
|
def initialize(parent = nil)
|
6
7
|
@parent = parent
|
@@ -15,5 +16,9 @@ module Playwright
|
|
15
16
|
def timeout(timeout_override = nil)
|
16
17
|
timeout_override || @default_timeout || @parent&.timeout || DEFAULT_TIMEOUT
|
17
18
|
end
|
19
|
+
|
20
|
+
def launch_timeout(timeout_override = nil)
|
21
|
+
timeout_override || @default_timeout || @parent&.launch_timeout || DEFAULT_LAUNCH_TIMEOUT
|
22
|
+
end
|
18
23
|
end
|
19
24
|
end
|
data/lib/playwright/utils.rb
CHANGED
@@ -3,36 +3,6 @@ require 'base64'
|
|
3
3
|
module Playwright
|
4
4
|
module Utils
|
5
5
|
module PrepareBrowserContextOptions
|
6
|
-
private def prepare_record_har_options(params)
|
7
|
-
out_params = {
|
8
|
-
path: params.delete(:record_har_path)
|
9
|
-
}
|
10
|
-
if params[:record_har_url_filter]
|
11
|
-
opt = params.delete(:record_har_url_filter)
|
12
|
-
if opt.is_a?(Regexp)
|
13
|
-
regex = ::Playwright::JavaScript::Regex.new(opt)
|
14
|
-
out_params[:urlRegexSource] = regex.source
|
15
|
-
out_params[:urlRegexFlags] = regex.flag
|
16
|
-
elsif opt.is_a?(String)
|
17
|
-
out_params[:urlGlob] = opt
|
18
|
-
end
|
19
|
-
end
|
20
|
-
if params[:record_har_mode]
|
21
|
-
out_params[:mode] = params.delete(:record_har_mode)
|
22
|
-
end
|
23
|
-
if params[:record_har_content]
|
24
|
-
out_params[:content] = params.delete(:record_har_content)
|
25
|
-
end
|
26
|
-
if params[:record_har_omit_content]
|
27
|
-
old_api_omit_content = params.delete(:record_har_omit_content)
|
28
|
-
if old_api_omit_content
|
29
|
-
out_params[:content] ||= 'omit'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
out_params
|
34
|
-
end
|
35
|
-
|
36
6
|
# @see https://github.com/microsoft/playwright/blob/5a2cfdbd47ed3c3deff77bb73e5fac34241f649d/src/client/browserContext.ts#L265
|
37
7
|
private def prepare_browser_context_options(params)
|
38
8
|
if params[:noViewport] == 0
|
@@ -42,9 +12,6 @@ module Playwright
|
|
42
12
|
if params[:extraHTTPHeaders]
|
43
13
|
params[:extraHTTPHeaders] = ::Playwright::HttpHeaders.new(params[:extraHTTPHeaders]).as_serialized
|
44
14
|
end
|
45
|
-
if params[:record_har_path]
|
46
|
-
params[:recordHar] = prepare_record_har_options(params)
|
47
|
-
end
|
48
15
|
if params[:record_video_dir]
|
49
16
|
params[:recordVideo] = {
|
50
17
|
dir: params.delete(:record_video_dir)
|
data/lib/playwright/version.rb
CHANGED
@@ -34,26 +34,31 @@ module Playwright
|
|
34
34
|
#
|
35
35
|
# This setting will change the default maximum time for all the methods accepting `timeout` option.
|
36
36
|
def set_default_timeout(timeout)
|
37
|
-
|
37
|
+
wrap_impl(@impl.set_default_timeout(unwrap_impl(timeout)))
|
38
38
|
end
|
39
39
|
alias_method :default_timeout=, :set_default_timeout
|
40
40
|
|
41
|
+
# @nodoc
|
42
|
+
def set_default_navigation_timeout(timeout)
|
43
|
+
wrap_impl(@impl.set_default_navigation_timeout(unwrap_impl(timeout)))
|
44
|
+
end
|
45
|
+
|
41
46
|
# -- inherited from EventEmitter --
|
42
47
|
# @nodoc
|
43
|
-
def
|
44
|
-
event_emitter_proxy.
|
48
|
+
def once(event, callback)
|
49
|
+
event_emitter_proxy.once(event, callback)
|
45
50
|
end
|
46
51
|
|
47
52
|
# -- inherited from EventEmitter --
|
48
53
|
# @nodoc
|
49
|
-
def
|
50
|
-
event_emitter_proxy.
|
54
|
+
def on(event, callback)
|
55
|
+
event_emitter_proxy.on(event, callback)
|
51
56
|
end
|
52
57
|
|
53
58
|
# -- inherited from EventEmitter --
|
54
59
|
# @nodoc
|
55
|
-
def
|
56
|
-
event_emitter_proxy.
|
60
|
+
def off(event, callback)
|
61
|
+
event_emitter_proxy.off(event, callback)
|
57
62
|
end
|
58
63
|
|
59
64
|
private def event_emitter_proxy
|
@@ -194,14 +194,20 @@ module Playwright
|
|
194
194
|
raise NotImplementedError.new('web_views is not implemented yet.')
|
195
195
|
end
|
196
196
|
|
197
|
+
# @nodoc
|
198
|
+
def tap_on(selector, duration: nil, timeout: nil)
|
199
|
+
wrap_impl(@impl.tap_on(unwrap_impl(selector), duration: unwrap_impl(duration), timeout: unwrap_impl(timeout)))
|
200
|
+
end
|
201
|
+
|
197
202
|
# @nodoc
|
198
203
|
def should_close_connection_on_close!
|
199
204
|
wrap_impl(@impl.should_close_connection_on_close!)
|
200
205
|
end
|
201
206
|
|
207
|
+
# -- inherited from EventEmitter --
|
202
208
|
# @nodoc
|
203
|
-
def
|
204
|
-
|
209
|
+
def once(event, callback)
|
210
|
+
event_emitter_proxy.once(event, callback)
|
205
211
|
end
|
206
212
|
|
207
213
|
# -- inherited from EventEmitter --
|
@@ -216,12 +222,6 @@ module Playwright
|
|
216
222
|
event_emitter_proxy.off(event, callback)
|
217
223
|
end
|
218
224
|
|
219
|
-
# -- inherited from EventEmitter --
|
220
|
-
# @nodoc
|
221
|
-
def once(event, callback)
|
222
|
-
event_emitter_proxy.once(event, callback)
|
223
|
-
end
|
224
|
-
|
225
225
|
private def event_emitter_proxy
|
226
226
|
@event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
|
227
227
|
end
|
@@ -288,20 +288,20 @@ module Playwright
|
|
288
288
|
|
289
289
|
# -- inherited from EventEmitter --
|
290
290
|
# @nodoc
|
291
|
-
def
|
292
|
-
event_emitter_proxy.
|
291
|
+
def once(event, callback)
|
292
|
+
event_emitter_proxy.once(event, callback)
|
293
293
|
end
|
294
294
|
|
295
295
|
# -- inherited from EventEmitter --
|
296
296
|
# @nodoc
|
297
|
-
def
|
298
|
-
event_emitter_proxy.
|
297
|
+
def on(event, callback)
|
298
|
+
event_emitter_proxy.on(event, callback)
|
299
299
|
end
|
300
300
|
|
301
301
|
# -- inherited from EventEmitter --
|
302
302
|
# @nodoc
|
303
|
-
def
|
304
|
-
event_emitter_proxy.
|
303
|
+
def off(event, callback)
|
304
|
+
event_emitter_proxy.off(event, callback)
|
305
305
|
end
|
306
306
|
|
307
307
|
private def event_emitter_proxy
|
@@ -205,20 +205,20 @@ module Playwright
|
|
205
205
|
|
206
206
|
# -- inherited from EventEmitter --
|
207
207
|
# @nodoc
|
208
|
-
def
|
209
|
-
event_emitter_proxy.
|
208
|
+
def once(event, callback)
|
209
|
+
event_emitter_proxy.once(event, callback)
|
210
210
|
end
|
211
211
|
|
212
212
|
# -- inherited from EventEmitter --
|
213
213
|
# @nodoc
|
214
|
-
def
|
215
|
-
event_emitter_proxy.
|
214
|
+
def on(event, callback)
|
215
|
+
event_emitter_proxy.on(event, callback)
|
216
216
|
end
|
217
217
|
|
218
218
|
# -- inherited from EventEmitter --
|
219
219
|
# @nodoc
|
220
|
-
def
|
221
|
-
event_emitter_proxy.
|
220
|
+
def off(event, callback)
|
221
|
+
event_emitter_proxy.off(event, callback)
|
222
222
|
end
|
223
223
|
|
224
224
|
private def event_emitter_proxy
|
@@ -464,23 +464,23 @@ module Playwright
|
|
464
464
|
end
|
465
465
|
|
466
466
|
# @nodoc
|
467
|
-
def
|
468
|
-
wrap_impl(@impl.
|
467
|
+
def enable_debug_console!
|
468
|
+
wrap_impl(@impl.enable_debug_console!)
|
469
469
|
end
|
470
470
|
|
471
471
|
# @nodoc
|
472
|
-
def
|
473
|
-
wrap_impl(@impl.
|
472
|
+
def pause
|
473
|
+
wrap_impl(@impl.pause)
|
474
474
|
end
|
475
475
|
|
476
476
|
# @nodoc
|
477
|
-
def
|
478
|
-
wrap_impl(@impl.
|
477
|
+
def owner_page=(req)
|
478
|
+
wrap_impl(@impl.owner_page=(unwrap_impl(req)))
|
479
479
|
end
|
480
480
|
|
481
481
|
# @nodoc
|
482
|
-
def
|
483
|
-
wrap_impl(@impl.
|
482
|
+
def options=(req)
|
483
|
+
wrap_impl(@impl.options=(unwrap_impl(req)))
|
484
484
|
end
|
485
485
|
|
486
486
|
# @nodoc
|
@@ -490,20 +490,20 @@ module Playwright
|
|
490
490
|
|
491
491
|
# -- inherited from EventEmitter --
|
492
492
|
# @nodoc
|
493
|
-
def
|
494
|
-
event_emitter_proxy.
|
493
|
+
def once(event, callback)
|
494
|
+
event_emitter_proxy.once(event, callback)
|
495
495
|
end
|
496
496
|
|
497
497
|
# -- inherited from EventEmitter --
|
498
498
|
# @nodoc
|
499
|
-
def
|
500
|
-
event_emitter_proxy.
|
499
|
+
def on(event, callback)
|
500
|
+
event_emitter_proxy.on(event, callback)
|
501
501
|
end
|
502
502
|
|
503
503
|
# -- inherited from EventEmitter --
|
504
504
|
# @nodoc
|
505
|
-
def
|
506
|
-
event_emitter_proxy.
|
505
|
+
def off(event, callback)
|
506
|
+
event_emitter_proxy.off(event, callback)
|
507
507
|
end
|
508
508
|
|
509
509
|
private def event_emitter_proxy
|
@@ -182,20 +182,20 @@ module Playwright
|
|
182
182
|
|
183
183
|
# -- inherited from EventEmitter --
|
184
184
|
# @nodoc
|
185
|
-
def
|
186
|
-
event_emitter_proxy.
|
185
|
+
def once(event, callback)
|
186
|
+
event_emitter_proxy.once(event, callback)
|
187
187
|
end
|
188
188
|
|
189
189
|
# -- inherited from EventEmitter --
|
190
190
|
# @nodoc
|
191
|
-
def
|
192
|
-
event_emitter_proxy.
|
191
|
+
def on(event, callback)
|
192
|
+
event_emitter_proxy.on(event, callback)
|
193
193
|
end
|
194
194
|
|
195
195
|
# -- inherited from EventEmitter --
|
196
196
|
# @nodoc
|
197
|
-
def
|
198
|
-
event_emitter_proxy.
|
197
|
+
def off(event, callback)
|
198
|
+
event_emitter_proxy.off(event, callback)
|
199
199
|
end
|
200
200
|
|
201
201
|
private def event_emitter_proxy
|
@@ -33,20 +33,20 @@ module Playwright
|
|
33
33
|
|
34
34
|
# -- inherited from EventEmitter --
|
35
35
|
# @nodoc
|
36
|
-
def
|
37
|
-
event_emitter_proxy.
|
36
|
+
def once(event, callback)
|
37
|
+
event_emitter_proxy.once(event, callback)
|
38
38
|
end
|
39
39
|
|
40
40
|
# -- inherited from EventEmitter --
|
41
41
|
# @nodoc
|
42
|
-
def
|
43
|
-
event_emitter_proxy.
|
42
|
+
def on(event, callback)
|
43
|
+
event_emitter_proxy.on(event, callback)
|
44
44
|
end
|
45
45
|
|
46
46
|
# -- inherited from EventEmitter --
|
47
47
|
# @nodoc
|
48
|
-
def
|
49
|
-
event_emitter_proxy.
|
48
|
+
def off(event, callback)
|
49
|
+
event_emitter_proxy.off(event, callback)
|
50
50
|
end
|
51
51
|
|
52
52
|
private def event_emitter_proxy
|
@@ -70,20 +70,20 @@ module Playwright
|
|
70
70
|
|
71
71
|
# -- inherited from EventEmitter --
|
72
72
|
# @nodoc
|
73
|
-
def
|
74
|
-
event_emitter_proxy.
|
73
|
+
def once(event, callback)
|
74
|
+
event_emitter_proxy.once(event, callback)
|
75
75
|
end
|
76
76
|
|
77
77
|
# -- inherited from EventEmitter --
|
78
78
|
# @nodoc
|
79
|
-
def
|
80
|
-
event_emitter_proxy.
|
79
|
+
def on(event, callback)
|
80
|
+
event_emitter_proxy.on(event, callback)
|
81
81
|
end
|
82
82
|
|
83
83
|
# -- inherited from EventEmitter --
|
84
84
|
# @nodoc
|
85
|
-
def
|
86
|
-
event_emitter_proxy.
|
85
|
+
def off(event, callback)
|
86
|
+
event_emitter_proxy.off(event, callback)
|
87
87
|
end
|
88
88
|
|
89
89
|
private def event_emitter_proxy
|
@@ -574,20 +574,20 @@ module Playwright
|
|
574
574
|
|
575
575
|
# -- inherited from EventEmitter --
|
576
576
|
# @nodoc
|
577
|
-
def
|
578
|
-
event_emitter_proxy.
|
577
|
+
def once(event, callback)
|
578
|
+
event_emitter_proxy.once(event, callback)
|
579
579
|
end
|
580
580
|
|
581
581
|
# -- inherited from EventEmitter --
|
582
582
|
# @nodoc
|
583
|
-
def
|
584
|
-
event_emitter_proxy.
|
583
|
+
def on(event, callback)
|
584
|
+
event_emitter_proxy.on(event, callback)
|
585
585
|
end
|
586
586
|
|
587
587
|
# -- inherited from EventEmitter --
|
588
588
|
# @nodoc
|
589
|
-
def
|
590
|
-
event_emitter_proxy.
|
589
|
+
def off(event, callback)
|
590
|
+
event_emitter_proxy.off(event, callback)
|
591
591
|
end
|
592
592
|
|
593
593
|
private def event_emitter_proxy
|
data/lib/playwright_api/frame.rb
CHANGED
@@ -1050,20 +1050,20 @@ module Playwright
|
|
1050
1050
|
|
1051
1051
|
# -- inherited from EventEmitter --
|
1052
1052
|
# @nodoc
|
1053
|
-
def
|
1054
|
-
event_emitter_proxy.
|
1053
|
+
def once(event, callback)
|
1054
|
+
event_emitter_proxy.once(event, callback)
|
1055
1055
|
end
|
1056
1056
|
|
1057
1057
|
# -- inherited from EventEmitter --
|
1058
1058
|
# @nodoc
|
1059
|
-
def
|
1060
|
-
event_emitter_proxy.
|
1059
|
+
def on(event, callback)
|
1060
|
+
event_emitter_proxy.on(event, callback)
|
1061
1061
|
end
|
1062
1062
|
|
1063
1063
|
# -- inherited from EventEmitter --
|
1064
1064
|
# @nodoc
|
1065
|
-
def
|
1066
|
-
event_emitter_proxy.
|
1065
|
+
def off(event, callback)
|
1066
|
+
event_emitter_proxy.off(event, callback)
|
1067
1067
|
end
|
1068
1068
|
|
1069
1069
|
private def event_emitter_proxy
|
@@ -100,20 +100,20 @@ module Playwright
|
|
100
100
|
|
101
101
|
# -- inherited from EventEmitter --
|
102
102
|
# @nodoc
|
103
|
-
def
|
104
|
-
event_emitter_proxy.
|
103
|
+
def once(event, callback)
|
104
|
+
event_emitter_proxy.once(event, callback)
|
105
105
|
end
|
106
106
|
|
107
107
|
# -- inherited from EventEmitter --
|
108
108
|
# @nodoc
|
109
|
-
def
|
110
|
-
event_emitter_proxy.
|
109
|
+
def on(event, callback)
|
110
|
+
event_emitter_proxy.on(event, callback)
|
111
111
|
end
|
112
112
|
|
113
113
|
# -- inherited from EventEmitter --
|
114
114
|
# @nodoc
|
115
|
-
def
|
116
|
-
event_emitter_proxy.
|
115
|
+
def off(event, callback)
|
116
|
+
event_emitter_proxy.off(event, callback)
|
117
117
|
end
|
118
118
|
|
119
119
|
private def event_emitter_proxy
|
@@ -274,6 +274,20 @@ module Playwright
|
|
274
274
|
wrap_impl(@impl.dblclick(button: unwrap_impl(button), delay: unwrap_impl(delay), force: unwrap_impl(force), modifiers: unwrap_impl(modifiers), noWaitAfter: unwrap_impl(noWaitAfter), position: unwrap_impl(position), timeout: unwrap_impl(timeout), trial: unwrap_impl(trial)))
|
275
275
|
end
|
276
276
|
|
277
|
+
#
|
278
|
+
# Describes the locator, description is used in the trace viewer and reports.
|
279
|
+
# Returns the locator pointing to the same element.
|
280
|
+
#
|
281
|
+
# **Usage**
|
282
|
+
#
|
283
|
+
# ```python sync
|
284
|
+
# button = page.get_by_test_id("btn-sub").describe("Subscribe button")
|
285
|
+
# button.click()
|
286
|
+
# ```
|
287
|
+
def describe(description)
|
288
|
+
wrap_impl(@impl.describe(unwrap_impl(description)))
|
289
|
+
end
|
290
|
+
|
277
291
|
#
|
278
292
|
# Programmatically dispatch an event on the matching element.
|
279
293
|
#
|
@@ -393,6 +407,13 @@ module Playwright
|
|
393
407
|
# If `expression` throws or rejects, this method throws.
|
394
408
|
#
|
395
409
|
# **Usage**
|
410
|
+
#
|
411
|
+
# Passing argument to `expression`:
|
412
|
+
#
|
413
|
+
# ```python sync
|
414
|
+
# result = page.get_by_testid("myId").evaluate("(element, [x, y]) => element.textContent + ' ' + x * y", [7, 8])
|
415
|
+
# print(result) # prints "myId text 56"
|
416
|
+
# ```
|
396
417
|
def evaluate(expression, arg: nil, timeout: nil)
|
397
418
|
wrap_impl(@impl.evaluate(unwrap_impl(expression), arg: unwrap_impl(arg), timeout: unwrap_impl(timeout)))
|
398
419
|
end
|
@@ -1246,8 +1267,13 @@ module Playwright
|
|
1246
1267
|
end
|
1247
1268
|
|
1248
1269
|
# @nodoc
|
1249
|
-
def expect(expression, options)
|
1250
|
-
wrap_impl(@impl.expect(unwrap_impl(expression), unwrap_impl(options)))
|
1270
|
+
def expect(expression, options, title)
|
1271
|
+
wrap_impl(@impl.expect(unwrap_impl(expression), unwrap_impl(options), unwrap_impl(title)))
|
1272
|
+
end
|
1273
|
+
|
1274
|
+
# @nodoc
|
1275
|
+
def generate_locator_string
|
1276
|
+
wrap_impl(@impl.generate_locator_string)
|
1251
1277
|
end
|
1252
1278
|
|
1253
1279
|
# @nodoc
|
@@ -72,6 +72,12 @@ module Playwright
|
|
72
72
|
wrap_impl(@impl.not_to_be_visible(timeout: unwrap_impl(timeout), visible: unwrap_impl(visible)))
|
73
73
|
end
|
74
74
|
|
75
|
+
#
|
76
|
+
# The opposite of [`method: LocatorAssertions.toContainClass`].
|
77
|
+
def not_to_contain_class(expected, timeout: nil)
|
78
|
+
wrap_impl(@impl.not_to_contain_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
79
|
+
end
|
80
|
+
|
75
81
|
#
|
76
82
|
# The opposite of [`method: LocatorAssertions.toContainText`].
|
77
83
|
def not_to_contain_text(expected, ignoreCase: nil, timeout: nil, useInnerText: nil)
|
@@ -328,6 +334,44 @@ module Playwright
|
|
328
334
|
wrap_impl(@impl.to_be_visible(timeout: unwrap_impl(timeout), visible: unwrap_impl(visible)))
|
329
335
|
end
|
330
336
|
|
337
|
+
#
|
338
|
+
# Ensures the `Locator` points to an element with given CSS classes. All classes from the asserted value, separated by spaces, must be present in the [Element.classList](https://developer.mozilla.org/en-US/docs/Web/API/Element/classList) in any order.
|
339
|
+
#
|
340
|
+
# **Usage**
|
341
|
+
#
|
342
|
+
# ```html
|
343
|
+
# <div class='middle selected row' id='component'></div>
|
344
|
+
# ```
|
345
|
+
#
|
346
|
+
# ```python sync
|
347
|
+
# from playwright.sync_api import expect
|
348
|
+
#
|
349
|
+
# locator = page.locator("#component")
|
350
|
+
# expect(locator).to_contain_class("middle selected row")
|
351
|
+
# expect(locator).to_contain_class("selected")
|
352
|
+
# expect(locator).to_contain_class("row middle")
|
353
|
+
# ```
|
354
|
+
#
|
355
|
+
# When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class lists. Each element's class attribute is matched against the corresponding class in the array:
|
356
|
+
#
|
357
|
+
# ```html
|
358
|
+
# <div class='list'>
|
359
|
+
# <div class='component inactive'></div>
|
360
|
+
# <div class='component active'></div>
|
361
|
+
# <div class='component inactive'></div>
|
362
|
+
# </div>
|
363
|
+
# ```
|
364
|
+
#
|
365
|
+
# ```python sync
|
366
|
+
# from playwright.sync_api import expect
|
367
|
+
#
|
368
|
+
# locator = page.locator(".list > .component")
|
369
|
+
# await expect(locator).to_contain_class(["inactive", "active", "inactive"])
|
370
|
+
# ```
|
371
|
+
def to_contain_class(expected, timeout: nil)
|
372
|
+
wrap_impl(@impl.to_contain_class(unwrap_impl(expected), timeout: unwrap_impl(timeout)))
|
373
|
+
end
|
374
|
+
|
331
375
|
#
|
332
376
|
# Ensures the `Locator` points to an element that contains the given text. All nested elements will be considered when computing the text content of the element. You can use regular expressions for the value as well.
|
333
377
|
#
|
@@ -439,7 +483,7 @@ module Playwright
|
|
439
483
|
end
|
440
484
|
|
441
485
|
#
|
442
|
-
# Ensures the `Locator` points to an element with given CSS classes. When a string is provided, it must fully match the element's `class` attribute. To match individual classes
|
486
|
+
# Ensures the `Locator` points to an element with given CSS classes. When a string is provided, it must fully match the element's `class` attribute. To match individual classes use [`method: LocatorAssertions.toContainClass`].
|
443
487
|
#
|
444
488
|
# **Usage**
|
445
489
|
#
|
@@ -451,8 +495,8 @@ module Playwright
|
|
451
495
|
# from playwright.sync_api import expect
|
452
496
|
#
|
453
497
|
# locator = page.locator("#component")
|
454
|
-
# expect(locator).to_have_class(re.compile(r"(^|\\s)selected(\\s|$)"))
|
455
498
|
# expect(locator).to_have_class("middle selected row")
|
499
|
+
# expect(locator).to_have_class(re.compile(r"(^|\\s)selected(\\s|$)"))
|
456
500
|
# ```
|
457
501
|
#
|
458
502
|
# When an array is passed, the method asserts that the list of elements located matches the corresponding list of expected class values. Each element's class attribute is matched against the corresponding string or regular expression in the array:
|
@@ -460,7 +504,7 @@ module Playwright
|
|
460
504
|
# ```python sync
|
461
505
|
# from playwright.sync_api import expect
|
462
506
|
#
|
463
|
-
# locator = page.locator("list > .component")
|
507
|
+
# locator = page.locator(".list > .component")
|
464
508
|
# expect(locator).to_have_class(["component", "component selected", "component"])
|
465
509
|
# ```
|
466
510
|
def to_have_class(expected, timeout: nil)
|