cornucopia 0.1.40 → 0.1.41
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 +4 -4
- data/.gitignore +2 -1
- data/cornucopia.gemspec +1 -1
- data/lib/cornucopia.rb +7 -0
- data/lib/cornucopia/capybara/finder_diagnostics.rb +10 -6
- data/lib/cornucopia/capybara/finder_extensions.rb +24 -15
- data/lib/cornucopia/capybara/install_extensions.rb +44 -0
- data/lib/cornucopia/capybara/matcher_extensions.rb +33 -21
- data/lib/cornucopia/capybara/page_diagnostics.rb +44 -1
- data/lib/cornucopia/capybara/selectable_values.rb +47 -0
- data/lib/cornucopia/capybara/synchronizable.rb +24 -0
- data/lib/cornucopia/cucumber_hooks.rb +6 -3
- data/lib/cornucopia/rspec_hooks.rb +5 -4
- data/lib/cornucopia/site_prism/element_extensions.rb +16 -2
- data/lib/cornucopia/site_prism/install_extensions.rb +18 -0
- data/lib/cornucopia/site_prism/page_application.rb +3 -1
- data/lib/cornucopia/site_prism/section_extensions.rb +23 -0
- data/lib/cornucopia/spinach_hooks.rb +6 -3
- data/lib/cornucopia/util/configuration.rb +14 -6
- data/lib/cornucopia/util/configured_report.rb +3 -1
- data/lib/cornucopia/util/file_asset.rb +3 -1
- data/lib/cornucopia/util/generic_settings.rb +3 -1
- data/lib/cornucopia/util/log_capture.rb +4 -2
- data/lib/cornucopia/util/pretty_formatter.rb +4 -2
- data/lib/cornucopia/util/report_builder.rb +9 -6
- data/lib/cornucopia/util/report_formatters.rb +3 -1
- data/lib/cornucopia/util/report_table.rb +4 -2
- data/lib/cornucopia/util/test_helper.rb +8 -2
- data/lib/cornucopia/version.rb +2 -2
- data/spec/dummy/app/controllers/application_controller.rb +2 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/config/application.rb +2 -0
- data/spec/dummy/config/boot.rb +2 -0
- data/spec/dummy/config/environment.rb +2 -0
- data/spec/dummy/config/environments/development.rb +2 -0
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/environments/test.rb +2 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +2 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +2 -0
- data/spec/dummy/config/initializers/inflections.rb +2 -0
- data/spec/dummy/config/initializers/mime_types.rb +2 -0
- data/spec/dummy/config/initializers/secret_token.rb +2 -0
- data/spec/dummy/config/initializers/session_store.rb +2 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +2 -0
- data/spec/dummy/config/routes.rb +2 -0
- data/spec/dummy/db/schema.rb +2 -0
- data/spec/dummy/features/support/env.rb +2 -0
- data/spec/lib/capybara/finder_diagnostics_spec.rb +68 -58
- data/spec/lib/capybara/finder_extensions_spec.rb +13 -6
- data/spec/lib/capybara/matcher_extensions_spec.rb +2 -0
- data/spec/lib/capybara/page_diagnostics_spec.rb +2 -0
- data/spec/lib/site_prism/element_extensions_spec.rb +2 -0
- data/spec/lib/site_prism/page_application_spec.rb +2 -0
- data/spec/lib/util/configuration_spec.rb +2 -0
- data/spec/lib/util/configured_report_spec.rb +2 -0
- data/spec/lib/util/file_asset_spec.rb +2 -0
- data/spec/lib/util/generic_settings_spec.rb +2 -0
- data/spec/lib/util/log_capture_spec.rb +2 -0
- data/spec/lib/util/pretty_formatter_spec.rb +29 -27
- data/spec/lib/util/report_builder_spec.rb +5 -3
- data/spec/lib/util/report_formatters_spec.rb +2 -0
- data/spec/lib/util/report_table_exception_spec.rb +2 -0
- data/spec/lib/util/report_table_spec.rb +4 -2
- data/spec/lib/util/test_helper_spec.rb +2 -0
- data/spec/pages/cornucopia_report_app.rb +2 -0
- data/spec/pages/cornucopia_report_pages/cornucopia_report_holder_page.rb +2 -0
- data/spec/pages/cornucopia_report_pages/cornucopia_report_test_contents_page.rb +2 -0
- data/spec/pages/cornucopia_report_pages/index_page.rb +2 -0
- data/spec/pages/google/email_page.rb +2 -0
- data/spec/pages/google/login_page.rb +2 -0
- data/spec/rails_helper.rb +2 -0
- data/spec/sample_report.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- metadata +11 -9
- data/lib/cornucopia/capybara/install_finder_extensions.rb +0 -105
- data/lib/cornucopia/capybara/install_matcher_extensions.rb +0 -43
- data/lib/cornucopia/site_prism/install_element_extensions.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6753fcbe86b5f2874825a23fa02b5d248c0aefcd
|
4
|
+
data.tar.gz: 775875061b712a821738900bb80a5c581166301e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc264d044dc713fc0afa59824e1261de1f6f50ab490d82d31751fdf3343f90c0607af6d26ae190e730d7fb4793389d5b4282b7e531499b394de29cdc0852598f
|
7
|
+
data.tar.gz: 8074a81b61fc1b8a43045f21e03853d4f22bf2d25b5c627d7c5fad2ad3decb03e3494186a424c6f8ce8e55434ff515f08fc206ae319be13b628218c1c19ebbf1
|
data/.gitignore
CHANGED
data/cornucopia.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
23
|
spec.require_paths = ["lib"]
|
24
24
|
|
25
|
-
spec.add_dependency "activesupport"
|
25
|
+
spec.add_dependency "activesupport", "~> 4"
|
26
26
|
|
27
27
|
spec.add_development_dependency "rails"
|
28
28
|
# spec.add_development_dependency "mysql2"
|
data/lib/cornucopia.rb
CHANGED
@@ -19,9 +19,16 @@ time = Benchmark.measure do
|
|
19
19
|
require "cornucopia/capybara/page_diagnostics"
|
20
20
|
require "cornucopia/capybara/finder_extensions"
|
21
21
|
require "cornucopia/capybara/matcher_extensions"
|
22
|
+
require "cornucopia/capybara/selectable_values"
|
23
|
+
require "cornucopia/capybara/synchronizable"
|
22
24
|
require "cornucopia/site_prism/element_extensions"
|
23
25
|
require "cornucopia/site_prism/page_application"
|
26
|
+
require "cornucopia/site_prism/section_extensions"
|
27
|
+
|
28
|
+
require "cornucopia/capybara/install_extensions"
|
29
|
+
require "cornucopia/site_prism/install_extensions"
|
24
30
|
end
|
31
|
+
|
25
32
|
puts "Cornucopia load time: #{time}"
|
26
33
|
|
27
34
|
module Cornucopia
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require ::File.expand_path("../util/configuration", File.dirname(__FILE__))
|
2
4
|
require ::File.expand_path("../util/report_builder", File.dirname(__FILE__))
|
3
5
|
|
@@ -26,8 +28,8 @@ module Cornucopia
|
|
26
28
|
# Usage:
|
27
29
|
# Instead of calling: <test_object>.<function> <args>
|
28
30
|
# you would call: test_finder <test_object>, :<function>, <args>
|
29
|
-
def self.test_finder(test_object, function_name, *args)
|
30
|
-
Cornucopia::Capybara::FinderDiagnostics::FindAction.new(test_object, {}, {}, function_name, *args).run
|
31
|
+
def self.test_finder(test_object, function_name, *args, &block)
|
32
|
+
Cornucopia::Capybara::FinderDiagnostics::FindAction.new(test_object, {}, {}, function_name, *args, &block).run
|
31
33
|
end
|
32
34
|
|
33
35
|
# This takes the same arguments as the #test_finder function, but
|
@@ -36,10 +38,11 @@ module Cornucopia
|
|
36
38
|
# This is for the times when the finder finds something, but you
|
37
39
|
# think that it may be wrong, or for whatever reason, you want
|
38
40
|
# more information about it to be output.
|
39
|
-
def self.diagnose_finder(test_object, function_name, *args)
|
40
|
-
find_action = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(test_object, {}, {}, function_name, *args)
|
41
|
+
def self.diagnose_finder(test_object, function_name, *args, &block)
|
42
|
+
find_action = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(test_object, {}, {}, function_name, *args, &block)
|
41
43
|
|
42
44
|
results = find_action.run
|
45
|
+
results = results.to_a if function_name == :all
|
43
46
|
find_action.generate_report "Diagnostic report on \"#{function_name.to_s}\":", nil
|
44
47
|
|
45
48
|
results
|
@@ -92,10 +95,11 @@ module Cornucopia
|
|
92
95
|
attr_accessor :return_value
|
93
96
|
attr_accessor :support_options
|
94
97
|
|
95
|
-
def initialize(test_object, report_options, support_options, function_name, *args)
|
98
|
+
def initialize(test_object, report_options, support_options, function_name, *args, &block)
|
96
99
|
@test_object = test_object
|
97
100
|
@function_name = function_name
|
98
101
|
@args = args
|
102
|
+
@block = block
|
99
103
|
@support_options = support_options
|
100
104
|
@report_options = report_options || {}
|
101
105
|
|
@@ -564,4 +568,4 @@ return attrib_list;"
|
|
564
568
|
end
|
565
569
|
end
|
566
570
|
end
|
567
|
-
end
|
571
|
+
end
|
@@ -1,32 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require ::File.expand_path("../util/configuration", File.dirname(__FILE__))
|
2
4
|
require ::File.expand_path("finder_diagnostics", File.dirname(__FILE__))
|
3
5
|
|
6
|
+
require "active_support/concern"
|
7
|
+
|
4
8
|
module Cornucopia
|
5
9
|
module Capybara
|
6
10
|
module FinderExtensions
|
7
|
-
|
8
|
-
|
9
|
-
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
included do
|
14
|
+
alias_method :__cornucopia_orig_find, :find
|
15
|
+
alias_method :__cornucopia_orig_all, :all
|
10
16
|
|
11
|
-
|
12
|
-
|
17
|
+
define_method :find do |*args, &block|
|
18
|
+
__cornucopia_finder_function(:find, *args, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
define_method :all do |*args, &block|
|
22
|
+
__cornucopia_finder_function(:all, *args, &block)
|
23
|
+
end
|
13
24
|
end
|
14
25
|
|
15
|
-
def __cornucopia_finder_function(finder_function, *args)
|
26
|
+
def __cornucopia_finder_function(finder_function, *args, &block)
|
16
27
|
retry_count = 0
|
17
28
|
result = nil
|
18
29
|
|
19
|
-
support_options = __cornucopia__extract_support_options(*args)
|
30
|
+
support_options = __cornucopia__extract_support_options(*args, &block)
|
20
31
|
|
21
32
|
begin
|
22
33
|
retry_count += 1
|
23
|
-
result = send("__cornucopia_orig_#{finder_function}", *args)
|
34
|
+
result = send("__cornucopia_orig_#{finder_function}", *args, &block)
|
24
35
|
rescue Selenium::WebDriver::Error::StaleElementReferenceError
|
25
36
|
retry if __cornucopia__retry_finder(retry_count, support_options)
|
26
37
|
|
27
|
-
result = __cornucopia__analyze_finder(finder_function, support_options, *args)
|
38
|
+
result = __cornucopia__analyze_finder(finder_function, support_options, *args, &block)
|
28
39
|
rescue Exception
|
29
|
-
result = __cornucopia__analyze_finder(finder_function, support_options, *args)
|
40
|
+
result = __cornucopia__analyze_finder(finder_function, support_options, *args, &block)
|
30
41
|
end
|
31
42
|
|
32
43
|
result
|
@@ -34,7 +45,7 @@ module Cornucopia
|
|
34
45
|
|
35
46
|
private
|
36
47
|
|
37
|
-
def __cornucopia__extract_support_options(*args)
|
48
|
+
def __cornucopia__extract_support_options(*args, &block)
|
38
49
|
support_options = {}
|
39
50
|
|
40
51
|
if args[-1].is_a?(Hash)
|
@@ -46,7 +57,7 @@ module Cornucopia
|
|
46
57
|
support_options
|
47
58
|
end
|
48
59
|
|
49
|
-
def __cornucopia__analyze_finder(function_name, support_options, *args)
|
60
|
+
def __cornucopia__analyze_finder(function_name, support_options, *args, &block)
|
50
61
|
return_value = nil
|
51
62
|
error = $!
|
52
63
|
|
@@ -60,7 +71,7 @@ module Cornucopia
|
|
60
71
|
{},
|
61
72
|
support_options,
|
62
73
|
function_name,
|
63
|
-
*args)
|
74
|
+
*args, &block)
|
64
75
|
|
65
76
|
if find_action.perform_analysis(Cornucopia::Util::Configuration.retry_with_found ||
|
66
77
|
support_options[:__cornucopia_retry_with_found])
|
@@ -85,5 +96,3 @@ module Cornucopia
|
|
85
96
|
end
|
86
97
|
end
|
87
98
|
end
|
88
|
-
|
89
|
-
load ::File.expand_path("install_finder_extensions.rb", File.dirname(__FILE__))
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if Object.const_defined?("Capybara") &&
|
4
|
+
Capybara.const_defined?("Node") &&
|
5
|
+
Capybara::Node.const_defined?("Document")
|
6
|
+
unless Capybara::Node::Document.included_modules.include?(Cornucopia::Capybara::FinderExtensions)
|
7
|
+
Capybara::Node::Document.include Cornucopia::Capybara::FinderExtensions
|
8
|
+
end
|
9
|
+
unless Capybara::Node::Document.included_modules.include?(Cornucopia::Capybara::MatcherExtensions)
|
10
|
+
Capybara::Node::Document.include Cornucopia::Capybara::MatcherExtensions
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
if Object.const_defined?("Capybara") &&
|
15
|
+
Capybara.const_defined?("Node") &&
|
16
|
+
Capybara::Node.const_defined?("Simple")
|
17
|
+
unless Capybara::Node::Simple.included_modules.include?(Cornucopia::Capybara::FinderExtensions)
|
18
|
+
Capybara::Node::Simple.include Cornucopia::Capybara::FinderExtensions
|
19
|
+
end
|
20
|
+
unless Capybara::Node::Simple.included_modules.include?(Cornucopia::Capybara::MatcherExtensions)
|
21
|
+
Capybara::Node::Simple.include Cornucopia::Capybara::MatcherExtensions
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if Object.const_defined?("Capybara") &&
|
26
|
+
Capybara.const_defined?("Node") &&
|
27
|
+
Capybara::Node.const_defined?("Element")
|
28
|
+
unless Capybara::Node::Element.included_modules.include?(Cornucopia::Capybara::FinderExtensions)
|
29
|
+
Capybara::Node::Element.include Cornucopia::Capybara::FinderExtensions
|
30
|
+
end
|
31
|
+
unless Capybara::Node::Element.included_modules.include?(Cornucopia::Capybara::MatcherExtensions)
|
32
|
+
Capybara::Node::Element.include Cornucopia::Capybara::MatcherExtensions
|
33
|
+
end
|
34
|
+
unless Capybara::Node::Element.included_modules.include?(Cornucopia::Capybara::SelectableValues)
|
35
|
+
Capybara::Node::Element.include Cornucopia::Capybara::SelectableValues
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if Object.const_defined?("Capybara") &&
|
40
|
+
Capybara.const_defined?("Session")
|
41
|
+
unless Capybara::Session.included_modules.include?(Cornucopia::Capybara::Synchronizable)
|
42
|
+
Capybara::Session.include Cornucopia::Capybara::Synchronizable
|
43
|
+
end
|
44
|
+
end
|
@@ -1,38 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require ::File.expand_path("../util/configuration", File.dirname(__FILE__))
|
2
4
|
require ::File.expand_path("finder_diagnostics", File.dirname(__FILE__))
|
3
5
|
|
6
|
+
require "active_support/concern"
|
7
|
+
|
4
8
|
module Cornucopia
|
5
9
|
module Capybara
|
6
10
|
module MatcherExtensions
|
7
|
-
|
8
|
-
__cornucopia_assert_selector_function(:assert_selector, *args)
|
9
|
-
end
|
11
|
+
extend ActiveSupport::Concern
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
included do
|
14
|
+
alias_method :__cornucopia_orig_assert_selector, :assert_selector
|
15
|
+
alias_method :__cornucopia_orig_assert_no_selector, :assert_no_selector
|
16
|
+
alias_method :__cornucopia_orig_has_selector?, :has_selector?
|
17
|
+
alias_method :__cornucopia_orig_has_no_selector?, :has_no_selector?
|
14
18
|
|
15
|
-
|
16
|
-
|
17
|
-
|
19
|
+
define_method :assert_selector do |*args|
|
20
|
+
__cornucopia_assert_selector_function(:assert_selector, *args)
|
21
|
+
end
|
18
22
|
|
19
|
-
|
20
|
-
|
23
|
+
define_method :assert_no_selector do |*args|
|
24
|
+
__cornucopia_assert_selector_function(:assert_no_selector, *args)
|
21
25
|
end
|
22
26
|
|
23
|
-
|
24
|
-
|
27
|
+
define_method :has_selector? do |*args|
|
28
|
+
new_args = args.dup
|
29
|
+
options = (new_args.pop if new_args.length > 1 && new_args[-1].is_a?(Hash)) || {}
|
25
30
|
|
26
|
-
|
27
|
-
|
28
|
-
|
31
|
+
if Cornucopia::Util::Configuration.ignore_has_selector_errors
|
32
|
+
options = { __cornucopia_no_analysis: true }.merge options
|
33
|
+
end
|
29
34
|
|
30
|
-
|
31
|
-
|
35
|
+
__cornucopia_assert_selector_function(:has_selector?, *new_args, options)
|
36
|
+
end
|
37
|
+
|
38
|
+
define_method :has_no_selector? do |*args|
|
39
|
+
new_args = args.dup
|
40
|
+
options = (new_args.pop if new_args.length > 1 && new_args[-1].is_a?(Hash)) || {}
|
41
|
+
|
42
|
+
if Cornucopia::Util::Configuration.ignore_has_selector_errors
|
43
|
+
options = { __cornucopia_no_analysis: true }.merge options
|
44
|
+
end
|
45
|
+
__cornucopia_assert_selector_function(:has_no_selector?, *new_args, options)
|
32
46
|
end
|
33
|
-
__cornucopia_assert_selector_function(:has_no_selector?, *new_args, options)
|
34
47
|
end
|
35
48
|
|
49
|
+
|
36
50
|
def __cornucopia_assert_selector_function(assert_selector_function, *args)
|
37
51
|
retry_count = 0
|
38
52
|
result = nil
|
@@ -104,5 +118,3 @@ module Cornucopia
|
|
104
118
|
end
|
105
119
|
end
|
106
120
|
end
|
107
|
-
|
108
|
-
load ::File.expand_path("install_matcher_extensions.rb", File.dirname(__FILE__))
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "digest"
|
2
4
|
# require ::File.expand_path("../util/configuration", File.dirname(__FILE__))
|
3
5
|
require ::File.expand_path("../util/report_builder", File.dirname(__FILE__))
|
@@ -47,6 +49,9 @@ module Cornucopia
|
|
47
49
|
@html_frame = "use accessor"
|
48
50
|
@screen_shot = "use accessor"
|
49
51
|
@html_file = "use accessor"
|
52
|
+
@browser_logs = "use accessor"
|
53
|
+
@browser_info = "use accessor"
|
54
|
+
@all_cookies = "use accessor"
|
50
55
|
end
|
51
56
|
|
52
57
|
def can_dump_details?
|
@@ -148,6 +153,44 @@ module Cornucopia
|
|
148
153
|
value
|
149
154
|
end
|
150
155
|
|
156
|
+
def execute_browser_function(function_symbol, unsupported_value, *args)
|
157
|
+
value = unsupported_value
|
158
|
+
|
159
|
+
unless @driver.browser.respond_to?(function_symbol) ||
|
160
|
+
@driver.browser.manage.respond_to?(function_symbol)
|
161
|
+
@unsupported_list << function_symbol unless @driver.browser.respond_to?(function_symbol)
|
162
|
+
end
|
163
|
+
|
164
|
+
begin
|
165
|
+
unless @unsupported_list.include?(function_symbol)
|
166
|
+
value = if @driver.browser.respond_to?(function_symbol)
|
167
|
+
@driver.browser.send(function_symbol, *args)
|
168
|
+
else
|
169
|
+
@driver.browser.manage.send(function_symbol, *args)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
rescue ::Capybara::NotSupportedByDriverError
|
173
|
+
@unsupported_list << function_symbol
|
174
|
+
end
|
175
|
+
|
176
|
+
value
|
177
|
+
end
|
178
|
+
|
179
|
+
def browser_logs
|
180
|
+
value = execute_browser_function(:logs, nil)
|
181
|
+
|
182
|
+
types = value.available_types
|
183
|
+
types.each_with_object({}) { |type, hash| hash[type] = value.get(type) }
|
184
|
+
end
|
185
|
+
|
186
|
+
def browser_info
|
187
|
+
execute_browser_function(:logs, nil)
|
188
|
+
end
|
189
|
+
|
190
|
+
def all_cookies
|
191
|
+
execute_browser_function(:all_cookies, nil)
|
192
|
+
end
|
193
|
+
|
151
194
|
def page_url
|
152
195
|
execute_driver_function(:current_url, nil)
|
153
196
|
end
|
@@ -225,4 +268,4 @@ module Cornucopia
|
|
225
268
|
end
|
226
269
|
end
|
227
270
|
end
|
228
|
-
end
|
271
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../util/configuration", File.dirname(__FILE__))
|
4
|
+
require ::File.expand_path("finder_diagnostics", File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require "active_support/concern"
|
7
|
+
|
8
|
+
module Cornucopia
|
9
|
+
module Capybara
|
10
|
+
module SelectableValues
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
# select_value finds the option with the value #value then calls select_option on that item.
|
14
|
+
#
|
15
|
+
# select_value only works on select boxes.
|
16
|
+
def select_value(values)
|
17
|
+
raise "select_value is only valid for select items" unless self.tag_name == "select"
|
18
|
+
|
19
|
+
if values.is_a?(Array)
|
20
|
+
values.each do |value|
|
21
|
+
html_safe_value = "".html_safe + value.to_s
|
22
|
+
self.find("option[value=\"#{html_safe_value}\"]", visible: false).select_option
|
23
|
+
end
|
24
|
+
else
|
25
|
+
html_safe_value = "".html_safe + values.to_s
|
26
|
+
self.find("option[value=\"#{html_safe_value}\"]", visible: false).select_option
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# value_text returns the text for the selected items in the select box instead of the value(s)
|
31
|
+
#
|
32
|
+
# value_text only works on select boxes.
|
33
|
+
def value_text
|
34
|
+
raise "value_text is only valid for select items" unless self.tag_name == "select"
|
35
|
+
|
36
|
+
values = self.value
|
37
|
+
if values.is_a?(Array)
|
38
|
+
values.map do |value|
|
39
|
+
self.find("option[value=\"#{value}\"]", visible: false).text
|
40
|
+
end
|
41
|
+
else
|
42
|
+
self.find("option[value=\"#{values}\"]", visible: false).text
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../util/configuration", File.dirname(__FILE__))
|
4
|
+
require ::File.expand_path("finder_diagnostics", File.dirname(__FILE__))
|
5
|
+
|
6
|
+
require "active_support/concern"
|
7
|
+
|
8
|
+
module Cornucopia
|
9
|
+
module Capybara
|
10
|
+
module Synchronizable
|
11
|
+
extend ActiveSupport::Concern
|
12
|
+
|
13
|
+
# This function uses Capybara's synchronize function to evaluate a block until
|
14
|
+
# it becomes true.
|
15
|
+
def synchronize_test(seconds = nil, options = {}, &block)
|
16
|
+
seconds ||= ::Capybara.respond_to?(:default_max_wait_time) ? ::Capybara.default_max_wait_time : ::Capybara.default_wait_time
|
17
|
+
|
18
|
+
document.synchronize(seconds, options) do
|
19
|
+
raise ::Capybara::ElementNotFound unless block.yield
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,6 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require ::File.expand_path("../cornucopia", File.dirname(__FILE__))
|
2
|
-
|
3
|
-
load ::File.expand_path("
|
4
|
+
|
5
|
+
load ::File.expand_path("capybara/install_extensions.rb", File.dirname(__FILE__))
|
6
|
+
load ::File.expand_path("site_prism/install_extensions.rb", File.dirname(__FILE__))
|
4
7
|
|
5
8
|
require "singleton"
|
6
9
|
|
@@ -31,7 +34,7 @@ if Cucumber::VERSION.split[0].to_i >= 2
|
|
31
34
|
test_name = nil
|
32
35
|
|
33
36
|
scenario = scenario_proxy
|
34
|
-
time
|
37
|
+
time = Benchmark.measure do
|
35
38
|
puts "Cornucopia::Hook::before test" if Cornucopia::Util::Configuration.benchmark
|
36
39
|
|
37
40
|
test_name = Cornucopia::Util::TestHelper.instance.cucumber_name(scenario)
|