playwright-ruby-client 1.20.2 → 1.21.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/documentation/docs/api/api_request_context.md +15 -2
  3. data/documentation/docs/api/browser_type.md +1 -1
  4. data/documentation/docs/api/console_message.md +27 -1
  5. data/documentation/docs/api/element_handle.md +4 -2
  6. data/documentation/docs/api/experimental/android.md +1 -1
  7. data/documentation/docs/api/frame_locator.md +1 -1
  8. data/documentation/docs/api/locator.md +3 -1
  9. data/documentation/docs/api/page.md +4 -1
  10. data/documentation/package.json +6 -6
  11. data/documentation/yarn.lock +2931 -3220
  12. data/lib/playwright/channel_owners/browser_context.rb +8 -0
  13. data/lib/playwright/channel_owners/element_handle.rb +12 -3
  14. data/lib/playwright/channel_owners/frame.rb +4 -5
  15. data/lib/playwright/channel_owners/page.rb +11 -7
  16. data/lib/playwright/channel_owners/writable_stream.rb +14 -0
  17. data/lib/playwright/input_files.rb +60 -8
  18. data/lib/playwright/locator_impl.rb +5 -0
  19. data/lib/playwright/transport.rb +12 -2
  20. data/lib/playwright/version.rb +2 -2
  21. data/lib/playwright_api/accessibility.rb +2 -1
  22. data/lib/playwright_api/android.rb +8 -8
  23. data/lib/playwright_api/android_device.rb +6 -6
  24. data/lib/playwright_api/api_request.rb +3 -3
  25. data/lib/playwright_api/api_request_context.rb +21 -8
  26. data/lib/playwright_api/browser.rb +6 -6
  27. data/lib/playwright_api/browser_context.rb +11 -11
  28. data/lib/playwright_api/browser_type.rb +8 -8
  29. data/lib/playwright_api/cdp_session.rb +6 -6
  30. data/lib/playwright_api/console_message.rb +26 -7
  31. data/lib/playwright_api/dialog.rb +6 -6
  32. data/lib/playwright_api/element_handle.rb +40 -38
  33. data/lib/playwright_api/frame.rb +24 -24
  34. data/lib/playwright_api/frame_locator.rb +1 -1
  35. data/lib/playwright_api/js_handle.rb +6 -6
  36. data/lib/playwright_api/locator.rb +22 -20
  37. data/lib/playwright_api/page.rb +31 -28
  38. data/lib/playwright_api/playwright.rb +9 -9
  39. data/lib/playwright_api/request.rb +6 -6
  40. data/lib/playwright_api/response.rb +6 -6
  41. data/lib/playwright_api/route.rb +6 -6
  42. data/lib/playwright_api/selectors.rb +7 -7
  43. data/lib/playwright_api/tracing.rb +7 -7
  44. data/lib/playwright_api/web_socket.rb +6 -6
  45. data/lib/playwright_api/worker.rb +8 -8
  46. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf7d8c81cfea6013b4c2f002b93f5b705b75db9cf5ce633ed99beda7d41263f6
4
- data.tar.gz: f8a705969e6aa35661b4de50ce15e94b763ddd8b7b1c454e9a323a421fa3748b
3
+ metadata.gz: 5e2dee736be02c56e75b6a89e2eab014c4d205ca23688b30084ea3854f50dfda
4
+ data.tar.gz: a213f955daad15c58bc1edd1b123cb6768cbc6df5ec6be0b09e537a8b6ea22ec
5
5
  SHA512:
6
- metadata.gz: 8971e9467e336ea9915bc1b4ec6f1b1598e6a0a797271de5897deda8073fdc16d13d346146563c1e549de4c064a8100c853248b97de2072851727465ed6e432d
7
- data.tar.gz: 4245aeee24a0004ca5d8259e01b5026bab8c32f2567c6eb2e7dfa6524d01359d3cd34d495f3bd83f95443d0776c0ea4e5cd326d857de2b886cfd6eb83084ec3f
6
+ metadata.gz: eba2fed3585b9ef5aa1b068cfc3294acc0f134e1ecccec6fae465bfd8df52c2395d02d706cb8958342c8e1af8be2066b537bc7af9eb3da1fe3748536677ba0c0
7
+ data.tar.gz: 2264ea9fd32bd7b02e15453a17876c2ee5fa8d51fb5eca652242959254ead0fda4ee721e9c35a1a24c1dc005d42268fd49b4566bd844841499bb8933ba83b8a3
@@ -5,10 +5,23 @@ sidebar_position: 10
5
5
  # APIRequestContext
6
6
 
7
7
  This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
8
- environment or the service to your e2e test. When used on [Page](./page) or a [BrowserContext](./browser_context), this API will automatically use
9
- the cookies from the corresponding [BrowserContext](./browser_context). This means that if you log in using this API, your e2e test will be
8
+ environment or the service to your e2e test.
9
+
10
+ Each Playwright browser context has associated with it [APIRequestContext](./api_request_context) instance which shares cookie storage with the
11
+ browser context and can be accessed via [BrowserContext#request](./browser_context#request) or [Page#request](./page#request). It is also
12
+ possible to create a new APIRequestContext instance manually by calling [APIRequest#new_context](./api_request#new_context).
13
+
14
+ **Cookie management**
15
+
16
+ [APIRequestContext](./api_request_context) retuned by [BrowserContext#request](./browser_context#request) and [Page#request](./page#request) shares cookie storage
17
+ with the corresponding [BrowserContext](./browser_context). Each API request will have `Cookie` header populated with the values from the
18
+ browser context. If the API response contains `Set-Cookie` header it will automatically update [BrowserContext](./browser_context) cookies
19
+ and requests made from the page will pick them up. This means that if you log in using this API, your e2e test will be
10
20
  logged in and vice versa.
11
21
 
22
+ If you want API requests to not interfere with the browser cookies you shoud create a new [APIRequestContext](./api_request_context) by calling
23
+ [APIRequest#new_context](./api_request#new_context). Such [APIRequestContext](./api_request_context) object will have its own isolated cookie storage.
24
+
12
25
  ```ruby
13
26
  playwright.chromium.launch do |browser|
14
27
  # This will launch a new browser, create a context and page. When making HTTP
@@ -31,7 +31,7 @@ def connect_over_cdp(
31
31
  &block)
32
32
  ```
33
33
 
34
- This methods attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
34
+ This method attaches Playwright to an existing browser instance using the Chrome DevTools Protocol.
35
35
 
36
36
  The default browser context is accessible via [Browser#contexts](./browser#contexts).
37
37
 
@@ -4,7 +4,33 @@ sidebar_position: 10
4
4
 
5
5
  # ConsoleMessage
6
6
 
7
- [ConsoleMessage](./console_message) objects are dispatched by page via the [`event: Page.console`] event.
7
+ [ConsoleMessage](./console_message) objects are dispatched by page via the [`event: Page.console`] event. For each console messages logged
8
+ in the page there will be corresponding event in the Playwright context.
9
+
10
+ ```ruby
11
+ # Listen for all console logs
12
+ page.on("console", ->(msg) { puts msg.text })
13
+
14
+ # Listen for all console events and handle errors
15
+ page.on("console", ->(msg) {
16
+ if msg.type == 'error'
17
+ puts "error: #{msg.text}"
18
+ end
19
+ })
20
+
21
+ # Get the next console log
22
+ msg = page.expect_console_message do
23
+ # Issue console.log inside the page
24
+ page.evaluate("console.error('hello', 42, { foo: 'bar' })")
25
+ end
26
+
27
+ # Deconstruct print arguments
28
+ msg.args[0].json_value # => 'hello'
29
+ msg.args[1].json_value # => 42
30
+ msg.args[2].json_value # => { 'foo' => 'bar' }
31
+ ```
32
+
33
+
8
34
 
9
35
  ## args
10
36
 
@@ -436,10 +436,12 @@ The method finds all elements matching the specified selector in the [ElementHan
436
436
  ```
437
437
  def screenshot(
438
438
  animations: nil,
439
+ caret: nil,
439
440
  mask: nil,
440
441
  omitBackground: nil,
441
442
  path: nil,
442
443
  quality: nil,
444
+ scale: nil,
443
445
  timeout: nil,
444
446
  type: nil)
445
447
  ```
@@ -641,8 +643,8 @@ def wait_for_element_state(state, timeout: nil)
641
643
 
642
644
  Returns when the element satisfies the `state`.
643
645
 
644
- Depending on the `state` parameter, this method waits for one of the [actionability](https://playwright.dev/python/docs/actionability) checks to pass.
645
- This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
646
+ Depending on the `state` parameter, this method waits for one of the [actionability](https://playwright.dev/python/docs/actionability) checks to
647
+ pass. This method throws when the element is detached while waiting, unless waiting for the `"hidden"` state.
646
648
  - `"visible"` Wait until the element is [visible](https://playwright.dev/python/docs/actionability).
647
649
  - `"hidden"` Wait until the element is [not visible](https://playwright.dev/python/docs/actionability) or
648
650
  [not attached](https://playwright.dev/python/docs/actionability). Note that waiting for hidden does not throw when the element detaches.
@@ -33,7 +33,7 @@ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm i -D playwright
33
33
  ## devices
34
34
 
35
35
  ```
36
- def devices(port: nil)
36
+ def devices(omitDriverInstall: nil, port: nil)
37
37
  ```
38
38
 
39
39
  Returns the list of detected Android devices.
@@ -76,4 +76,4 @@ The method finds an element matching the specified selector in the FrameLocator'
76
76
  def nth(index)
77
77
  ```
78
78
 
79
- Returns locator to the n-th matching frame.
79
+ Returns locator to the n-th matching frame. It's zero based, `nth(0)` selects the first frame.
@@ -450,7 +450,7 @@ The method finds an element matching the specified selector in the [Locator](./l
450
450
  def nth(index)
451
451
  ```
452
452
 
453
- Returns locator to the n-th matching element.
453
+ Returns locator to the n-th matching element. It's zero based, `nth(0)` selects the first element.
454
454
 
455
455
  ## page
456
456
 
@@ -490,10 +490,12 @@ modifier, modifier is pressed and being held while the subsequent key is being p
490
490
  ```
491
491
  def screenshot(
492
492
  animations: nil,
493
+ caret: nil,
493
494
  mask: nil,
494
495
  omitBackground: nil,
495
496
  path: nil,
496
497
  quality: nil,
498
+ scale: nil,
497
499
  timeout: nil,
498
500
  type: nil)
499
501
  ```
@@ -1013,12 +1013,14 @@ To remove a route with its handler you can use [Page#unroute](./page#unroute).
1013
1013
  ```
1014
1014
  def screenshot(
1015
1015
  animations: nil,
1016
+ caret: nil,
1016
1017
  clip: nil,
1017
1018
  fullPage: nil,
1018
1019
  mask: nil,
1019
1020
  omitBackground: nil,
1020
1021
  path: nil,
1021
1022
  quality: nil,
1023
+ scale: nil,
1022
1024
  timeout: nil,
1023
1025
  type: nil)
1024
1026
  ```
@@ -1606,6 +1608,7 @@ associated with the page.
1606
1608
 
1607
1609
  ## request
1608
1610
 
1609
- API testing helper associated with this page. Requests made with this API will use page cookies.
1611
+ API testing helper associated with this page. This method returns the same instance as
1612
+ [BrowserContext#request](./browser_context#request) on the page's context. See [BrowserContext#request](./browser_context#request) for more details.
1610
1613
 
1611
1614
  ## touchscreen
@@ -14,14 +14,14 @@
14
14
  "write-heading-ids": "docusaurus write-heading-ids"
15
15
  },
16
16
  "dependencies": {
17
- "@docusaurus/core": "^2.0.0-beta.6",
18
- "@docusaurus/preset-classic": "^2.0.0-beta.6",
19
- "@mdx-js/react": "^1.6.21",
20
- "@svgr/webpack": "^5.5.0",
17
+ "@docusaurus/core": "^2.0.0-beta.18",
18
+ "@docusaurus/preset-classic": "^2.0.0-beta.18",
19
+ "@mdx-js/react": "^1.6.22",
20
+ "@svgr/webpack": "^6.2.1",
21
21
  "clsx": "^1.1.1",
22
22
  "file-loader": "^6.2.0",
23
- "react": "^17.0.1",
24
- "react-dom": "^17.0.1",
23
+ "react": "^18.0.0",
24
+ "react-dom": "^18.0.0",
25
25
  "url-loader": "^4.1.1"
26
26
  },
27
27
  "browserslist": {