cornucopia 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +51 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +16 -0
- data/LICENSE.TXT +22 -0
- data/README.md +341 -0
- data/Rakefile +18 -0
- data/cornucopia.gemspec +39 -0
- data/lib/cornucopia.rb +18 -0
- data/lib/cornucopia/capybara/finder_diagnostics.rb +536 -0
- data/lib/cornucopia/capybara/finder_extensions.rb +89 -0
- data/lib/cornucopia/capybara/install_finder_extensions.rb +105 -0
- data/lib/cornucopia/capybara/install_matcher_extensions.rb +39 -0
- data/lib/cornucopia/capybara/matcher_extensions.rb +83 -0
- data/lib/cornucopia/capybara/page_diagnostics.rb +228 -0
- data/lib/cornucopia/cucumber_hooks.rb +38 -0
- data/lib/cornucopia/factory_girl/dynamic_association.rb +14 -0
- data/lib/cornucopia/rspec_hooks.rb +37 -0
- data/lib/cornucopia/site_prism/element_extensions.rb +273 -0
- data/lib/cornucopia/site_prism/install_element_extensions.rb +23 -0
- data/lib/cornucopia/site_prism/page_application.rb +126 -0
- data/lib/cornucopia/source_files/collapse.gif +0 -0
- data/lib/cornucopia/source_files/cornucopia.css +162 -0
- data/lib/cornucopia/source_files/expand.gif +0 -0
- data/lib/cornucopia/source_files/index_base.html +10 -0
- data/lib/cornucopia/source_files/index_contents.html +2 -0
- data/lib/cornucopia/source_files/more_info.js +87 -0
- data/lib/cornucopia/source_files/report_base.html +10 -0
- data/lib/cornucopia/source_files/report_contents.html +3 -0
- data/lib/cornucopia/spinach_hooks.rb +51 -0
- data/lib/cornucopia/util/configuration.rb +493 -0
- data/lib/cornucopia/util/configured_report.rb +520 -0
- data/lib/cornucopia/util/file_asset.rb +46 -0
- data/lib/cornucopia/util/generic_settings.rb +37 -0
- data/lib/cornucopia/util/log_capture.rb +97 -0
- data/lib/cornucopia/util/pretty_formatter.rb +580 -0
- data/lib/cornucopia/util/report_builder.rb +474 -0
- data/lib/cornucopia/util/report_formatters.rb +11 -0
- data/lib/cornucopia/util/report_table.rb +195 -0
- data/lib/cornucopia/version.rb +3 -0
- data/lib/tasks/cornucopia_tasks.rake +4 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +27 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cucumber.yml +8 -0
- data/spec/dummy/config/database.yml +37 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/db/schema.rb +16 -0
- data/spec/dummy/features/support/env.rb +66 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/lib/tasks/cucumber.rake +65 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/cucumber +10 -0
- data/spec/fixtures/sample_page.html +150 -0
- data/spec/lib/capybara/finder_diagnostics_spec.rb +517 -0
- data/spec/lib/capybara/finder_extensions_spec.rb +328 -0
- data/spec/lib/capybara/page_diagnostics_spec.rb +277 -0
- data/spec/lib/site_prism/element_extensions_spec.rb +290 -0
- data/spec/lib/site_prism/page_application_spec.rb +81 -0
- data/spec/lib/util/configuration_spec.rb +254 -0
- data/spec/lib/util/configured_report_spec.rb +1058 -0
- data/spec/lib/util/file_asset_spec.rb +86 -0
- data/spec/lib/util/generic_settings_spec.rb +48 -0
- data/spec/lib/util/log_capture_spec.rb +151 -0
- data/spec/lib/util/pretty_formatter_spec.rb +694 -0
- data/spec/lib/util/report_builder_spec.rb +983 -0
- data/spec/lib/util/report_formatters_spec.rb +13 -0
- data/spec/lib/util/report_table_exception_spec.rb +21 -0
- data/spec/lib/util/report_table_spec.rb +319 -0
- data/spec/pages/cornucopia_report_app.rb +10 -0
- data/spec/pages/google/email_page.rb +22 -0
- data/spec/pages/google/login_page.rb +25 -0
- data/spec/rails_helper.rb +43 -0
- data/spec/sample_report.rb +45 -0
- data/spec/spec_helper.rb +81 -0
- metadata +410 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
|
4
|
+
if vendored_cucumber_bin
|
5
|
+
load File.expand_path(vendored_cucumber_bin)
|
6
|
+
else
|
7
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
8
|
+
require 'cucumber'
|
9
|
+
load Cucumber::BINARY
|
10
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>This is a sample page</title>
|
4
|
+
</head>
|
5
|
+
<body>
|
6
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
There is a lot we could do in the body of a page.
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<select id="select-box">
|
13
|
+
<option value="0">100</option>
|
14
|
+
<option value="1">101</option>
|
15
|
+
<option value="2">102</option>
|
16
|
+
<option value="3">103</option>
|
17
|
+
<option value="4">104</option>
|
18
|
+
<option value="5">105</option>
|
19
|
+
<option value="6">106</option>
|
20
|
+
<option value="7">107</option>
|
21
|
+
<option value="8">108</option>
|
22
|
+
<option value="9">109</option>
|
23
|
+
<option value="10">110</option>
|
24
|
+
<option value="11">111</option>
|
25
|
+
<option value="12">112</option>
|
26
|
+
<option value="13">113</option>
|
27
|
+
<option value="14">114</option>
|
28
|
+
<option value="15">115</option>
|
29
|
+
<option value="16">116</option>
|
30
|
+
<option value="17">117</option>
|
31
|
+
<option value="18">118</option>
|
32
|
+
<option value="19">119</option>
|
33
|
+
</select>
|
34
|
+
|
35
|
+
<select id="multi-select-box" multiple="true">
|
36
|
+
<option value="0">200</option>
|
37
|
+
<option value="1">201</option>
|
38
|
+
<option value="2">202</option>
|
39
|
+
<option value="3">203</option>
|
40
|
+
<option value="4">204</option>
|
41
|
+
<option value="5">205</option>
|
42
|
+
<option value="6">206</option>
|
43
|
+
<option value="7">207</option>
|
44
|
+
<option value="8">208</option>
|
45
|
+
<option value="9">209</option>
|
46
|
+
<option value="10">210</option>
|
47
|
+
<option value="11">211</option>
|
48
|
+
<option value="12">212</option>
|
49
|
+
<option value="13">213</option>
|
50
|
+
<option value="14">214</option>
|
51
|
+
<option value="15">215</option>
|
52
|
+
<option value="16">216</option>
|
53
|
+
<option value="17">217</option>
|
54
|
+
<option value="18">218</option>
|
55
|
+
<option value="19">219</option>
|
56
|
+
</select>
|
57
|
+
|
58
|
+
<div class="single-class">Single</div>
|
59
|
+
<div class="multi-class">Multiples 1</div>
|
60
|
+
<div class="multi-class">Multiples 2</div>
|
61
|
+
<div class="multi-class">Multiples 3</div>
|
62
|
+
<div class="multi-class">Multiples 4</div>
|
63
|
+
|
64
|
+
<div class="parent-class">
|
65
|
+
<div class="single-class">Single 1</div>
|
66
|
+
<div class="multi-class">Multiples 1-1</div>
|
67
|
+
<div class="multi-class">Multiples 1-2</div>
|
68
|
+
<div class="multi-class">Multiples 1-3</div>
|
69
|
+
<div class="multi-class">Multiples 1-4</div>
|
70
|
+
</div>
|
71
|
+
|
72
|
+
<div id="hidden-div" class="hidden" style="display: none;">
|
73
|
+
<div class="parent-class">
|
74
|
+
<div class="single-class">Single 2</div>
|
75
|
+
<div class="multi-class">Multiples 2-1</div>
|
76
|
+
<div class="multi-class">Multiples 2-2</div>
|
77
|
+
<div class="multi-class">Multiples 2-3</div>
|
78
|
+
<div class="multi-class">Multiples 2-4</div>
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<a class="a-class b-class c-class" id="hidden-cool-link" href="#" onclick="alert('cool!');">Cool alert!</a>
|
82
|
+
<input class="a-class b-class c-class" id="hidden-cool-button" type="button" value="Still cool!" onclick="alert('still cool!');" />
|
83
|
+
<label>text box</label><input id="hidden-text-box" type="text" />
|
84
|
+
|
85
|
+
<div class="radio-container">
|
86
|
+
<input name="hidden-radio-group-1" id="hidden-radio-1" type="radio" value="1"> 1
|
87
|
+
<input name="hidden-radio-group-1" id="hidden-radio-2" type="radio" value="2"> 2
|
88
|
+
<input name="hidden-radio-group-1" id="hidden-radio-3" type="radio" value="3"> 3
|
89
|
+
<input name="hidden-radio-group-1" id="hidden-radio-4" type="radio" value="4"> 4
|
90
|
+
<input name="hidden-radio-group-1" id="hidden-radio-5" type="radio" value="5"> 5
|
91
|
+
<input name="hidden-radio-group-1" id="hidden-radio-6" type="radio" value="6"> 6
|
92
|
+
<input name="hidden-radio-group-1" id="hidden-radio-7" type="radio" value="7"> 7
|
93
|
+
<input name="hidden-radio-group-1" id="hidden-radio-8" type="radio" value="8"> 8
|
94
|
+
<input name="hidden-radio-group-1" id="hidden-radio-9" type="radio" value="9"> 9
|
95
|
+
<input name="hidden-radio-group-1" id="hidden-radio-10" type="radio" value="10"> 10
|
96
|
+
</div>
|
97
|
+
|
98
|
+
<div class="check-container">
|
99
|
+
<input id="hidden-check-1" type="checkbox" value="hidden-1"> 1
|
100
|
+
<input id="hidden-check-2" type="checkbox" value="hidden-2"> 2
|
101
|
+
<input id="hidden-check-3" type="checkbox" value="hidden-3"> 3
|
102
|
+
<input id="hidden-check-4" type="checkbox" value="hidden-4"> 4
|
103
|
+
<input id="hidden-check-5" type="checkbox" value="hidden-5"> 5
|
104
|
+
<input id="hidden-check-6" type="checkbox" value="hidden-6"> 6
|
105
|
+
<input id="hidden-check-7" type="checkbox" value="hidden-7"> 7
|
106
|
+
<input id="hidden-check-8" type="checkbox" value="hidden-8"> 8
|
107
|
+
<input id="hidden-check-9" type="checkbox" value="hidden-9"> 9
|
108
|
+
<input id="hidden-check-10" type="checkbox" value="hidden-10"> 10
|
109
|
+
</div>
|
110
|
+
</div>
|
111
|
+
|
112
|
+
<div class="parent-class">
|
113
|
+
<div class="single-class">Single 3</div>
|
114
|
+
<div class="multi-class">Multiples 3-1</div>
|
115
|
+
<div class="multi-class">Multiples 3-2</div>
|
116
|
+
<div class="multi-class">Multiples 3-3</div>
|
117
|
+
<div class="multi-class">Multiples 3-4</div>
|
118
|
+
</div>
|
119
|
+
|
120
|
+
<a id="cool-link" href="#" onclick="alert('cool!');">Cool alert!</a>
|
121
|
+
<input id="cool-button" type="button" value="Still cool!" onclick="alert('still cool!');" />
|
122
|
+
<label>text box</label><input id="text-box" type="text" />
|
123
|
+
|
124
|
+
<div class="radio-container">
|
125
|
+
<input name="radio-group-1" id="radio-1" type="radio" value="1"> 1
|
126
|
+
<input name="radio-group-1" id="radio-2" type="radio" value="2"> 2
|
127
|
+
<input name="radio-group-1" id="radio-3" type="radio" value="3"> 3
|
128
|
+
<input name="radio-group-1" id="radio-4" type="radio" value="4"> 4
|
129
|
+
<input name="radio-group-1" id="radio-5" type="radio" value="5"> 5
|
130
|
+
<input name="radio-group-1" id="radio-6" type="radio" value="6"> 6
|
131
|
+
<input name="radio-group-1" id="radio-7" type="radio" value="7"> 7
|
132
|
+
<input name="radio-group-1" id="radio-8" type="radio" value="8"> 8
|
133
|
+
<input name="radio-group-1" id="radio-9" type="radio" value="9"> 9
|
134
|
+
<input name="radio-group-1" id="radio-10" type="radio" value="10"> 10
|
135
|
+
</div>
|
136
|
+
|
137
|
+
<div class="check-container">
|
138
|
+
<input id="check-1" type="checkbox" value="1"> 1
|
139
|
+
<input id="check-2" type="checkbox" value="2"> 2
|
140
|
+
<input id="check-3" type="checkbox" value="3"> 3
|
141
|
+
<input id="check-4" type="checkbox" value="4"> 4
|
142
|
+
<input id="check-5" type="checkbox" value="5"> 5
|
143
|
+
<input id="check-6" type="checkbox" value="6"> 6
|
144
|
+
<input id="check-7" type="checkbox" value="7"> 7
|
145
|
+
<input id="check-8" type="checkbox" value="8"> 8
|
146
|
+
<input id="check-9" type="checkbox" value="9"> 9
|
147
|
+
<input id="check-10" type="checkbox" value="10"> 10
|
148
|
+
</div>
|
149
|
+
</body>
|
150
|
+
</html>
|
@@ -0,0 +1,517 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require ::File.expand_path("../../../lib/cornucopia/util/report_builder", File.dirname(__FILE__))
|
3
|
+
require ::File.expand_path("../../../lib/cornucopia/capybara/page_diagnostics", File.dirname(__FILE__))
|
4
|
+
require ::File.expand_path("../../../lib/cornucopia/capybara/finder_diagnostics", File.dirname(__FILE__))
|
5
|
+
|
6
|
+
describe Cornucopia::Capybara::FinderDiagnostics, type: :feature do
|
7
|
+
# Make sure that all tests start clean and get cleaned up afterwards...
|
8
|
+
around(:example) do |example|
|
9
|
+
expect(File.directory?(Rails.root.join("cornucopia_report/"))).to be_falsey
|
10
|
+
|
11
|
+
begin
|
12
|
+
@file_name_1 = generate_report_file("report_1")
|
13
|
+
|
14
|
+
example.run
|
15
|
+
ensure
|
16
|
+
if (Cornucopia::Util::ReportBuilder.class_variable_get("@@current_report"))
|
17
|
+
Cornucopia::Util::ReportBuilder.current_report.close
|
18
|
+
end
|
19
|
+
|
20
|
+
::Capybara.current_session.driver.window_handles.each do |handle|
|
21
|
+
if handle != ::Capybara.current_session.driver.current_window_handle
|
22
|
+
::Capybara.current_session.driver.close_window(handle)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
FileUtils.rm_rf Rails.root.join("cornucopia_report/")
|
27
|
+
FileUtils.rm_rf Rails.root.join("sample_report/")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
before(:context) do
|
32
|
+
@file_name_1 = generate_report_file("report_1")
|
33
|
+
::Capybara.app = Rack::File.new File.absolute_path(File.join(File.dirname(@file_name_1), "../.."))
|
34
|
+
end
|
35
|
+
|
36
|
+
it "does nothing if found" do
|
37
|
+
index_page = CornucopiaReportApp.index_page
|
38
|
+
|
39
|
+
index_page.load base_folder: "sample_report"
|
40
|
+
|
41
|
+
tester = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(index_page, {}, {}, :find, "#base-contents")
|
42
|
+
expect(tester).not_to receive(:perform_analysis)
|
43
|
+
|
44
|
+
tester.run
|
45
|
+
end
|
46
|
+
|
47
|
+
it "runs a report if not found" do
|
48
|
+
index_page = CornucopiaReportApp.index_page
|
49
|
+
|
50
|
+
index_page.load base_folder: "sample_report"
|
51
|
+
|
52
|
+
index_page.contents do |contents_frame|
|
53
|
+
tester = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(contents_frame, {}, {}, :find, "#base-contentss")
|
54
|
+
expect(tester).to receive(:perform_analysis).and_call_original
|
55
|
+
|
56
|
+
expect { tester.run }.to raise_error(Capybara::ElementNotFound)
|
57
|
+
end
|
58
|
+
|
59
|
+
Cornucopia::Util::ReportBuilder.current_report.close
|
60
|
+
|
61
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
62
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
63
|
+
report_page.contents do |contents_frame|
|
64
|
+
expect(contents_frame.errors.length).to be == 1
|
65
|
+
expect(contents_frame.errors[0].name.text).to be == "An error occurred while processing \"find\":"
|
66
|
+
expect(contents_frame.errors[0].tables[0].rows.length).to be == 7
|
67
|
+
expect(contents_frame.errors[0].tables[0].rows[0].labels[0].text).to be == "function_name"
|
68
|
+
expect(contents_frame.errors[0].tables[0].rows[0].values[0].text).to be == ":find"
|
69
|
+
expect(contents_frame.errors[0].tables[0].rows[1].labels[0].text).to be == "args[0]"
|
70
|
+
expect(contents_frame.errors[0].tables[0].rows[1].values[0].text).to be == "#base-contentss"
|
71
|
+
expect(contents_frame.errors[0].tables[0].rows[2].labels[0].text).to be == "search_args"
|
72
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables.length).to be == 1
|
73
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows.length).to be == 2
|
74
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[0].labels[0].text).to be == "0"
|
75
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[0].values[0].text).to be == ":css"
|
76
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[1].labels[0].text).to be == "1"
|
77
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[1].values[0].text).to be == "#base-contentss"
|
78
|
+
expect(contents_frame.errors[0].tables[0].rows[5].labels[0].text).to be == "exception"
|
79
|
+
expect(contents_frame.errors[0].tables[0].rows[5].values[0].text).to be == "Unable to find css \"#base-contentss\""
|
80
|
+
expect(contents_frame.errors[0].tables[0].rows[6].labels[0].text).to be == "backtrace"
|
81
|
+
expect(contents_frame.errors[0].tables[0].rows[6].expands[0]).to be
|
82
|
+
expect(contents_frame.errors[0].tables[0].rows[6].mores[0]).to be
|
83
|
+
expect(contents_frame.errors[0].tables[0].rows[6].values[0].text.length).to be > 0
|
84
|
+
|
85
|
+
contents_frame.errors[0].more_details.show_hide.click
|
86
|
+
expect(contents_frame.errors[0].more_details.details.rows.length).to be == 10
|
87
|
+
expect(contents_frame.errors[0].more_details.details.rows[0].labels[0].text).to be == "name"
|
88
|
+
expect(contents_frame.errors[0].more_details.details.rows[0].values[0].text).to be == "Capybara::ElementNotFound"
|
89
|
+
expect(contents_frame.errors[0].more_details.details.rows[1].labels[0].text).to be == "support_options"
|
90
|
+
expect(contents_frame.errors[0].more_details.details.rows[1].values[0].text).to be == "{:__cornucopia_no_analysis=>true, :__cornucopia_retry_with_found=>nil}"
|
91
|
+
expect(contents_frame.errors[0].more_details.details.rows[2].labels[0].text).to be == "page_url"
|
92
|
+
expect(contents_frame.errors[0].more_details.details.rows[2].values[0].text).to match /report_contents\.html/
|
93
|
+
expect(contents_frame.errors[0].more_details.details.rows[3].labels[0].text).to be == "title"
|
94
|
+
expect(contents_frame.errors[0].more_details.details.rows[3].values[0].text).to be == "Diagnostics report list"
|
95
|
+
expect(contents_frame.errors[0].more_details.details.rows[4].labels[0].text).to be == "screen_shot"
|
96
|
+
expect(contents_frame.errors[0].more_details.details.rows[4].value_images[0][:src]).to match /\/screen_shot\.png/
|
97
|
+
expect(contents_frame.errors[0].more_details.details.rows[5].labels[0].text).to be == "html_file"
|
98
|
+
expect(contents_frame.errors[0].more_details.details.rows[5].value_links[0][:href]).
|
99
|
+
to match /html_save_file\/__cornucopia_save_page\.html/
|
100
|
+
expect(contents_frame.errors[0].more_details.details.rows[6].labels[0].text).to be == "html_frame"
|
101
|
+
expect(contents_frame.errors[0].more_details.details.rows[6].value_frames[0][:src]).
|
102
|
+
to match /page_dump\.html/
|
103
|
+
expect(contents_frame.errors[0].more_details.details.rows[7].labels[0].text).to be == "html_source"
|
104
|
+
expect(contents_frame.errors[0].more_details.details.rows[7].value_textareas[0].text).to be
|
105
|
+
expect(contents_frame.errors[0].more_details.details.rows[8].labels[0].text).to be == "page_height"
|
106
|
+
expect(contents_frame.errors[0].more_details.details.rows[8].values[0].text).to be
|
107
|
+
expect(contents_frame.errors[0].more_details.details.rows[9].labels[0].text).to be == "page_width"
|
108
|
+
expect(contents_frame.errors[0].more_details.details.rows[9].values[0].text).to be
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
it "runs a report if too many found" do
|
113
|
+
@file_name_1 = generate_report_file("report_1")
|
114
|
+
|
115
|
+
index_page = CornucopiaReportApp.index_page
|
116
|
+
|
117
|
+
index_page.load base_folder: "sample_report"
|
118
|
+
|
119
|
+
index_page.contents do |contents_frame|
|
120
|
+
tester = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(contents_frame, {}, {}, :find, "a")
|
121
|
+
expect(tester).to receive(:perform_analysis).and_call_original
|
122
|
+
|
123
|
+
expect { tester.run }.to raise_error(Capybara::Ambiguous)
|
124
|
+
end
|
125
|
+
|
126
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
127
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
128
|
+
report_page.contents do |contents_frame|
|
129
|
+
expect(contents_frame.errors.length).to be == 1
|
130
|
+
expect(contents_frame.errors[0].name.text).to be == "An error occurred while processing \"find\":"
|
131
|
+
expect(contents_frame.errors[0].tables[0].rows.length).to be == 7
|
132
|
+
expect(contents_frame.errors[0].tables[0].rows[0].labels[0].text).to be == "function_name"
|
133
|
+
expect(contents_frame.errors[0].tables[0].rows[0].values[0].text).to be == ":find"
|
134
|
+
expect(contents_frame.errors[0].tables[0].rows[1].labels[0].text).to be == "args[0]"
|
135
|
+
expect(contents_frame.errors[0].tables[0].rows[1].values[0].text).to be == "a"
|
136
|
+
expect(contents_frame.errors[0].tables[0].rows[2].labels[0].text).to be == "search_args"
|
137
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables.length).to be == 1
|
138
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows.length).to be == 2
|
139
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[0].labels[0].text).to be == "0"
|
140
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[0].values[0].text).to be == ":css"
|
141
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[1].labels[0].text).to be == "1"
|
142
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[1].values[0].text).to be == "a"
|
143
|
+
expect(contents_frame.errors[0].tables[0].rows[5].labels[0].text).to be == "exception"
|
144
|
+
expect(contents_frame.errors[0].tables[0].rows[5].values[0].text).to match /Ambiguous match, found .+ elements matching css "a"/
|
145
|
+
expect(contents_frame.errors[0].tables[0].rows[6].labels[0].text).to be == "backtrace"
|
146
|
+
expect(contents_frame.errors[0].tables[0].rows[6].expands[0]).to be
|
147
|
+
expect(contents_frame.errors[0].tables[0].rows[6].mores[0]).to be
|
148
|
+
expect(contents_frame.errors[0].tables[0].rows[6].values[0].text.length).to be > 0
|
149
|
+
|
150
|
+
contents_frame.errors[0].more_details.show_hide.click
|
151
|
+
num_rows = contents_frame.errors[0].more_details.details.rows[1].sub_tables[0].rows.length
|
152
|
+
expect(contents_frame.errors[0].more_details.details.rows.length).to be == 12 + num_rows
|
153
|
+
expect(contents_frame.errors[0].more_details.details.rows[0].labels[0].text).to be == "name"
|
154
|
+
expect(contents_frame.errors[0].more_details.details.rows[0].values[0].text).to be == "Capybara::Ambiguous"
|
155
|
+
expect(contents_frame.errors[0].more_details.details.rows[1].labels[0].text).to be == "all_elements"
|
156
|
+
expect(contents_frame.errors[0].more_details.details.rows[1].sub_tables.length).to be > 1
|
157
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 2].labels[0].text).to be == "guessed_types"
|
158
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 2].values[0].text).to be
|
159
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 3].labels[0].text).to be == "support_options"
|
160
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 3].values[0].text).to be == "{:__cornucopia_no_analysis=>true, :__cornucopia_retry_with_found=>nil}"
|
161
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 4].labels[0].text).to be == "page_url"
|
162
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 4].values[0].text).to match /report_contents\.html/
|
163
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 5].labels[0].text).to be == "title"
|
164
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 5].values[0].text).to be == "Diagnostics report list"
|
165
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 6].labels[0].text).to be == "screen_shot"
|
166
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 6].value_images[0][:src]).to match /\/screen_shot\.png/
|
167
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 7].labels[0].text).to be == "html_file"
|
168
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 7].value_links[0][:href]).
|
169
|
+
to match /html_save_file\/__cornucopia_save_page\.html/
|
170
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 8].labels[0].text).to be == "html_frame"
|
171
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 8].value_frames[0][:src]).
|
172
|
+
to match /page_dump\.html/
|
173
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 9].labels[0].text).to be == "html_source"
|
174
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 9].value_textareas[0].text).to be
|
175
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 10].labels[0].text).to be == "page_height"
|
176
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 10].values[0].text).to be
|
177
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 11].labels[0].text).to be == "page_width"
|
178
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 11].values[0].text).to be
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
it "runs the finder when test_finder is called" do
|
183
|
+
index_page = CornucopiaReportApp.index_page
|
184
|
+
|
185
|
+
index_page.load base_folder: "sample_report"
|
186
|
+
|
187
|
+
index_page.contents do |contents_frame|
|
188
|
+
diag = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(contents_frame, {}, {}, :all, "a")
|
189
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).
|
190
|
+
to receive(:new).
|
191
|
+
with(contents_frame, {}, {}, :all, "a").
|
192
|
+
and_return(diag)
|
193
|
+
expect(diag).to receive(:run).and_call_original
|
194
|
+
|
195
|
+
find_all = contents_frame.all("a")
|
196
|
+
test_all = Cornucopia::Capybara::FinderDiagnostics.test_finder(contents_frame, :all, "a")
|
197
|
+
|
198
|
+
expect(find_all.length).to be == test_all.length
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
it "outputs an analysis when diagnose_finder is called" do
|
203
|
+
index_page = CornucopiaReportApp.index_page
|
204
|
+
|
205
|
+
index_page.load base_folder: "sample_report"
|
206
|
+
|
207
|
+
index_page.contents do |contents_frame|
|
208
|
+
diag = Cornucopia::Capybara::FinderDiagnostics::FindAction.
|
209
|
+
new(contents_frame, {}, {}, :all, :css, "a", visible: true)
|
210
|
+
expect(Cornucopia::Capybara::FinderDiagnostics::FindAction).
|
211
|
+
to receive(:new).
|
212
|
+
with(contents_frame, {}, {}, :all, :css, "a", visible: true).
|
213
|
+
and_return(diag)
|
214
|
+
expect(diag).to receive(:run).and_call_original
|
215
|
+
expect(diag).to receive(:generate_report).and_call_original
|
216
|
+
|
217
|
+
find_all = contents_frame.all("a")
|
218
|
+
test_all = Cornucopia::Capybara::FinderDiagnostics.
|
219
|
+
diagnose_finder(contents_frame, :all, :css, "a", visible: true)
|
220
|
+
|
221
|
+
expect(find_all.length).to be == test_all.length
|
222
|
+
end
|
223
|
+
|
224
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
225
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
226
|
+
report_page.contents do |contents_frame|
|
227
|
+
expect(contents_frame.errors.length).to be == 1
|
228
|
+
expect(contents_frame.errors[0].name.text).to be == "Diagnostic report on \"all\":"
|
229
|
+
expect(contents_frame.errors[0].tables[0].rows.length).to be == 7
|
230
|
+
expect(contents_frame.errors[0].tables[0].rows[0].labels[0].text).to be == "function_name"
|
231
|
+
expect(contents_frame.errors[0].tables[0].rows[0].values[0].text).to be == ":all"
|
232
|
+
expect(contents_frame.errors[0].tables[0].rows[1].labels[0].text).to be == "args[0]"
|
233
|
+
expect(contents_frame.errors[0].tables[0].rows[1].values[0].text).to be == ":css"
|
234
|
+
expect(contents_frame.errors[0].tables[0].rows[2].labels[0].text).to be == "search_args"
|
235
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables.length).to be == 1
|
236
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows.length).to be == 2
|
237
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[0].labels[0].text).to be == "0"
|
238
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[0].values[0].text).to be == ":css"
|
239
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[1].labels[0].text).to be == "1"
|
240
|
+
expect(contents_frame.errors[0].tables[0].rows[2].sub_tables[0].rows[1].values[0].text).to be == "a"
|
241
|
+
expect(contents_frame.errors[0].tables[0].rows[5].labels[0].text).to be == "options"
|
242
|
+
expect(contents_frame.errors[0].tables[0].rows[5].sub_tables.length).to be == 1
|
243
|
+
expect(contents_frame.errors[0].tables[0].rows[5].sub_tables[0].rows.length).to be == 1
|
244
|
+
expect(contents_frame.errors[0].tables[0].rows[5].sub_tables[0].rows[0].labels[0].text).to be == "visible"
|
245
|
+
expect(contents_frame.errors[0].tables[0].rows[5].sub_tables[0].rows[0].values[0].text).to be == "true"
|
246
|
+
|
247
|
+
contents_frame.errors[0].more_details.show_hide.click
|
248
|
+
num_rows = contents_frame.errors[0].more_details.details.rows[0].sub_tables[0].rows.length
|
249
|
+
expect(contents_frame.errors[0].more_details.details.rows.length).to be == 13 + num_rows
|
250
|
+
expect(contents_frame.errors[0].more_details.details.rows[0].labels[0].text).to be == "all_elements"
|
251
|
+
expect(contents_frame.errors[0].more_details.details.rows[0].sub_tables.length).to be > 1
|
252
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 1].labels[0].text).to be == "args"
|
253
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 2].labels[0].text).to be == "1"
|
254
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 2].values[0].text).to be == "a"
|
255
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 3].labels[0].text).to be == "2"
|
256
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 3].values[0].text).to be == "{:visible=>true}"
|
257
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 4].labels[0].text).to be == "guessed_types"
|
258
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 4].values[0].text).to be
|
259
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 5].labels[0].text).to be == "page_url"
|
260
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 5].values[0].text).
|
261
|
+
to match /report_contents\.html/
|
262
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 6].labels[0].text).to be == "title"
|
263
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 6].values[0].text).
|
264
|
+
to be == "Diagnostics report list"
|
265
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 7].labels[0].text).to be == "screen_shot"
|
266
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 7].value_images[0][:src]).
|
267
|
+
to match /\/screen_shot\.png/
|
268
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 8].labels[0].text).to be == "html_file"
|
269
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 8].value_links[0][:href]).
|
270
|
+
to match /html_save_file\/__cornucopia_save_page\.html/
|
271
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 9].labels[0].text).to be == "html_frame"
|
272
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 9].value_frames[0][:src]).
|
273
|
+
to match /page_dump\.html/
|
274
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 10].labels[0].text).to be == "html_source"
|
275
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 10].value_textareas[0].text).to be
|
276
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 11].labels[0].text).to be == "page_height"
|
277
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 11].values[0].text).to be
|
278
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 12].labels[0].text).to be == "page_width"
|
279
|
+
expect(contents_frame.errors[0].more_details.details.rows[num_rows + 12].values[0].text).to be
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
context "with a sample test file" do
|
284
|
+
let(:base_folder) { File.absolute_path(File.join(File.dirname(@file_name_1), "../..")) }
|
285
|
+
|
286
|
+
before(:example) do
|
287
|
+
Cornucopia::Util::FileAsset.new("../../../spec/fixtures/sample_page.html").
|
288
|
+
create_file(File.join(base_folder, "sample_report/sample_file.html"))
|
289
|
+
|
290
|
+
::Capybara.current_session.visit("/sample_report/sample_file.html")
|
291
|
+
end
|
292
|
+
|
293
|
+
it "finds hidden elements during analysis" do
|
294
|
+
base_object = ::Capybara.current_session.find(:css, "#hidden-div", visible: false)
|
295
|
+
expect { base_object.find("input[type=button]") }.to raise_error(Capybara::ElementNotFound)
|
296
|
+
|
297
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
298
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
299
|
+
report_page.contents do |contents_frame|
|
300
|
+
expect(contents_frame.errors.length).to be == 1
|
301
|
+
contents_frame.errors[0].more_details.show_hide.click
|
302
|
+
expect(contents_frame.errors[0].more_details.details.row(2).labels[0].text).to be == "all_other_elements"
|
303
|
+
|
304
|
+
hidden_row_specs = contents_frame.errors[0].more_details.details.row(1).sub_tables[0].rows[0].sub_tables[0].rows
|
305
|
+
expect(hidden_row_specs[0].labels[0].text).to be == "elem_checked"
|
306
|
+
expect(hidden_row_specs[1].labels[0].text).to be == "elem_id"
|
307
|
+
expect(hidden_row_specs[1].values[0].text).to be == "hidden-cool-button"
|
308
|
+
expect(hidden_row_specs[2].labels[0].text).to be == "elem_location"
|
309
|
+
expect(hidden_row_specs[3].labels[0].text).to be == "x"
|
310
|
+
expect(hidden_row_specs[4].labels[0].text).to be == "y"
|
311
|
+
expect(hidden_row_specs[5].labels[0].text).to be == "elem_outerHTML"
|
312
|
+
expect(hidden_row_specs[6].labels[0].text).to be == "elem_selected"
|
313
|
+
expect(hidden_row_specs[7].labels[0].text).to be == "elem_tag_name"
|
314
|
+
expect(hidden_row_specs[8].labels[0].text).to be == "elem_value"
|
315
|
+
expect(hidden_row_specs[9].labels[0].text).to be == "elem_visible"
|
316
|
+
expect(hidden_row_specs[9].values[0].text).to be == "false"
|
317
|
+
expect(hidden_row_specs[10].labels[0].text).to be == "native_class"
|
318
|
+
expect(hidden_row_specs[11].labels[0].text).to be == "native_onclick"
|
319
|
+
expect(hidden_row_specs[12].labels[0].text).to be == "native_size"
|
320
|
+
expect(hidden_row_specs[13].labels[0].text).to be == "width"
|
321
|
+
expect(hidden_row_specs[14].labels[0].text).to be == "height"
|
322
|
+
expect(hidden_row_specs[15].labels[0].text).to be == "native_type"
|
323
|
+
expect(hidden_row_specs[15].values[0].text).to be == "button"
|
324
|
+
end
|
325
|
+
end
|
326
|
+
|
327
|
+
it "finds selection options using the from option" do
|
328
|
+
report = Cornucopia::Util::ReportBuilder.current_report
|
329
|
+
|
330
|
+
report.within_section("an existing section") do |section|
|
331
|
+
section.within_table do |table|
|
332
|
+
table.write_stats "something", "a value"
|
333
|
+
find_action = Cornucopia::Capybara::FinderDiagnostics::FindAction.
|
334
|
+
new ::Capybara.current_session,
|
335
|
+
{ report: report,
|
336
|
+
table: table },
|
337
|
+
{},
|
338
|
+
:find,
|
339
|
+
"100",
|
340
|
+
from: "select-box"
|
341
|
+
|
342
|
+
allow(find_action).to receive(:guessed_types).and_return([])
|
343
|
+
|
344
|
+
find_action.generate_report("inside diagnostics") do |report, report_table|
|
345
|
+
report_table.write_stats("inside", "value")
|
346
|
+
end
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
350
|
+
report.close
|
351
|
+
|
352
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
353
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
354
|
+
report_page.contents do |contents_frame|
|
355
|
+
expect(contents_frame.errors.length).to be == 1
|
356
|
+
|
357
|
+
the_row = contents_frame.errors[0].tables[0].row(0)
|
358
|
+
expect(the_row.labels[0].text).to be == "something"
|
359
|
+
expect(the_row.values[0].text).to be == "a value"
|
360
|
+
|
361
|
+
the_row = contents_frame.errors[0].tables[0].row(2)
|
362
|
+
expect(the_row.labels[0].text).to be == "function_name"
|
363
|
+
expect(the_row.values[0].text).to be == ":find"
|
364
|
+
|
365
|
+
the_row = contents_frame.errors[0].tables[0].rows.last
|
366
|
+
expect(the_row.labels[0].text).to be == "inside"
|
367
|
+
expect(the_row.values[0].text).to be == "value"
|
368
|
+
end
|
369
|
+
end
|
370
|
+
|
371
|
+
it "deals with it if the from isn't found" do
|
372
|
+
find_action = Cornucopia::Capybara::FinderDiagnostics::FindAction.
|
373
|
+
new ::Capybara.current_session,
|
374
|
+
{},
|
375
|
+
{},
|
376
|
+
:select,
|
377
|
+
"100",
|
378
|
+
from: "select-boxes"
|
379
|
+
|
380
|
+
find_action.generate_report("inside diagnostics")
|
381
|
+
|
382
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
383
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
384
|
+
report_page.contents do |contents_frame|
|
385
|
+
expect(contents_frame.errors.length).to be == 1
|
386
|
+
|
387
|
+
the_row = contents_frame.errors[0].tables[4].row(0)
|
388
|
+
expect(the_row.labels[0].text).to be == "function_name"
|
389
|
+
expect(the_row.values[0].text).to be == ":select"
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
393
|
+
it "will retry with what it actually finds..." do
|
394
|
+
begin
|
395
|
+
Cornucopia::Util::Configuration.retry_with_found = true
|
396
|
+
|
397
|
+
base_object = ::Capybara.current_session.find(:css, "#hidden-div", visible: false)
|
398
|
+
button = base_object.all("input[type=button]", count: 1)
|
399
|
+
|
400
|
+
expect(button.length).to be == 1
|
401
|
+
expect(button[0].class).to be == ::Capybara::Node::Element
|
402
|
+
|
403
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
404
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
405
|
+
report_page.contents do |contents_frame|
|
406
|
+
contents_frame.errors[0].more_details.show_hide.click
|
407
|
+
expect(contents_frame.errors.length).to be == 1
|
408
|
+
expect(contents_frame.errors[0].tables[0].rows.last.labels[0].text).not_to be == "Retrying action:"
|
409
|
+
expect(contents_frame.errors[0].more_details.details.rows.last.labels[0].text).to be == "Retrying action:"
|
410
|
+
expect(contents_frame.errors[0].more_details.details.rows.last.values[0].text).to be == "Success"
|
411
|
+
end
|
412
|
+
ensure
|
413
|
+
Cornucopia::Util::Configuration.retry_with_found = false
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
describe "#retry_action_with_found_element" do
|
418
|
+
it "find and it will appropriately handle the driver not supporting evaluate_script" do
|
419
|
+
begin
|
420
|
+
Cornucopia::Util::Configuration.retry_with_found = true
|
421
|
+
|
422
|
+
base_object = ::Capybara.current_session.find(:css, "#hidden-div", visible: false)
|
423
|
+
button = base_object.find("input[type=button]")
|
424
|
+
|
425
|
+
expect(button.class).to be == ::Capybara::Node::Element
|
426
|
+
|
427
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
428
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
429
|
+
report_page.contents do |contents_frame|
|
430
|
+
contents_frame.errors[0].more_details.show_hide.click
|
431
|
+
expect(contents_frame.errors.length).to be == 1
|
432
|
+
expect(contents_frame.errors[0].tables[0].rows.last.labels[0].text).not_to be == "Retrying action:"
|
433
|
+
expect(contents_frame.errors[0].more_details.details.rows.last.labels[0].text).to be == "Retrying action:"
|
434
|
+
expect(contents_frame.errors[0].more_details.details.rows.last.values[0].text).to be == "Success"
|
435
|
+
end
|
436
|
+
ensure
|
437
|
+
Cornucopia::Util::Configuration.retry_with_found = false
|
438
|
+
end
|
439
|
+
end
|
440
|
+
|
441
|
+
it "first" do
|
442
|
+
begin
|
443
|
+
Cornucopia::Util::Configuration.retry_with_found = true
|
444
|
+
|
445
|
+
allow_any_instance_of(::Capybara::Node::Element).to receive(:outerHTML).and_return(nil)
|
446
|
+
|
447
|
+
expect(::Capybara.current_session).
|
448
|
+
to receive(:evaluate_script).at_least(1).times.and_raise(::Capybara::NotSupportedByDriverError)
|
449
|
+
expect_any_instance_of(::Selenium::WebDriver::Driver).
|
450
|
+
to receive(:execute_script).at_least(1).times.and_raise(::Capybara::NotSupportedByDriverError)
|
451
|
+
|
452
|
+
base_object = ::Capybara.current_session.find(:css, "#hidden-div", visible: false)
|
453
|
+
button = base_object.first("Still cool!", count: 1)
|
454
|
+
|
455
|
+
expect(button.class).to be == ::Capybara::Node::Element
|
456
|
+
|
457
|
+
report_page = CornucopiaReportApp.cornucopia_report_page
|
458
|
+
report_page.load(report_name: "cornucopia_report", base_folder: "cornucopia_report")
|
459
|
+
report_page.contents do |contents_frame|
|
460
|
+
contents_frame.errors[0].more_details.show_hide.click
|
461
|
+
expect(contents_frame.errors.length).to be == 1
|
462
|
+
expect(contents_frame.errors[0].tables[0].rows.last.labels[0].text).not_to be == "Retrying action:"
|
463
|
+
expect(contents_frame.errors[0].more_details.details.rows.last.labels[0].text).to be == "Retrying action:"
|
464
|
+
expect(contents_frame.errors[0].more_details.details.rows.last.values[0].text).to be == "Success"
|
465
|
+
end
|
466
|
+
ensure
|
467
|
+
Cornucopia::Util::Configuration.retry_with_found = false
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
it "finds selection options using the from option" do
|
472
|
+
report = Cornucopia::Util::ReportBuilder.current_report
|
473
|
+
|
474
|
+
module Cornucopia
|
475
|
+
module Capybara
|
476
|
+
class FinderDiagnostics
|
477
|
+
def self.test_finder_stupid
|
478
|
+
found_1 = FindAction::FoundElement.new(::Capybara.page.find("#select-box"))
|
479
|
+
found_2 = FindAction::FoundElement.new(::Capybara.page.find("#select-box"))
|
480
|
+
|
481
|
+
found_1 == found_2
|
482
|
+
end
|
483
|
+
|
484
|
+
def self.test_not_finder_stupid
|
485
|
+
found_1 = FindAction::FoundElement.new(::Capybara.page.find("#select-box"))
|
486
|
+
found_2 = FindAction::FoundElement.new(::Capybara.page.find("#multi-select-box"))
|
487
|
+
|
488
|
+
found_1 == found_2
|
489
|
+
end
|
490
|
+
end
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
expect(Cornucopia::Capybara::FinderDiagnostics.test_finder_stupid).to be_truthy
|
495
|
+
expect(Cornucopia::Capybara::FinderDiagnostics.test_not_finder_stupid).to be_falsey
|
496
|
+
end
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
describe "FindAction" do
|
501
|
+
it "returns perform_analysis's result" do
|
502
|
+
index_page = CornucopiaReportApp.index_page
|
503
|
+
|
504
|
+
index_page.load base_folder: "sample_report"
|
505
|
+
|
506
|
+
index_page.contents do |contents_frame|
|
507
|
+
tester = Cornucopia::Capybara::FinderDiagnostics::FindAction.new(contents_frame, {}, {}, :find, "#base-contentss")
|
508
|
+
test_value = [nil, true, false, Faker::Lorem.sentence].sample
|
509
|
+
|
510
|
+
expect(tester).to receive(:perform_analysis).and_return true
|
511
|
+
tester.instance_variable_set(:@return_value, test_value)
|
512
|
+
|
513
|
+
expect(tester.run).to eq test_value
|
514
|
+
end
|
515
|
+
end
|
516
|
+
end
|
517
|
+
end
|