playwright-ruby-client 1.37.1 → 1.38.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -7
  3. data/documentation/docs/api/download.md +17 -7
  4. data/documentation/docs/api/element_handle.md +1 -14
  5. data/documentation/docs/api/frame.md +1 -6
  6. data/documentation/docs/api/keyboard.md +4 -0
  7. data/documentation/docs/api/locator.md +31 -16
  8. data/documentation/docs/api/locator_assertions.md +684 -0
  9. data/documentation/docs/api/page.md +1 -6
  10. data/documentation/docs/api/request.md +17 -0
  11. data/documentation/docs/include/api_coverage.md +44 -0
  12. data/lib/playwright/channel.rb +1 -1
  13. data/lib/playwright/channel_owners/browser_context.rb +15 -0
  14. data/lib/playwright/channel_owners/page.rb +2 -0
  15. data/lib/playwright/channel_owners/request.rb +17 -1
  16. data/lib/playwright/channel_owners/route.rb +5 -1
  17. data/lib/playwright/errors.rb +15 -2
  18. data/lib/playwright/events.rb +1 -0
  19. data/lib/playwright/javascript/value_parser.rb +8 -0
  20. data/lib/playwright/javascript/value_serializer.rb +11 -5
  21. data/lib/playwright/locator_assertions_impl.rb +417 -0
  22. data/lib/playwright/locator_impl.rb +28 -5
  23. data/lib/playwright/test.rb +68 -0
  24. data/lib/playwright/utils.rb +4 -0
  25. data/lib/playwright/version.rb +2 -2
  26. data/lib/playwright_api/download.rb +12 -3
  27. data/lib/playwright_api/element_handle.rb +1 -14
  28. data/lib/playwright_api/frame.rb +1 -6
  29. data/lib/playwright_api/keyboard.rb +4 -0
  30. data/lib/playwright_api/locator.rb +31 -16
  31. data/lib/playwright_api/locator_assertions.rb +538 -0
  32. data/lib/playwright_api/page.rb +1 -6
  33. data/lib/playwright_api/request.rb +17 -0
  34. data/lib/playwright_api/worker.rb +4 -4
  35. data/sig/playwright.rbs +44 -0
  36. metadata +7 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 00d50bbadac84d3bfa4881ee450991e7e0999c9ca5daab2343bceb885d90522b
4
- data.tar.gz: 16bfdd05cc45587c02a89a9e9098c32a518c3e6b81e254524393e71b47483391
3
+ metadata.gz: 88f3401d3e186312c93e17fa2758d30cdd45c7a95676af608b87a8052d548355
4
+ data.tar.gz: c0ac53d04666186f7ae9dc892c5c4a8a5ea982739c4a38e0740c5cece26543d0
5
5
  SHA512:
6
- metadata.gz: 4e936a99c032fb86e7865cc8880c6679a23b2d621624a98b31d528a7c9d9886851b02b6cb9bab43937bf85b85a2d27ee2cbb0d15d25a11f2962066991531eac0
7
- data.tar.gz: 5e3c6c5bf4af0df7129d6c5ed1ebd6b29928ed68b10b698eb3385ac414c3a04a7ec4a96b964feffa6a65e2f96a7821c3dea8e5b841d186312a66ec1ad53ad825
6
+ metadata.gz: bf802105e56ef6c3b3786ac24c53092eb32780cb0d98232c940cdbd8fb2cc44355d741c5d27312517e3c7ff5b63d683a4c6f4e6b939f99f62b56dcc2741e28f9
7
+ data.tar.gz: 1b0a0e47e92cbeb8f5142b54416ceeeaf8a16d5428452225433da0449f85ecfe77f6157ea794c29c308d311eda0e0e79b4cdac48238b82c9b6175b65602768b3
data/README.md CHANGED
@@ -51,18 +51,24 @@ Playwright.create(playwright_cli_executable_path: './node_modules/.bin/playwrigh
51
51
  page = browser.new_page
52
52
  page.goto('https://github.com/')
53
53
 
54
- form = page.query_selector("form.js-site-search-form")
55
- search_input = form.query_selector("input.header-search-input")
56
- search_input.click
54
+ page.get_by_placeholder("Search or jump to...").click
55
+ page.locator('input[name="query-builder-test"]').click
56
+
57
+ expect(page.keyboard).to be_a(::Playwright::Keyboard)
58
+
57
59
  page.keyboard.type("playwright")
58
60
  page.expect_navigation {
59
61
  page.keyboard.press("Enter")
60
62
  }
61
63
 
62
- list = page.query_selector("ul.repo-list")
63
- items = list.query_selector_all("div.f4")
64
- items.each do |item|
65
- title = item.eval_on_selector("a", "a => a.innerText")
64
+ list = page.get_by_test_id('results-list').locator('.search-title')
65
+
66
+ # wait for item to appear
67
+ list.first.wait_for
68
+
69
+ # list them
70
+ list.locator('.search-title').all.each do |item|
71
+ title = item.text_content
66
72
  puts("==> #{title}")
67
73
  end
68
74
  end
@@ -10,15 +10,18 @@ sidebar_position: 10
10
10
  All the downloaded files belonging to the browser context are deleted when the
11
11
  browser context is closed.
12
12
 
13
- Download event is emitted once the download starts. Download path becomes available once download completes:
13
+ Download event is emitted once the download starts. Download path becomes available once download completes.
14
14
 
15
- ```ruby
16
- download = page.expect_download do
17
- page.get_by_text("Download file").click
18
- end
15
+ ```python sync title=example_c247767083cf193df26a39a61a3a8bc19d63ed5c24db91b88c50b7d37975005d.py
16
+ # Start waiting for the download
17
+ with page.expect_download() as download_info:
18
+ # Perform the action that initiates download
19
+ page.get_by_text("Download file").click()
20
+ download = download_info.value
21
+
22
+ # Wait for the download process to complete and save the downloaded file somewhere
23
+ download.save_as("/path/to/save/at/" + download.suggested_filename)
19
24
 
20
- # wait for download to complete
21
- path = download.path
22
25
  ```
23
26
 
24
27
  ## cancel
@@ -81,6 +84,13 @@ def save_as(path)
81
84
  Copy the download to a user-specified path. It is safe to call this method while the download
82
85
  is still in progress. Will wait for the download to finish if necessary.
83
86
 
87
+ **Usage**
88
+
89
+ ```python sync title=example_66ffd4ef7286957e4294d84b8f660ff852c87af27a56b3e4dd9f84562b5ece02.py
90
+ download.save_as("/path/to/save/at/" + download.suggested_filename)
91
+
92
+ ```
93
+
84
94
  ## suggested_filename
85
95
 
86
96
  ```
@@ -259,7 +259,7 @@ This method waits for [actionability](https://playwright.dev/python/docs/actiona
259
259
 
260
260
  If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
261
261
 
262
- To send fine-grained keyboard events, use [ElementHandle#type](./element_handle#type).
262
+ To send fine-grained keyboard events, use [Locator#press_sequentially](./locator#press_sequentially).
263
263
 
264
264
  ## focus
265
265
 
@@ -614,19 +614,6 @@ To press a special key, like `Control` or `ArrowDown`, use [ElementHandle#press]
614
614
 
615
615
  **Usage**
616
616
 
617
- ```ruby
618
- element_handle.type("hello") # types instantly
619
- element_handle.type("world", delay: 100) # types slower, like a user
620
- ```
621
-
622
- An example of typing into a text field and then submitting the form:
623
-
624
- ```ruby
625
- element_handle = page.query_selector("input")
626
- element_handle.type("some text")
627
- element_handle.press("Enter")
628
- ```
629
-
630
617
  ## uncheck
631
618
 
632
619
  ```
@@ -349,7 +349,7 @@ This method waits for an element matching `selector`, waits for [actionability](
349
349
 
350
350
  If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
351
351
 
352
- To send fine-grained keyboard events, use [Frame#type](./frame#type).
352
+ To send fine-grained keyboard events, use [Locator#press_sequentially](./locator#press_sequentially).
353
353
 
354
354
  ## focus
355
355
 
@@ -1041,11 +1041,6 @@ To press a special key, like `Control` or `ArrowDown`, use [Keyboard#press](./ke
1041
1041
 
1042
1042
  **Usage**
1043
1043
 
1044
- ```ruby
1045
- frame.type("#mytextarea", "hello") # types instantly
1046
- frame.type("#mytextarea", "world", delay: 100) # types slower, like a user
1047
- ```
1048
-
1049
1044
  ## uncheck
1050
1045
 
1051
1046
  ```
@@ -97,6 +97,8 @@ def press(key, delay: nil)
97
97
  ```
98
98
 
99
99
 
100
+ **NOTE**: In most cases, you should use [Locator#press](./locator#press) instead.
101
+
100
102
  `key` can specify the intended
101
103
  [keyboardEvent.key](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key) value or a single character to
102
104
  generate the text for. A superset of the `key` values can be found
@@ -136,6 +138,8 @@ def type(text, delay: nil)
136
138
  ```
137
139
 
138
140
 
141
+ **NOTE**: In most cases, you should use [Locator#fill](./locator#fill) instead. You only need to press keys one by one if there is special keyboard handling on the page - in this case use [Locator#press_sequentially](./locator#press_sequentially).
142
+
139
143
  Sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
140
144
 
141
145
  To press a special key, like `Control` or `ArrowDown`, use [Keyboard#press](./keyboard#press).
@@ -458,7 +458,7 @@ This method waits for [actionability](https://playwright.dev/python/docs/actiona
458
458
 
459
459
  If the target element is not an `<input>`, `<textarea>` or `[contenteditable]` element, this method throws an error. However, if the element is inside the `<label>` element that has an associated [control](https://developer.mozilla.org/en-US/docs/Web/API/HTMLLabelElement/control), the control will be filled instead.
460
460
 
461
- To send fine-grained keyboard events, use [Locator#type](./locator#type).
461
+ To send fine-grained keyboard events, use [Locator#press_sequentially](./locator#press_sequentially).
462
462
 
463
463
  ## filter
464
464
 
@@ -1032,6 +1032,36 @@ respective texts.
1032
1032
  Shortcuts such as `key: "Control+o"` or `key: "Control+Shift+T"` are supported as well. When specified with the
1033
1033
  modifier, modifier is pressed and being held while the subsequent key is being pressed.
1034
1034
 
1035
+ ## press_sequentially
1036
+
1037
+ ```
1038
+ def press_sequentially(text, delay: nil, noWaitAfter: nil, timeout: nil)
1039
+ ```
1040
+
1041
+
1042
+ **NOTE**: In most cases, you should use [Locator#fill](./locator#fill) instead. You only need to press keys one by one if there is special keyboard handling on the page.
1043
+
1044
+ Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
1045
+
1046
+ To press a special key, like `Control` or `ArrowDown`, use [Locator#press](./locator#press).
1047
+
1048
+ **Usage**
1049
+
1050
+ ```python sync title=example_1b7781d5527574a18d4b9812e3461203d2acc9ba7e09cbfd0ffbc4154e3f5971.py
1051
+ locator.press_sequentially("hello") # types instantly
1052
+ locator.press_sequentially("world", delay=100) # types slower, like a user
1053
+
1054
+ ```
1055
+
1056
+ An example of typing into a text field and then submitting the form:
1057
+
1058
+ ```python sync title=example_cc0a6b9aa95b97e5c17c4b114da10a29c7f6f793e99aee1ea2703636af6e24f9.py
1059
+ locator = page.get_by_label("Password")
1060
+ locator.press_sequentially("my password")
1061
+ locator.press("Enter")
1062
+
1063
+ ```
1064
+
1035
1065
  ## screenshot
1036
1066
 
1037
1067
  ```
@@ -1254,27 +1284,12 @@ def type(text, delay: nil, noWaitAfter: nil, timeout: nil)
1254
1284
  ```
1255
1285
 
1256
1286
 
1257
- **NOTE**: In most cases, you should use [Locator#fill](./locator#fill) instead. You only need to type characters if there is special keyboard handling on the page.
1258
-
1259
1287
  Focuses the element, and then sends a `keydown`, `keypress`/`input`, and `keyup` event for each character in the text.
1260
1288
 
1261
1289
  To press a special key, like `Control` or `ArrowDown`, use [Locator#press](./locator#press).
1262
1290
 
1263
1291
  **Usage**
1264
1292
 
1265
- ```ruby
1266
- element.type("hello") # types instantly
1267
- element.type("world", delay: 100) # types slower, like a user
1268
- ```
1269
-
1270
- An example of typing into a text field and then submitting the form:
1271
-
1272
- ```ruby
1273
- element = page.get_by_label("Password")
1274
- element.type("my password")
1275
- element.press("Enter")
1276
- ```
1277
-
1278
1293
  ## uncheck
1279
1294
 
1280
1295
  ```