playwright-ruby-client 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 330a0cd5755fdbe5136276e881415f5966f159b2abc62f66a26ab5068b326efe
4
- data.tar.gz: 6108f18234e97d483c17958bee26628f4068be0438d1ce5553748ff1f7489acd
3
+ metadata.gz: 2c3d1d005addff01402de5290c11dbac3aaac9a49608b7d88b3f86dffac45090
4
+ data.tar.gz: 3bde2b4a9f082fbdfb8b4577cfc6afadf19fe538e741b2bd4728ea942e3dd85b
5
5
  SHA512:
6
- metadata.gz: c82ea88ac3d7b78e1e746f95ba09f0c6903cd20f9f0410f6bba68b9fdd00cf47a5e1c3103d8884c917542a7e41959ded61ba2b2ae9f58cfa2e2bfe4e1e2edf59
7
- data.tar.gz: 61867b7e5b78b8271db8d937c8e6129e84bba1eb5181179dc464c50930e88b641a25f6a3c1d3bb1e6183f0cb9546b494622a918b2942405ea9b9a3b9356f8321
6
+ metadata.gz: 2a48cffd45f0ffd1a946c08d7ab920aac304812545271e7c250eae1bf0004d4c5be78688b04a513c5ec950b8e9d5c90c54f8e18c24e9e0856be8aa739c0e379b
7
+ data.tar.gz: 9b75e4959d91687cc995453f9ae76fea2b62c4641f949b9c60a197c0d11ad70060405159180309bc874fa0945a40d97c07ff2aa8033eb0e60fc2d12fc5a781b1
@@ -96,6 +96,59 @@ differences between Chromium and Chrome.
96
96
  [This article](https://chromium.googlesource.com/chromium/src/+/lkgr/docs/chromium_browser_vs_google_chrome.md)
97
97
  describes some differences for Linux users.
98
98
 
99
+ ## launch_persistent_context
100
+
101
+ ```
102
+ def launch_persistent_context(
103
+ userDataDir,
104
+ acceptDownloads: nil,
105
+ args: nil,
106
+ bypassCSP: nil,
107
+ channel: nil,
108
+ chromiumSandbox: nil,
109
+ colorScheme: nil,
110
+ deviceScaleFactor: nil,
111
+ devtools: nil,
112
+ downloadsPath: nil,
113
+ env: nil,
114
+ executablePath: nil,
115
+ extraHTTPHeaders: nil,
116
+ geolocation: nil,
117
+ handleSIGHUP: nil,
118
+ handleSIGINT: nil,
119
+ handleSIGTERM: nil,
120
+ hasTouch: nil,
121
+ headless: nil,
122
+ httpCredentials: nil,
123
+ ignoreDefaultArgs: nil,
124
+ ignoreHTTPSErrors: nil,
125
+ isMobile: nil,
126
+ javaScriptEnabled: nil,
127
+ locale: nil,
128
+ noViewport: nil,
129
+ offline: nil,
130
+ permissions: nil,
131
+ proxy: nil,
132
+ record_har_omit_content: nil,
133
+ record_har_path: nil,
134
+ record_video_dir: nil,
135
+ record_video_size: nil,
136
+ reducedMotion: nil,
137
+ screen: nil,
138
+ slowMo: nil,
139
+ timeout: nil,
140
+ timezoneId: nil,
141
+ tracesDir: nil,
142
+ userAgent: nil,
143
+ viewport: nil,
144
+ &block)
145
+ ```
146
+
147
+ Returns the persistent browser context instance.
148
+
149
+ Launches browser that uses persistent storage located at `userDataDir` and returns the only context. Closing this
150
+ context will automatically close the browser.
151
+
99
152
  ## name
100
153
 
101
154
  ```
@@ -23,18 +23,16 @@ def continue(headers: nil, method: nil, postData: nil, url: nil)
23
23
 
24
24
  Continues route's request with optional overrides.
25
25
 
26
- ```python sync title=example_1960aabd58c9553683368e29429d39c1209d35e6e3625bbef1280a1fa022a9ee.py
27
- def handle(route, request):
28
- # override headers
29
- headers = {
30
- **request.headers,
31
- "foo": "bar" # set "foo" header
32
- "origin": None # remove "origin" header
33
- }
34
- route.continue_(headers=headers)
35
- }
36
- page.route("**/*", handle)
37
-
26
+ ```ruby
27
+ def handle(route, request)
28
+ # override headers
29
+ headers = request.headers
30
+ headers['foo'] = 'bar' # set "foo" header
31
+ headers['user-agent'] = 'Unknown Browser' # modify user-agent
32
+
33
+ route.continue(headers: headers)
34
+ end
35
+ page.route("**/*", method(:handle))
38
36
  ```
39
37
 
40
38
 
@@ -54,19 +52,20 @@ Fulfills route's request with given response.
54
52
 
55
53
  An example of fulfilling all requests with 404 responses:
56
54
 
57
- ```python sync title=example_6d2dfd4bb5c8360f8d80bb91c563b0bd9b99aa24595063cf85e5a6e1b105f89c.py
58
- page.route("**/*", lambda route: route.fulfill(
59
- status=404,
60
- content_type="text/plain",
61
- body="not found!"))
62
-
55
+ ```ruby
56
+ page.route("**/*", ->(route, request) {
57
+ route.fulfill(
58
+ status: 404,
59
+ contentType: 'text/plain',
60
+ body: 'not found!!',
61
+ )
62
+ })
63
63
  ```
64
64
 
65
65
  An example of serving static file:
66
66
 
67
- ```python sync title=example_c77fd0986d0b74c905cd9417756c76775e612cc86410f9a5aabc5b46d233d150.py
68
- page.route("**/xhr_endpoint", lambda route: route.fulfill(path="mock_data.json"))
69
-
67
+ ```ruby
68
+ page.route("**/xhr_endpoint", ->(route, _) { route.fulfill(path: "mock_data.json") })
70
69
  ```
71
70
 
72
71
 
@@ -202,4 +202,4 @@ end
202
202
 
203
203
  * Playwright doesn't allow clicking invisible DOM elements or moving elements. `click` sometimes doesn't work as Selenium does. See the detail in https://playwright.dev/docs/actionability/
204
204
  * `current_window.maximize` and `current_window.fullscreen` work only on headful (non-headless) mode, as selenium driver does.
205
- * `Capybara::Node::Element#drag_to` does not accept `html5` parameter, since [Playwright doesn't implement the feature yet](https://github.com/microsoft/playwright/pull/6207).
205
+ * `Capybara::Node::Element#drag_to` does not accept `html5` parameter.
@@ -340,7 +340,7 @@
340
340
  * connect_over_cdp
341
341
  * executable_path
342
342
  * launch
343
- * ~~launch_persistent_context~~
343
+ * launch_persistent_context
344
344
  * name
345
345
 
346
346
  ## Playwright
@@ -1,5 +1,7 @@
1
1
  module Playwright
2
2
  define_channel_owner :BrowserType do
3
+ include Utils::PrepareBrowserContextOptions
4
+
3
5
  def name
4
6
  @initializer['name']
5
7
  end
@@ -20,6 +22,22 @@ module Playwright
20
22
  end
21
23
  end
22
24
 
25
+ def launch_persistent_context(userDataDir, **options, &block)
26
+ params = options.dup
27
+ prepare_browser_context_options(params)
28
+ params['userDataDir'] = userDataDir
29
+
30
+ resp = @channel.send_message_to_server('launchPersistentContext', params.compact)
31
+ context = ChannelOwners::Browser.from(resp)
32
+ return context unless block
33
+
34
+ begin
35
+ block.call(context)
36
+ ensure
37
+ context.close
38
+ end
39
+ end
40
+
23
41
  def connect_over_cdp(endpointURL, headers: nil, slowMo: nil, timeout: nil, &block)
24
42
  raise 'Connecting over CDP is only supported in Chromium.' unless name == 'chromium'
25
43
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playwright
4
- VERSION = '0.6.4'
4
+ VERSION = '0.6.5'
5
5
  COMPATIBLE_PLAYWRIGHT_VERSION = '1.12.0'
6
6
  end
@@ -133,8 +133,9 @@ module Playwright
133
133
  timezoneId: nil,
134
134
  tracesDir: nil,
135
135
  userAgent: nil,
136
- viewport: nil)
137
- raise NotImplementedError.new('launch_persistent_context is not implemented yet.')
136
+ viewport: nil,
137
+ &block)
138
+ wrap_impl(@impl.launch_persistent_context(unwrap_impl(userDataDir), acceptDownloads: unwrap_impl(acceptDownloads), args: unwrap_impl(args), bypassCSP: unwrap_impl(bypassCSP), channel: unwrap_impl(channel), chromiumSandbox: unwrap_impl(chromiumSandbox), colorScheme: unwrap_impl(colorScheme), deviceScaleFactor: unwrap_impl(deviceScaleFactor), devtools: unwrap_impl(devtools), downloadsPath: unwrap_impl(downloadsPath), env: unwrap_impl(env), executablePath: unwrap_impl(executablePath), extraHTTPHeaders: unwrap_impl(extraHTTPHeaders), geolocation: unwrap_impl(geolocation), handleSIGHUP: unwrap_impl(handleSIGHUP), handleSIGINT: unwrap_impl(handleSIGINT), handleSIGTERM: unwrap_impl(handleSIGTERM), hasTouch: unwrap_impl(hasTouch), headless: unwrap_impl(headless), httpCredentials: unwrap_impl(httpCredentials), ignoreDefaultArgs: unwrap_impl(ignoreDefaultArgs), 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_omit_content: unwrap_impl(record_har_omit_content), record_har_path: unwrap_impl(record_har_path), record_video_dir: unwrap_impl(record_video_dir), record_video_size: unwrap_impl(record_video_size), reducedMotion: unwrap_impl(reducedMotion), screen: unwrap_impl(screen), slowMo: unwrap_impl(slowMo), timeout: unwrap_impl(timeout), timezoneId: unwrap_impl(timezoneId), tracesDir: unwrap_impl(tracesDir), userAgent: unwrap_impl(userAgent), viewport: unwrap_impl(viewport), &wrap_block_call(block)))
138
139
  end
139
140
 
140
141
  # Returns browser name. For example: `'chromium'`, `'webkit'` or `'firefox'`.
@@ -1273,8 +1273,8 @@ module Playwright
1273
1273
  end
1274
1274
 
1275
1275
  # @nodoc
1276
- def start_js_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1277
- wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1276
+ def stop_js_coverage
1277
+ wrap_impl(@impl.stop_js_coverage)
1278
1278
  end
1279
1279
 
1280
1280
  # @nodoc
@@ -1288,8 +1288,8 @@ module Playwright
1288
1288
  end
1289
1289
 
1290
1290
  # @nodoc
1291
- def stop_js_coverage
1292
- wrap_impl(@impl.stop_js_coverage)
1291
+ def start_js_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1292
+ wrap_impl(@impl.start_js_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1293
1293
  end
1294
1294
 
1295
1295
  # @nodoc
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: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-08 00:00:00.000000000 Z
11
+ date: 2021-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby