playwright-ruby-client 0.6.2 → 0.6.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 623dc9bf11ce77bda6cd9006c727e31060564810bac0ccf5f06aabffc5976c07
4
- data.tar.gz: 206995c24a6cbd4dcd6867eaa076e3b3052b7a7056cd63188a7ebb0e54c38056
3
+ metadata.gz: 77f49d82e8b6b94210f79ee9e031dcfb73072a11da4c366626ad3bcf3e18bfa9
4
+ data.tar.gz: '098cbff788ed38a7647de0271d6f3c38a757e3c750ebf8aaa3f96dccbb626921'
5
5
  SHA512:
6
- metadata.gz: a341d042e6e35b5205f56303efda6fe9a34e857c12696622c366f0ebbc113816b3418e05e87b8fe60867ae2252964a36545b8bd782cf61f9c23f42e868cb098a
7
- data.tar.gz: 68fc458f0fc750c208f8daa7f900ef33977987aa6684db4edea20c42cf5f3837deb4e5b828385fd9c25d11769ff1b345cdb795aef370158bd009a515dfeeb54d
6
+ metadata.gz: 46997fb7eff8b747560a6f8658bc2b50cbeb2a489f75ed716ccfb84fc8dfddea171bbd4812dc897840507c7d9267e1c81e9f79ae05679ccece322dff7c8adc8b
7
+ data.tar.gz: 134a0003575cbe1501af23dad3a2f706cf9a961a8c067a858ecd25e61fe7a20f018d382d8d38be40c5aaa0c603dd0b1d02bd62b674405bfa5b5e130cf8593196
@@ -48,4 +48,115 @@ Capybara.default_driver = :playwright
48
48
  Capybara.javascript_driver = :playwright
49
49
  ```
50
50
 
51
- It is not mandatry. Without changing the default driver, you can still use Playwright driver by specifying `Capybara.current_driver = :playwrite` (or `driven_by :playwright` in system spec) explicitly.
51
+ It is not mandatry. Without changing the default driver, you can still use Playwright driver by specifying `Capybara.current_driver = :playwright` (or `driven_by :playwright` in system spec) explicitly.
52
+
53
+ ### (reference) Available driver options
54
+
55
+ These parameters can be passed into `Capybara::Playwright::Driver.new`
56
+
57
+ * `playwright_cli_executable_path`
58
+ * Refer [this article](./download_playwright_driver) to understand what to specify.
59
+ * `browser_type`
60
+ * `:chromium` (default), `:firefox`, or `:webkit`
61
+ * Parameters for [Playwright::BrowserType#launch](/docs/api/browser_type#launch)
62
+ * args
63
+ * channel
64
+ * `chrome`, `msedge`, `chrome-beta`, `chrome-dev`, `chrome-canary`, `msedge-beta`, `msedge-dev` Browser distribution channel. Read more about using [Google Chrome & Microsoft Edge](https://playwright.dev/docs/browsers#google-chrome--microsoft-edge)
65
+ * devtools
66
+ * downloadsPath
67
+ * env
68
+ * executablePath
69
+ * firefoxUserPrefs
70
+ * headless
71
+ * ignoreDefaultArgs
72
+ * proxy
73
+ * slowMo
74
+ * timeout
75
+ * Parameters for [Playwright::Browser#new_context](/docs/api/browser#new_context)
76
+ * bypassCSP
77
+ * colorScheme
78
+ * deviceScaleFactor
79
+ * extraHTTPHeaders
80
+ * geolocation
81
+ * hasTouch
82
+ * httpCredentials
83
+ * ignoreHTTPSErrors
84
+ * isMobile
85
+ * javaScriptEnabled
86
+ * locale
87
+ * noViewport
88
+ * offline
89
+ * permissions
90
+ * proxy
91
+ * record_har_omit_content
92
+ * record_har_path
93
+ * record_video_dir
94
+ * record_video_size
95
+ * screen
96
+ * storageState
97
+ * timezoneId
98
+ * userAgent
99
+ * viewport
100
+
101
+ ```ruby
102
+ driver_opts = {
103
+ # `playwright` command path.
104
+ playwright_cli_executable_path: './node_modules/.bin/playwright',
105
+
106
+ # Use firefox for testing.
107
+ browser_type: :firefox,
108
+
109
+ # Headful mode.
110
+ headless: false,
111
+
112
+ # Slower operation
113
+ slowMo: 50, # integer. (50-100 would be good for most cases)
114
+ }
115
+
116
+ Capybara::Playwright::Driver.new(app, driver_opts)
117
+ ```
118
+
119
+
120
+ ## Available functions and Limitations
121
+
122
+ ### Capybara DSL
123
+
124
+ Most of the methods of `Capybara::Session` and `Capybara::Node::Element` are available. However the following method is not yet implemented.
125
+
126
+ * `Capybara::Node::Element#drop`
127
+
128
+ ### Playwright-native scripting
129
+
130
+ We can also describe Playwright-native automation script using `with_playwright_page` and `with_playwright_element_handle`.
131
+
132
+ ```ruby
133
+ # With Capybara DSL
134
+ find('a[data-item-type="global_search"]').click
135
+
136
+ # With Playwright-native Page
137
+ Capybara.current_session.driver.with_playwright_page do |page|
138
+ # `page` is an instance of Playwright::Page.
139
+ page.click('a[data-item-type="global_search"]')
140
+ end
141
+ ```
142
+
143
+ ```ruby
144
+ all('.list-item').each do |li|
145
+ # With Capybara::Node::Element method
146
+ puts li.all('a').first.text
147
+
148
+ # With Playwright-native ElementHandle
149
+ puts li.with_playwright_element_handle do |handle|
150
+ # `handle` is an instance of Playwright::ElementHandle
151
+ handle.query_selector('a').text_content
152
+ end
153
+ end
154
+ ```
155
+
156
+ Generally, Capybara DSL seems simple, but Playwright-native scripting are more precise and efficient. Also `waitForNavigation`, `waitForSelector`, and many other Playwright functions are available with Playwright-native scripting.
157
+
158
+ ### Limitations
159
+
160
+ * 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/
161
+ * `current_window.maximize` and `current_window.fullscreen` work only on headful (non-headless) mode, as selenium driver does.
162
+ * `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).
@@ -7,7 +7,7 @@ module Playwright
7
7
  private def after_initialize
8
8
  @connected = true
9
9
  @closed_or_closing = false
10
- @remote = true
10
+ @remote = false
11
11
 
12
12
  @contexts = Set.new
13
13
  @channel.on('close', method(:on_close))
@@ -52,14 +52,6 @@ module Playwright
52
52
 
53
53
  def close
54
54
  return if @closed_or_closing
55
- if @remote
56
- @contexts.each do |context|
57
- context.pages.each do |page|
58
- page.send(:on_close)
59
- end
60
- context.send(:on_close)
61
- end
62
- end
63
55
  @closed_or_closing = true
64
56
  @channel.send_message_to_server('close')
65
57
  nil
@@ -89,14 +81,6 @@ module Playwright
89
81
 
90
82
  private def on_close(_ = {})
91
83
  @connected = false
92
- if @remote
93
- @contexts.each do |context|
94
- context.pages.each do |page|
95
- page.send(:on_close)
96
- end
97
- context.send(:on_close)
98
- end
99
- end
100
84
  emit(Events::Browser::Disconnected, self)
101
85
  @closed_or_closing = true
102
86
  end
@@ -46,6 +46,8 @@ module Playwright
46
46
  ChannelOwners::Request.from_nullable(params['page']),
47
47
  )
48
48
  })
49
+
50
+ @closed_promise = Concurrent::Promises.resolvable_future
49
51
  end
50
52
 
51
53
  private def on_page(page)
@@ -223,15 +225,14 @@ module Playwright
223
225
  end
224
226
 
225
227
  private def on_close
226
- @closed_or_closing = true
227
228
  @browser&.send(:remove_context, self)
228
229
  emit(Events::BrowserContext::Close)
230
+ @closed_promise.fulfill(true)
229
231
  end
230
232
 
231
233
  def close
232
- return if @closed_or_closing
233
- @closed_or_closing = true
234
234
  @channel.send_message_to_server('close')
235
+ @closed_promise.value!
235
236
  nil
236
237
  rescue => err
237
238
  raise unless safe_close_error?(err)
@@ -65,7 +65,8 @@ module Playwright
65
65
  emit(Events::Page::WebSocket, ChannelOwners::WebSocket.from(params['webSocket']))
66
66
  })
67
67
  @channel.on('worker', ->(params) {
68
- on_worker(ChannelOwners::Worker.from(params['worker']))
68
+ worker = ChannelOwners::Worker.from(params['worker'])
69
+ # on_worker(worker)
69
70
  })
70
71
  end
71
72
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Playwright
4
- VERSION = '0.6.2'
4
+ VERSION = '0.6.3'
5
5
  COMPATIBLE_PLAYWRIGHT_VERSION = '1.12.0'
6
6
  end
@@ -1278,8 +1278,8 @@ module Playwright
1278
1278
  end
1279
1279
 
1280
1280
  # @nodoc
1281
- def stop_js_coverage
1282
- wrap_impl(@impl.stop_js_coverage)
1281
+ def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1282
+ wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1283
1283
  end
1284
1284
 
1285
1285
  # @nodoc
@@ -1288,8 +1288,8 @@ module Playwright
1288
1288
  end
1289
1289
 
1290
1290
  # @nodoc
1291
- def start_css_coverage(resetOnNavigation: nil, reportAnonymousScripts: nil)
1292
- wrap_impl(@impl.start_css_coverage(resetOnNavigation: unwrap_impl(resetOnNavigation), reportAnonymousScripts: unwrap_impl(reportAnonymousScripts)))
1291
+ def stop_js_coverage
1292
+ wrap_impl(@impl.stop_js_coverage)
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.2
4
+ version: 0.6.3
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-01 00:00:00.000000000 Z
11
+ date: 2021-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby