capybara-playwright-driver 0.1.5 → 0.1.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f43dbe09eba1cda75ed608f418120fbe5daebe99aa4bebde377ef120bd88d3f
|
4
|
+
data.tar.gz: 825d1aa7230177a37c7f6ce23ce656961084a2f13bfe8e5e36674836866a477e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f989b332d2d69bf84e3b270478514cee94a1ed3dc40c6868b8c61565248fa0d597e16f1575a42344bd13cbb4ecce8277956813d67df8b407351db72e684778d
|
7
|
+
data.tar.gz: df9dfa30c1f50fb1dc3c037b1b7445308e5301632ec6f8d16ba05f53b071f8a106355ae5d8d59b6885892c70bd7b2b713fe3a6d2f3c763ba528cd37c0c8ec899
|
data/capybara-playwright.gemspec
CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
|
27
27
|
spec.required_ruby_version = '>= 2.4'
|
28
28
|
spec.add_dependency 'capybara'
|
29
|
-
spec.add_dependency 'playwright-ruby-client', '>= 0.
|
29
|
+
spec.add_dependency 'playwright-ruby-client', '>= 0.8.0'
|
30
30
|
spec.add_development_dependency 'allure-rspec'
|
31
31
|
spec.add_development_dependency 'bundler', '~> 2.2.3'
|
32
32
|
spec.add_development_dependency 'launchy', '>= 2.0.4'
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Capybara
|
2
|
+
module Playwright
|
3
|
+
# playwright-ruby-client provides 3 methods to launch/connect browser.
|
4
|
+
#
|
5
|
+
# Playwright.create do |playwright|
|
6
|
+
# playwright.chromium.launch do |browser|
|
7
|
+
#
|
8
|
+
# Playwright.connect_to_playwright_server do |playwright| ...
|
9
|
+
# playwright.chromium.launch do |browser|
|
10
|
+
#
|
11
|
+
# Playwright.connect_to_browser_server do |browser| ...
|
12
|
+
#
|
13
|
+
# This class provides start/stop methods for driver.
|
14
|
+
# This is responsible for
|
15
|
+
# - managing PlaywrightExecution
|
16
|
+
# - launching browser with given option if needed
|
17
|
+
class BrowserRunner
|
18
|
+
class PlaywrightConnectToPlaywrightServer
|
19
|
+
def initialize(endpoint_url, options)
|
20
|
+
@ws_endpoint = endpoint_url
|
21
|
+
@browser_type = options[:browser_type] || :chromium
|
22
|
+
unless %i(chromium firefox webkit).include?(@browser_type)
|
23
|
+
raise ArgumentError.new("Unknown browser_type: #{@browser_type}")
|
24
|
+
end
|
25
|
+
@browser_options = BrowserOptions.new(options)
|
26
|
+
end
|
27
|
+
|
28
|
+
def playwright_execution
|
29
|
+
@playwright_execution ||= ::Playwright.connect_to_playwright_server(@ws_endpoint)
|
30
|
+
end
|
31
|
+
|
32
|
+
def playwright_browser
|
33
|
+
browser_type = playwright_execution.playwright.send(@browser_type)
|
34
|
+
browser_options = @browser_options.value
|
35
|
+
browser_type.launch(**browser_options)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class PlaywrightConnectToBrowserServer
|
40
|
+
def initialize(endpoint_url)
|
41
|
+
@ws_endpoint = endpoint_url
|
42
|
+
end
|
43
|
+
|
44
|
+
def playwright_execution
|
45
|
+
@playwright_execution ||= ::Playwright.connect_to_browser_server(@ws_endpoint)
|
46
|
+
end
|
47
|
+
|
48
|
+
def playwright_browser
|
49
|
+
playwright_execution.browser
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class PlaywrightCreate
|
54
|
+
def initialize(options)
|
55
|
+
@playwright_cli_executable_path = options[:playwright_cli_executable_path] || 'npx playwright'
|
56
|
+
@browser_type = options[:browser_type] || :chromium
|
57
|
+
unless %i(chromium firefox webkit).include?(@browser_type)
|
58
|
+
raise ArgumentError.new("Unknown browser_type: #{@browser_type}")
|
59
|
+
end
|
60
|
+
@browser_options = BrowserOptions.new(options)
|
61
|
+
end
|
62
|
+
|
63
|
+
def playwright_execution
|
64
|
+
@playwright_execution ||= ::Playwright.create(
|
65
|
+
playwright_cli_executable_path: @playwright_cli_executable_path,
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
def playwright_browser
|
70
|
+
browser_type = playwright_execution.playwright.send(@browser_type)
|
71
|
+
browser_options = @browser_options.value
|
72
|
+
browser_type.launch(**browser_options)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def initialize(options)
|
77
|
+
@runner =
|
78
|
+
if options[:playwright_server_endpoint_url]
|
79
|
+
PlaywrightConnectToPlaywrightServer.new(options[:playwright_server_endpoint_url], options)
|
80
|
+
elsif options[:browser_server_endpoint_url]
|
81
|
+
PlaywrightConnectToBrowserServer.new(options[:browser_server_endpoint_url])
|
82
|
+
else
|
83
|
+
PlaywrightCreate.new(options)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# @return [::Playwright::Browser]
|
88
|
+
def start
|
89
|
+
@playwright_execution = @runner.playwright_execution
|
90
|
+
@runner.playwright_browser
|
91
|
+
end
|
92
|
+
|
93
|
+
def stop
|
94
|
+
@playwright_execution&.stop
|
95
|
+
@playwright_execution = nil
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -7,13 +7,7 @@ module Capybara
|
|
7
7
|
include DriverExtension
|
8
8
|
|
9
9
|
def initialize(app, **options)
|
10
|
-
@
|
11
|
-
@browser_type = options[:browser_type] || :chromium
|
12
|
-
unless %i(chromium firefox webkit).include?(@browser_type)
|
13
|
-
raise ArgumentError.new("Unknown browser_type: #{@browser_type}")
|
14
|
-
end
|
15
|
-
|
16
|
-
@browser_options = BrowserOptions.new(options)
|
10
|
+
@browser_runner = BrowserRunner.new(options)
|
17
11
|
@page_options = PageOptions.new(options)
|
18
12
|
end
|
19
13
|
|
@@ -43,22 +37,13 @@ module Capybara
|
|
43
37
|
exit @exit_status if @exit_status # Force exit with stored status
|
44
38
|
end
|
45
39
|
|
46
|
-
|
47
|
-
browser_options = @browser_options.value
|
48
|
-
browser_type.launch(**browser_options)
|
49
|
-
end
|
50
|
-
|
51
|
-
private def playwright_execution
|
52
|
-
@playwright_execution ||= ::Playwright.create(
|
53
|
-
playwright_cli_executable_path: @playwright_cli_executable_path,
|
54
|
-
)
|
40
|
+
@browser_runner.start
|
55
41
|
end
|
56
42
|
|
57
43
|
private def quit
|
58
44
|
@playwright_browser&.close
|
59
45
|
@playwright_browser = nil
|
60
|
-
@
|
61
|
-
@playwright_execution = nil
|
46
|
+
@browser_runner.stop
|
62
47
|
end
|
63
48
|
|
64
49
|
def reset!
|
data/lib/capybara/playwright.rb
CHANGED
@@ -4,6 +4,7 @@ require 'capybara'
|
|
4
4
|
require 'playwright'
|
5
5
|
|
6
6
|
require 'capybara/playwright/browser'
|
7
|
+
require 'capybara/playwright/browser_runner'
|
7
8
|
require 'capybara/playwright/browser_options'
|
8
9
|
require 'capybara/playwright/dialog_event_handler'
|
9
10
|
require 'capybara/playwright/driver'
|
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.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- YusukeIwaki
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.8.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 0.8.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: allure-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- lib/capybara/playwright.rb
|
185
185
|
- lib/capybara/playwright/browser.rb
|
186
186
|
- lib/capybara/playwright/browser_options.rb
|
187
|
+
- lib/capybara/playwright/browser_runner.rb
|
187
188
|
- lib/capybara/playwright/dialog_event_handler.rb
|
188
189
|
- lib/capybara/playwright/driver.rb
|
189
190
|
- lib/capybara/playwright/driver_extension.rb
|