capybara-playwright-driver 0.3.1 → 0.4.0

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: 931fea1c143e8de209fb6a360e072b0b5dfd724e7f9d240d8a4b0a36b39b443e
4
- data.tar.gz: 53fa84147fadb311502981d7a51311d147a140f6983cd8d66567cea79918d332
3
+ metadata.gz: ff1545e5e7830f5c9c3a3880894c6c4b89cbe3104a18ee388870e16b6d31cd9c
4
+ data.tar.gz: 3add9f1a8aa12f459f2efe3b61d8c0200716201b02effacd666bd97f3220d479
5
5
  SHA512:
6
- metadata.gz: 1e3e16c8377aa75d7fb5716e875b0291d50332ef9e447c52205b0dab27cfd8de95d32388112a3f1a280137569eba270f77b236f826dcc7117d374ff43b18943c
7
- data.tar.gz: cc15d0f5a5ddfa9d024d87e800f9e073df34220318b68465e9e77ff4bfc8ac3ce3a3cd7ed7e393b9b884de85fbf0ac4eae65b4e7ee68740cb4c68eafa17524c9
6
+ metadata.gz: 5a88d7c10d9002bf81c0c5d10760623e69d8b02ee86ef238d3a2138e333d936d3c3fc2c6954b483b93dec856653f99a84bbec59b61106fd5a6df3f374e1616d2
7
+ data.tar.gz: aa54328b1a239b1d2800052775a9620180a26cf90ac2cc3fe48334f0b4b4c3d983da29fbc1f3d9aad1b75101319d00e85cd597dcf6ad9d579bda7bee5d236340
@@ -14,18 +14,20 @@ module Capybara
14
14
 
15
15
  class NoSuchWindowError < StandardError ; end
16
16
 
17
- def initialize(driver:, playwright_browser:, page_options:, record_video: false)
17
+ def initialize(driver:, playwright_browser:, page_options:, record_video: false, default_navigation_timeout: nil)
18
18
  @driver = driver
19
19
  @playwright_browser = playwright_browser
20
20
  @page_options = page_options
21
21
  if record_video
22
22
  @page_options[:record_video_dir] ||= tmpdir
23
23
  end
24
+ @default_navigation_timeout = default_navigation_timeout
24
25
  @playwright_page = create_page(create_browser_context)
25
26
  end
26
27
 
27
28
  private def create_browser_context
28
29
  @playwright_browser.new_context(**@page_options).tap do |browser_context|
30
+ browser_context.default_navigation_timeout = @default_navigation_timeout if @default_navigation_timeout
29
31
  browser_context.on('page', ->(page) {
30
32
  unless @playwright_page
31
33
  @playwright_page = page
@@ -21,7 +21,8 @@ module Capybara
21
21
  ignoreDefaultArgs: nil,
22
22
  proxy: nil,
23
23
  slowMo: nil,
24
- timeout: nil,
24
+ # timeout: nil,
25
+ tracesDir: nil,
25
26
  }.keys
26
27
 
27
28
  def value
@@ -9,6 +9,9 @@ module Capybara
9
9
  def initialize(app, **options)
10
10
  @browser_runner = BrowserRunner.new(options)
11
11
  @page_options = PageOptions.new(options)
12
+ if options[:timeout].is_a?(Numeric)
13
+ @default_navigation_timeout = options[:timeout] * 1000
14
+ end
12
15
  end
13
16
 
14
17
  def wait?; true; end
@@ -20,6 +23,7 @@ module Capybara
20
23
  playwright_browser: playwright_browser,
21
24
  page_options: @page_options.value,
22
25
  record_video: callback_on_save_screenrecord?,
26
+ default_navigation_timeout: @default_navigation_timeout,
23
27
  )
24
28
  end
25
29
 
@@ -239,7 +239,13 @@ module Capybara
239
239
 
240
240
  class TextInput < Settable
241
241
  def set(value, **options)
242
- @element.fill(value.to_s, timeout: @timeout)
242
+ text = value.to_s
243
+ if text.end_with?("\n")
244
+ @element.fill(text[0...-1], timeout: @timeout)
245
+ @element.press('Enter', timeout: @timeout)
246
+ else
247
+ @element.fill(text, timeout: @timeout)
248
+ end
243
249
  rescue ::Playwright::TimeoutError
244
250
  raise if @element.editable?
245
251
 
@@ -9,30 +9,31 @@ module Capybara
9
9
  end
10
10
 
11
11
  def all_text
12
- assert_element_not_stale
13
-
14
- text = @shadow_roow_element.text_content
15
- text.to_s.gsub(/[\u200b\u200e\u200f]/, '')
16
- .gsub(/[\ \n\f\t\v\u2028\u2029]+/, ' ')
17
- .gsub(/\A[[:space:]&&[^\u00a0]]+/, '')
18
- .gsub(/[[:space:]&&[^\u00a0]]+\z/, '')
19
- .tr("\u00a0", ' ')
12
+ assert_element_not_stale {
13
+ text = @shadow_roow_element.text_content
14
+ text.to_s.gsub(/[\u200b\u200e\u200f]/, '')
15
+ .gsub(/[\ \n\f\t\v\u2028\u2029]+/, ' ')
16
+ .gsub(/\A[[:space:]&&[^\u00a0]]+/, '')
17
+ .gsub(/[[:space:]&&[^\u00a0]]+\z/, '')
18
+ .tr("\u00a0", ' ')
19
+ }
20
20
  end
21
21
 
22
22
  def visible_text
23
- assert_element_not_stale
23
+ assert_element_not_stale {
24
24
 
25
- return '' unless visible?
25
+ return '' unless visible?
26
26
 
27
- # https://github.com/teamcapybara/capybara/blob/1c164b608fa6452418ec13795b293655f8a0102a/lib/capybara/rack_test/node.rb#L18
28
- displayed_text = @shadow_roow_element.text_content.to_s.
29
- gsub(/[\u200b\u200e\u200f]/, '').
30
- gsub(/[\ \n\f\t\v\u2028\u2029]+/, ' ')
31
- displayed_text.squeeze(' ')
32
- .gsub(/[\ \n]*\n[\ \n]*/, "\n")
33
- .gsub(/\A[[:space:]&&[^\u00a0]]+/, '')
34
- .gsub(/[[:space:]&&[^\u00a0]]+\z/, '')
35
- .tr("\u00a0", ' ')
27
+ # https://github.com/teamcapybara/capybara/blob/1c164b608fa6452418ec13795b293655f8a0102a/lib/capybara/rack_test/node.rb#L18
28
+ displayed_text = @shadow_roow_element.text_content.to_s.
29
+ gsub(/[\u200b\u200e\u200f]/, '').
30
+ gsub(/[\ \n\f\t\v\u2028\u2029]+/, ' ')
31
+ displayed_text.squeeze(' ')
32
+ .gsub(/[\ \n]*\n[\ \n]*/, "\n")
33
+ .gsub(/\A[[:space:]&&[^\u00a0]]+/, '')
34
+ .gsub(/[[:space:]&&[^\u00a0]]+\z/, '')
35
+ .tr("\u00a0", ' ')
36
+ }
36
37
  end
37
38
  end
38
39
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Capybara
4
4
  module Playwright
5
- VERSION = '0.3.1'
5
+ VERSION = '0.4.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-playwright-driver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - YusukeIwaki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-28 00:00:00.000000000 Z
11
+ date: 2023-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara