playwright-ruby-client 1.16.beta1 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/{fetch_request.md → api_request_context.md} +2 -2
  3. data/documentation/docs/api/browser_context.md +1 -1
  4. data/documentation/docs/api/element_handle.md +2 -3
  5. data/documentation/docs/api/frame.md +30 -0
  6. data/documentation/docs/api/frame_locator.md +70 -0
  7. data/documentation/docs/api/locator.md +17 -2
  8. data/documentation/docs/api/page.md +35 -4
  9. data/documentation/docs/api/request.md +3 -3
  10. data/documentation/docs/api/selectors.md +1 -1
  11. data/documentation/docs/api/tracing.md +2 -2
  12. data/documentation/docs/include/api_coverage.md +25 -7
  13. data/lib/playwright/channel.rb +1 -1
  14. data/lib/playwright/channel_owners/api_request_context.rb +4 -0
  15. data/lib/playwright/channel_owners/artifact.rb +1 -6
  16. data/lib/playwright/channel_owners/browser.rb +6 -8
  17. data/lib/playwright/channel_owners/browser_context.rb +5 -3
  18. data/lib/playwright/channel_owners/browser_type.rb +0 -1
  19. data/lib/playwright/channel_owners/fetch_request.rb +5 -1
  20. data/lib/playwright/channel_owners/frame.rb +10 -6
  21. data/lib/playwright/channel_owners/page.rb +18 -10
  22. data/lib/playwright/channel_owners/request.rb +9 -21
  23. data/lib/playwright/channel_owners/response.rb +0 -4
  24. data/lib/playwright/connection.rb +9 -0
  25. data/lib/playwright/frame_locator_impl.rb +49 -0
  26. data/lib/playwright/locator_impl.rb +13 -5
  27. data/lib/playwright/route_handler.rb +13 -1
  28. data/lib/playwright/tracing_impl.rb +6 -9
  29. data/lib/playwright/version.rb +2 -2
  30. data/lib/playwright/video.rb +3 -0
  31. data/lib/playwright.rb +2 -1
  32. data/lib/playwright_api/api_request_context.rb +149 -0
  33. data/lib/playwright_api/browser_context.rb +6 -1
  34. data/lib/playwright_api/element_handle.rb +2 -3
  35. data/lib/playwright_api/frame.rb +26 -1
  36. data/lib/playwright_api/frame_locator.rb +51 -0
  37. data/lib/playwright_api/locator.rb +12 -2
  38. data/lib/playwright_api/page.rb +35 -9
  39. data/lib/playwright_api/playwright.rb +5 -0
  40. data/lib/playwright_api/selectors.rb +2 -2
  41. data/lib/playwright_api/tracing.rb +4 -4
  42. metadata +12 -8
  43. data/lib/playwright_api/fetch_request.rb +0 -77
@@ -288,6 +288,9 @@ module Playwright
288
288
  wrap_impl(@impl.emulate_media(colorScheme: unwrap_impl(colorScheme), forcedColors: unwrap_impl(forcedColors), media: unwrap_impl(media), reducedMotion: unwrap_impl(reducedMotion)))
289
289
  end
290
290
 
291
+ # > NOTE: This method does not wait for the element to pass actionability checks and therefore can lead to the flaky
292
+ # tests. Use [`method: Locator.evaluate`], other `Locator` helper methods or web-first assertions instead.
293
+ #
291
294
  # The method finds an element matching the specified selector within the page and passes it as a first argument to
292
295
  # `expression`. If no elements match the selector, the method throws an error. Returns the value of `expression`.
293
296
  #
@@ -307,6 +310,9 @@ module Playwright
307
310
  wrap_impl(@impl.eval_on_selector(unwrap_impl(selector), unwrap_impl(expression), arg: unwrap_impl(arg), strict: unwrap_impl(strict)))
308
311
  end
309
312
 
313
+ # > NOTE: In most cases, [`method: Locator.evaluateAll`], other `Locator` helper methods and web-first assertions do a
314
+ # better job.
315
+ #
310
316
  # The method finds all elements matching the specified selector within the page and passes an array of matched elements as
311
317
  # a first argument to `expression`. Returns the result of `expression` invocation.
312
318
  #
@@ -349,7 +355,7 @@ module Playwright
349
355
  # `ElementHandle` instances can be passed as an argument to the [`method: Page.evaluate`]:
350
356
  #
351
357
  # ```python sync
352
- # body_handle = page.query_selector("body")
358
+ # body_handle = page.evaluate("document.body")
353
359
  # html = page.evaluate("([body, suffix]) => body.innerHTML + suffix", [body_handle, "hello"])
354
360
  # body_handle.dispose()
355
361
  # ```
@@ -533,6 +539,18 @@ module Playwright
533
539
  wrap_impl(@impl.frame(name: unwrap_impl(name), url: unwrap_impl(url)))
534
540
  end
535
541
 
542
+ # When working with iframes, you can create a frame locator that will enter the iframe and allow selecting elements in
543
+ # that iframe. Following snippet locates element with text "Submit" in the iframe with id `my-frame`, like `<iframe
544
+ # id="my-frame">`:
545
+ #
546
+ # ```python sync
547
+ # locator = page.frame_locator("#my-iframe").locator("text=Submit")
548
+ # locator.click()
549
+ # ```
550
+ def frame_locator(selector)
551
+ wrap_impl(@impl.frame_locator(unwrap_impl(selector)))
552
+ end
553
+
536
554
  # An array of all frames attached to the page.
537
555
  def frames
538
556
  wrap_impl(@impl.frames)
@@ -791,14 +809,18 @@ module Playwright
791
809
  wrap_impl(@impl.press(unwrap_impl(selector), unwrap_impl(key), delay: unwrap_impl(delay), noWaitAfter: unwrap_impl(noWaitAfter), strict: unwrap_impl(strict), timeout: unwrap_impl(timeout)))
792
810
  end
793
811
 
812
+ # > NOTE: The use of `ElementHandle` is discouraged, use `Locator` objects and web-first assertions instead.
813
+ #
794
814
  # The method finds an element matching the specified selector within the page. If no elements match the selector, the
795
- # return value resolves to `null`. To wait for an element on the page, use [`method: Page.waitForSelector`].
815
+ # return value resolves to `null`. To wait for an element on the page, use [`method: Locator.waitFor`].
796
816
  #
797
817
  # Shortcut for main frame's [`method: Frame.querySelector`].
798
818
  def query_selector(selector, strict: nil)
799
819
  wrap_impl(@impl.query_selector(unwrap_impl(selector), strict: unwrap_impl(strict)))
800
820
  end
801
821
 
822
+ # > NOTE: The use of `ElementHandle` is discouraged, use `Locator` objects and web-first assertions instead.
823
+ #
802
824
  # The method finds all elements matching the specified selector within the page. If no elements match the selector, the
803
825
  # return value resolves to `[]`.
804
826
  #
@@ -807,8 +829,8 @@ module Playwright
807
829
  wrap_impl(@impl.query_selector_all(unwrap_impl(selector)))
808
830
  end
809
831
 
810
- # Returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the
811
- # last redirect.
832
+ # This method reloads the current page, in the same way as if the user had triggered a browser refresh. Returns the main
833
+ # resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect.
812
834
  def reload(timeout: nil, waitUntil: nil)
813
835
  wrap_impl(@impl.reload(timeout: unwrap_impl(timeout), waitUntil: unwrap_impl(waitUntil)))
814
836
  end
@@ -990,7 +1012,8 @@ module Playwright
990
1012
  # [`method: Browser.newContext`] allows to set viewport size (and more) for all pages in the context at once.
991
1013
  #
992
1014
  # `page.setViewportSize` will resize the page. A lot of websites don't expect phones to change size, so you should set the
993
- # viewport size before navigating to the page.
1015
+ # viewport size before navigating to the page. [`method: Page.setViewportSize`] will also reset `screen` size, use
1016
+ # [`method: Browser.newContext`] with `screen` and `viewport` parameters if you need better control of these properties.
994
1017
  #
995
1018
  # ```python sync
996
1019
  # page = browser.new_page()
@@ -1266,6 +1289,9 @@ module Playwright
1266
1289
  # Returns when element specified by selector satisfies `state` option. Returns `null` if waiting for `hidden` or
1267
1290
  # `detached`.
1268
1291
  #
1292
+ # > NOTE: Playwright automatically waits for element to be ready before performing an action. Using `Locator` objects and
1293
+ # web-first assertions make the code wait-for-selector-free.
1294
+ #
1269
1295
  # Wait for the `selector` to satisfy `state` option (either appear/disappear from dom, or become visible/hidden). If at
1270
1296
  # the moment of calling the method `selector` already satisfies the condition, the method will return immediately. If the
1271
1297
  # selector doesn't satisfy the condition for the `timeout` milliseconds, the function will throw.
@@ -1366,13 +1392,13 @@ module Playwright
1366
1392
  end
1367
1393
 
1368
1394
  # @nodoc
1369
- def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1370
- wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1395
+ def stop_css_coverage
1396
+ wrap_impl(@impl.stop_css_coverage)
1371
1397
  end
1372
1398
 
1373
1399
  # @nodoc
1374
- def stop_css_coverage
1375
- wrap_impl(@impl.stop_css_coverage)
1400
+ def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1401
+ wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1376
1402
  end
1377
1403
 
1378
1404
  # @nodoc
@@ -50,6 +50,11 @@ module Playwright
50
50
  wrap_impl(@impl.firefox)
51
51
  end
52
52
 
53
+ # Exposes API that can be used for the Web API testing.
54
+ def request # property
55
+ raise NotImplementedError.new('request is not implemented yet.')
56
+ end
57
+
53
58
  # Selectors can be used to install custom selector engines. See [Working with selectors](./selectors.md) for more
54
59
  # information.
55
60
  def selectors # property
@@ -28,11 +28,11 @@ module Playwright
28
28
  # page.set_content('<div><button>Click me</button></div>')
29
29
  #
30
30
  # # Use the selector prefixed with its name.
31
- # button = page.query_selector('tag=button')
31
+ # button = page.locator('tag=button')
32
32
  # # Combine it with other selector engines.
33
33
  # page.click('tag=div >> text="Click me"')
34
34
  # # Can use it in any methods supporting selectors.
35
- # button_count = page.eval_on_selector_all('tag=button', 'buttons => buttons.length')
35
+ # button_count = page.locator('tag=button').count()
36
36
  # print(button_count)
37
37
  # browser.close()
38
38
  #
@@ -22,8 +22,8 @@ module Playwright
22
22
  # page.goto("https://playwright.dev")
23
23
  # context.tracing.stop(path = "trace.zip")
24
24
  # ```
25
- def start(name: nil, screenshots: nil, snapshots: nil)
26
- wrap_impl(@impl.start(name: unwrap_impl(name), screenshots: unwrap_impl(screenshots), snapshots: unwrap_impl(snapshots)))
25
+ def start(name: nil, screenshots: nil, snapshots: nil, title: nil)
26
+ wrap_impl(@impl.start(name: unwrap_impl(name), screenshots: unwrap_impl(screenshots), snapshots: unwrap_impl(snapshots), title: unwrap_impl(title)))
27
27
  end
28
28
 
29
29
  # Start a new trace chunk. If you'd like to record multiple traces on the same `BrowserContext`, use
@@ -45,8 +45,8 @@ module Playwright
45
45
  # # Save a second trace file with different actions.
46
46
  # context.tracing.stop_chunk(path = "trace2.zip")
47
47
  # ```
48
- def start_chunk
49
- wrap_impl(@impl.start_chunk)
48
+ def start_chunk(title: nil)
49
+ wrap_impl(@impl.start_chunk(title: unwrap_impl(title)))
50
50
  end
51
51
 
52
52
  # Stop tracing.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playwright-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.16.beta1
4
+ version: 1.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-01 00:00:00.000000000 Z
11
+ date: 2021-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -210,6 +210,7 @@ files:
210
210
  - documentation/README.md
211
211
  - documentation/babel.config.js
212
212
  - documentation/docs/api/accessibility.md
213
+ - documentation/docs/api/api_request_context.md
213
214
  - documentation/docs/api/browser.md
214
215
  - documentation/docs/api/browser_context.md
215
216
  - documentation/docs/api/browser_type.md
@@ -224,9 +225,9 @@ files:
224
225
  - documentation/docs/api/experimental/android_input.md
225
226
  - documentation/docs/api/experimental/android_socket.md
226
227
  - documentation/docs/api/experimental/android_web_view.md
227
- - documentation/docs/api/fetch_request.md
228
228
  - documentation/docs/api/file_chooser.md
229
229
  - documentation/docs/api/frame.md
230
+ - documentation/docs/api/frame_locator.md
230
231
  - documentation/docs/api/js_handle.md
231
232
  - documentation/docs/api/keyboard.md
232
233
  - documentation/docs/api/locator.md
@@ -278,6 +279,7 @@ files:
278
279
  - lib/playwright/channel_owner.rb
279
280
  - lib/playwright/channel_owners/android.rb
280
281
  - lib/playwright/channel_owners/android_device.rb
282
+ - lib/playwright/channel_owners/api_request_context.rb
281
283
  - lib/playwright/channel_owners/artifact.rb
282
284
  - lib/playwright/channel_owners/binding_call.rb
283
285
  - lib/playwright/channel_owners/browser.rb
@@ -307,6 +309,7 @@ files:
307
309
  - lib/playwright/event_emitter_proxy.rb
308
310
  - lib/playwright/events.rb
309
311
  - lib/playwright/file_chooser_impl.rb
312
+ - lib/playwright/frame_locator_impl.rb
310
313
  - lib/playwright/http_headers.rb
311
314
  - lib/playwright/input_files.rb
312
315
  - lib/playwright/javascript.rb
@@ -337,6 +340,7 @@ files:
337
340
  - lib/playwright_api/android_input.rb
338
341
  - lib/playwright_api/android_socket.rb
339
342
  - lib/playwright_api/android_web_view.rb
343
+ - lib/playwright_api/api_request_context.rb
340
344
  - lib/playwright_api/browser.rb
341
345
  - lib/playwright_api/browser_context.rb
342
346
  - lib/playwright_api/browser_type.rb
@@ -345,9 +349,9 @@ files:
345
349
  - lib/playwright_api/dialog.rb
346
350
  - lib/playwright_api/download.rb
347
351
  - lib/playwright_api/element_handle.rb
348
- - lib/playwright_api/fetch_request.rb
349
352
  - lib/playwright_api/file_chooser.rb
350
353
  - lib/playwright_api/frame.rb
354
+ - lib/playwright_api/frame_locator.rb
351
355
  - lib/playwright_api/js_handle.rb
352
356
  - lib/playwright_api/keyboard.rb
353
357
  - lib/playwright_api/locator.rb
@@ -378,12 +382,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
378
382
  version: '2.4'
379
383
  required_rubygems_version: !ruby/object:Gem::Requirement
380
384
  requirements:
381
- - - ">"
385
+ - - ">="
382
386
  - !ruby/object:Gem::Version
383
- version: 1.3.1
387
+ version: '0'
384
388
  requirements: []
385
- rubygems_version: 3.2.22
389
+ rubygems_version: 3.2.32
386
390
  signing_key:
387
391
  specification_version: 4
388
- summary: The Ruby binding of playwright driver 1.16.0
392
+ summary: The Ruby binding of playwright driver 1.17.0
389
393
  test_files: []
@@ -1,77 +0,0 @@
1
- module Playwright
2
- # This API is used for Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
3
- # environment or the service to your e2e test. When used on `Page` or a `BrowserContext`, this API will automatically use
4
- # the cookies from the corresponding `BrowserContext`. This means that if you log in using this API, your e2e test will be
5
- # logged in and vice versa.
6
- class FetchRequest < PlaywrightApi
7
-
8
- # All responses received through [`method: FetchRequest.fetch`], [`method: FetchRequest.get`],
9
- # [`method: FetchRequest.post`] and other methods are stored in the memory, so that you can later call
10
- # [`method: FetchResponse.body`]. This method discards all stored responses, and makes [`method: FetchResponse.body`]
11
- # throw "Response disposed" error.
12
- def dispose
13
- raise NotImplementedError.new('dispose is not implemented yet.')
14
- end
15
-
16
- # Sends HTTP(S) fetch and returns its response. The method will populate fetch cookies from the context and update context
17
- # cookies from the response. The method will automatically follow redirects.
18
- def fetch(
19
- urlOrRequest,
20
- data: nil,
21
- failOnStatusCode: nil,
22
- headers: nil,
23
- ignoreHTTPSErrors: nil,
24
- method: nil,
25
- params: nil,
26
- timeout: nil)
27
- raise NotImplementedError.new('fetch is not implemented yet.')
28
- end
29
-
30
- # Sends HTTP(S) GET request and returns its response. The method will populate fetch cookies from the context and update
31
- # context cookies from the response. The method will automatically follow redirects.
32
- def get(
33
- urlOrRequest,
34
- failOnStatusCode: nil,
35
- headers: nil,
36
- ignoreHTTPSErrors: nil,
37
- params: nil,
38
- timeout: nil)
39
- raise NotImplementedError.new('get is not implemented yet.')
40
- end
41
-
42
- # Sends HTTP(S) fetch and returns its response. The method will populate fetch cookies from the context and update context
43
- # cookies from the response. The method will automatically follow redirects.
44
- def post(
45
- urlOrRequest,
46
- data: nil,
47
- failOnStatusCode: nil,
48
- headers: nil,
49
- ignoreHTTPSErrors: nil,
50
- params: nil,
51
- timeout: nil)
52
- raise NotImplementedError.new('post is not implemented yet.')
53
- end
54
-
55
- # -- inherited from EventEmitter --
56
- # @nodoc
57
- def off(event, callback)
58
- event_emitter_proxy.off(event, callback)
59
- end
60
-
61
- # -- inherited from EventEmitter --
62
- # @nodoc
63
- def once(event, callback)
64
- event_emitter_proxy.once(event, callback)
65
- end
66
-
67
- # -- inherited from EventEmitter --
68
- # @nodoc
69
- def on(event, callback)
70
- event_emitter_proxy.on(event, callback)
71
- end
72
-
73
- private def event_emitter_proxy
74
- @event_emitter_proxy ||= EventEmitterProxy.new(self, @impl)
75
- end
76
- end
77
- end