cornucopia 0.1.55 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +0 -2
- data/.ruby-version +1 -0
- data/Gemfile +4 -1
- data/Gemfile.lock +297 -0
- data/cornucopia.gemspec +13 -12
- data/lib/cornucopia/capybara/finder_diagnostics/find_action/found_element.rb +155 -0
- data/lib/cornucopia/capybara/finder_diagnostics/find_action.rb +417 -0
- data/lib/cornucopia/capybara/finder_diagnostics.rb +9 -551
- data/lib/cornucopia/capybara/finder_extensions.rb +34 -26
- data/lib/cornucopia/capybara/install_extensions.rb +6 -6
- data/lib/cornucopia/capybara/matcher_extensions.rb +110 -47
- data/lib/cornucopia/capybara/page_diagnostics/window_iterator.rb +42 -0
- data/lib/cornucopia/capybara/page_diagnostics.rb +1 -30
- data/lib/cornucopia/capybara/synchronizable.rb +1 -1
- data/lib/cornucopia/site_prism/class_extensions.rb +13 -0
- data/lib/cornucopia/site_prism/element_extensions.rb +7 -4
- data/lib/cornucopia/site_prism/install_extensions.rb +1 -1
- data/lib/cornucopia/site_prism/page_application.rb +3 -3
- data/lib/cornucopia/site_prism/section_extensions.rb +3 -11
- data/lib/cornucopia/util/report_builder.rb +1 -1
- data/lib/cornucopia/version.rb +1 -1
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/config/application.rb +1 -1
- data/spec/lib/capybara/finder_diagnostics_spec.rb +11 -13
- data/spec/lib/capybara/finder_extensions_spec.rb +19 -11
- data/spec/lib/capybara/matcher_extensions_spec.rb +13 -15
- data/spec/lib/capybara/page_diagnostics_spec.rb +1 -1
- data/spec/lib/site_prism/element_extensions_spec.rb +3 -3
- data/spec/lib/util/configured_report_spec.rb +4 -4
- data/spec/lib/util/log_capture_spec.rb +5 -5
- data/spec/lib/util/report_builder_spec.rb +3 -3
- data/spec/lib/util/report_table_spec.rb +5 -5
- data/spec/pages/cornucopia_report_pages/cornucopia_report_test_contents_page.rb +1 -1
- data/spec/sample_report.rb +6 -6
- data/spec/spec_helper.rb +5 -1
- metadata +37 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ff5dbeea3aa850a07b6a55dc69d7ab547a93c6772c7aa67586025ef0c58e5b5b
|
4
|
+
data.tar.gz: e03d325d2df3e708e8ceb640d4284820d00022812a56d0c41adecb660d366670
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41df757e4bed265adf5bdd8b30aa21f3b98e1e2e044e0f8863776ee6ddaece592843c4b45ac26fa7b74b2d05a751ee8be3d0be13ccc0193aeafc0ac8bf09684d
|
7
|
+
data.tar.gz: 974c3c15bc9b4f08e1cedc7073bf7b766c7114a1c8f23c6a9d0c25e41c77b9bd4741fec9e2cc9792f767ecd3dceaefef087b4addabab12d9ff7b3c724bfd0959
|
data/.gitignore
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.6
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,297 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
cornucopia (0.2.0)
|
5
|
+
activesupport (> 4.0, < 8.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actioncable (7.1.2)
|
11
|
+
actionpack (= 7.1.2)
|
12
|
+
activesupport (= 7.1.2)
|
13
|
+
nio4r (~> 2.0)
|
14
|
+
websocket-driver (>= 0.6.1)
|
15
|
+
zeitwerk (~> 2.6)
|
16
|
+
actionmailbox (7.1.2)
|
17
|
+
actionpack (= 7.1.2)
|
18
|
+
activejob (= 7.1.2)
|
19
|
+
activerecord (= 7.1.2)
|
20
|
+
activestorage (= 7.1.2)
|
21
|
+
activesupport (= 7.1.2)
|
22
|
+
mail (>= 2.7.1)
|
23
|
+
net-imap
|
24
|
+
net-pop
|
25
|
+
net-smtp
|
26
|
+
actionmailer (7.1.2)
|
27
|
+
actionpack (= 7.1.2)
|
28
|
+
actionview (= 7.1.2)
|
29
|
+
activejob (= 7.1.2)
|
30
|
+
activesupport (= 7.1.2)
|
31
|
+
mail (~> 2.5, >= 2.5.4)
|
32
|
+
net-imap
|
33
|
+
net-pop
|
34
|
+
net-smtp
|
35
|
+
rails-dom-testing (~> 2.2)
|
36
|
+
actionpack (7.1.2)
|
37
|
+
actionview (= 7.1.2)
|
38
|
+
activesupport (= 7.1.2)
|
39
|
+
nokogiri (>= 1.8.5)
|
40
|
+
racc
|
41
|
+
rack (>= 2.2.4)
|
42
|
+
rack-session (>= 1.0.1)
|
43
|
+
rack-test (>= 0.6.3)
|
44
|
+
rails-dom-testing (~> 2.2)
|
45
|
+
rails-html-sanitizer (~> 1.6)
|
46
|
+
actiontext (7.1.2)
|
47
|
+
actionpack (= 7.1.2)
|
48
|
+
activerecord (= 7.1.2)
|
49
|
+
activestorage (= 7.1.2)
|
50
|
+
activesupport (= 7.1.2)
|
51
|
+
globalid (>= 0.6.0)
|
52
|
+
nokogiri (>= 1.8.5)
|
53
|
+
actionview (7.1.2)
|
54
|
+
activesupport (= 7.1.2)
|
55
|
+
builder (~> 3.1)
|
56
|
+
erubi (~> 1.11)
|
57
|
+
rails-dom-testing (~> 2.2)
|
58
|
+
rails-html-sanitizer (~> 1.6)
|
59
|
+
activejob (7.1.2)
|
60
|
+
activesupport (= 7.1.2)
|
61
|
+
globalid (>= 0.3.6)
|
62
|
+
activemodel (7.1.2)
|
63
|
+
activesupport (= 7.1.2)
|
64
|
+
activerecord (7.1.2)
|
65
|
+
activemodel (= 7.1.2)
|
66
|
+
activesupport (= 7.1.2)
|
67
|
+
timeout (>= 0.4.0)
|
68
|
+
activestorage (7.1.2)
|
69
|
+
actionpack (= 7.1.2)
|
70
|
+
activejob (= 7.1.2)
|
71
|
+
activerecord (= 7.1.2)
|
72
|
+
activesupport (= 7.1.2)
|
73
|
+
marcel (~> 1.0)
|
74
|
+
activesupport (7.1.2)
|
75
|
+
base64
|
76
|
+
bigdecimal
|
77
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
78
|
+
connection_pool (>= 2.2.5)
|
79
|
+
drb
|
80
|
+
i18n (>= 1.6, < 2)
|
81
|
+
minitest (>= 5.1)
|
82
|
+
mutex_m
|
83
|
+
tzinfo (~> 2.0)
|
84
|
+
addressable (2.8.6)
|
85
|
+
public_suffix (>= 2.0.2, < 6.0)
|
86
|
+
base64 (0.2.0)
|
87
|
+
bigdecimal (3.1.5)
|
88
|
+
builder (3.2.4)
|
89
|
+
capybara (3.39.2)
|
90
|
+
addressable
|
91
|
+
matrix
|
92
|
+
mini_mime (>= 0.1.3)
|
93
|
+
nokogiri (~> 1.8)
|
94
|
+
rack (>= 1.6.0)
|
95
|
+
rack-test (>= 0.6.3)
|
96
|
+
regexp_parser (>= 1.5, < 3.0)
|
97
|
+
xpath (~> 3.2)
|
98
|
+
concurrent-ruby (1.2.2)
|
99
|
+
connection_pool (2.4.1)
|
100
|
+
crass (1.0.6)
|
101
|
+
cucumber (9.1.1)
|
102
|
+
builder (~> 3.2, >= 3.2.4)
|
103
|
+
cucumber-ci-environment (~> 9.2, >= 9.2.0)
|
104
|
+
cucumber-core (~> 12.0)
|
105
|
+
cucumber-cucumber-expressions (~> 17.0)
|
106
|
+
cucumber-gherkin (> 24, < 27)
|
107
|
+
cucumber-html-formatter (> 20.3, < 22)
|
108
|
+
cucumber-messages (> 19, < 25)
|
109
|
+
diff-lcs (~> 1.5)
|
110
|
+
mini_mime (~> 1.1, >= 1.1.5)
|
111
|
+
multi_test (~> 1.1, >= 1.1.0)
|
112
|
+
sys-uname (~> 1.2, >= 1.2.3)
|
113
|
+
cucumber-ci-environment (9.2.0)
|
114
|
+
cucumber-core (12.0.0)
|
115
|
+
cucumber-gherkin (>= 25, < 27)
|
116
|
+
cucumber-messages (>= 20, < 23)
|
117
|
+
cucumber-tag-expressions (~> 5.0, >= 5.0.4)
|
118
|
+
cucumber-cucumber-expressions (17.0.1)
|
119
|
+
cucumber-gherkin (26.2.0)
|
120
|
+
cucumber-messages (>= 19.1.4, < 22.1)
|
121
|
+
cucumber-html-formatter (21.2.0)
|
122
|
+
cucumber-messages (> 19, < 25)
|
123
|
+
cucumber-messages (22.0.0)
|
124
|
+
cucumber-rails (3.0.0)
|
125
|
+
capybara (>= 3.11, < 4)
|
126
|
+
cucumber (>= 5, < 10)
|
127
|
+
railties (>= 5.2, < 8)
|
128
|
+
cucumber-tag-expressions (5.0.6)
|
129
|
+
date (3.3.4)
|
130
|
+
diff-lcs (1.5.0)
|
131
|
+
docile (1.4.0)
|
132
|
+
drb (2.2.0)
|
133
|
+
ruby2_keywords
|
134
|
+
erubi (1.12.0)
|
135
|
+
faker (3.2.3)
|
136
|
+
i18n (>= 1.8.11, < 2)
|
137
|
+
ffi (1.16.3)
|
138
|
+
gem-release (2.2.2)
|
139
|
+
globalid (1.2.1)
|
140
|
+
activesupport (>= 6.1)
|
141
|
+
i18n (1.14.1)
|
142
|
+
concurrent-ruby (~> 1.0)
|
143
|
+
io-console (0.7.1)
|
144
|
+
irb (1.11.1)
|
145
|
+
rdoc
|
146
|
+
reline (>= 0.4.2)
|
147
|
+
launchy (2.5.2)
|
148
|
+
addressable (~> 2.8)
|
149
|
+
loofah (2.22.0)
|
150
|
+
crass (~> 1.0.2)
|
151
|
+
nokogiri (>= 1.12.0)
|
152
|
+
mail (2.8.1)
|
153
|
+
mini_mime (>= 0.1.1)
|
154
|
+
net-imap
|
155
|
+
net-pop
|
156
|
+
net-smtp
|
157
|
+
marcel (1.0.2)
|
158
|
+
matrix (0.4.2)
|
159
|
+
mini_mime (1.1.5)
|
160
|
+
mini_portile2 (2.8.5)
|
161
|
+
minitest (5.21.1)
|
162
|
+
multi_test (1.1.0)
|
163
|
+
mutex_m (0.2.0)
|
164
|
+
net-imap (0.4.9.1)
|
165
|
+
date
|
166
|
+
net-protocol
|
167
|
+
net-pop (0.1.2)
|
168
|
+
net-protocol
|
169
|
+
net-protocol (0.2.2)
|
170
|
+
timeout
|
171
|
+
net-smtp (0.4.0.1)
|
172
|
+
net-protocol
|
173
|
+
nio4r (2.7.0)
|
174
|
+
nokogiri (1.16.0)
|
175
|
+
mini_portile2 (~> 2.8.2)
|
176
|
+
racc (~> 1.4)
|
177
|
+
psych (5.1.2)
|
178
|
+
stringio
|
179
|
+
public_suffix (5.0.4)
|
180
|
+
racc (1.7.3)
|
181
|
+
rack (3.0.8)
|
182
|
+
rack-session (2.0.0)
|
183
|
+
rack (>= 3.0.0)
|
184
|
+
rack-test (2.1.0)
|
185
|
+
rack (>= 1.3)
|
186
|
+
rackup (2.1.0)
|
187
|
+
rack (>= 3)
|
188
|
+
webrick (~> 1.8)
|
189
|
+
rails (7.1.2)
|
190
|
+
actioncable (= 7.1.2)
|
191
|
+
actionmailbox (= 7.1.2)
|
192
|
+
actionmailer (= 7.1.2)
|
193
|
+
actionpack (= 7.1.2)
|
194
|
+
actiontext (= 7.1.2)
|
195
|
+
actionview (= 7.1.2)
|
196
|
+
activejob (= 7.1.2)
|
197
|
+
activemodel (= 7.1.2)
|
198
|
+
activerecord (= 7.1.2)
|
199
|
+
activestorage (= 7.1.2)
|
200
|
+
activesupport (= 7.1.2)
|
201
|
+
bundler (>= 1.15.0)
|
202
|
+
railties (= 7.1.2)
|
203
|
+
rails-dom-testing (2.2.0)
|
204
|
+
activesupport (>= 5.0.0)
|
205
|
+
minitest
|
206
|
+
nokogiri (>= 1.6)
|
207
|
+
rails-html-sanitizer (1.6.0)
|
208
|
+
loofah (~> 2.21)
|
209
|
+
nokogiri (~> 1.14)
|
210
|
+
railties (7.1.2)
|
211
|
+
actionpack (= 7.1.2)
|
212
|
+
activesupport (= 7.1.2)
|
213
|
+
irb
|
214
|
+
rackup (>= 1.0.0)
|
215
|
+
rake (>= 12.2)
|
216
|
+
thor (~> 1.0, >= 1.2.2)
|
217
|
+
zeitwerk (~> 2.6)
|
218
|
+
rake (13.1.0)
|
219
|
+
rdoc (6.6.2)
|
220
|
+
psych (>= 4.0.0)
|
221
|
+
regexp_parser (2.9.0)
|
222
|
+
reline (0.4.2)
|
223
|
+
io-console (~> 0.5)
|
224
|
+
rexml (3.2.6)
|
225
|
+
rspec-core (3.12.2)
|
226
|
+
rspec-support (~> 3.12.0)
|
227
|
+
rspec-expectations (3.12.3)
|
228
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
229
|
+
rspec-support (~> 3.12.0)
|
230
|
+
rspec-mocks (3.12.6)
|
231
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
232
|
+
rspec-support (~> 3.12.0)
|
233
|
+
rspec-rails (6.1.0)
|
234
|
+
actionpack (>= 6.1)
|
235
|
+
activesupport (>= 6.1)
|
236
|
+
railties (>= 6.1)
|
237
|
+
rspec-core (~> 3.12)
|
238
|
+
rspec-expectations (~> 3.12)
|
239
|
+
rspec-mocks (~> 3.12)
|
240
|
+
rspec-support (~> 3.12)
|
241
|
+
rspec-support (3.12.1)
|
242
|
+
ruby2_keywords (0.0.5)
|
243
|
+
rubyzip (2.3.2)
|
244
|
+
selenium-webdriver (4.16.0)
|
245
|
+
rexml (~> 3.2, >= 3.2.5)
|
246
|
+
rubyzip (>= 1.2.2, < 3.0)
|
247
|
+
websocket (~> 1.0)
|
248
|
+
simplecov (0.22.0)
|
249
|
+
docile (~> 1.1)
|
250
|
+
simplecov-html (~> 0.11)
|
251
|
+
simplecov_json_formatter (~> 0.1)
|
252
|
+
simplecov-html (0.12.3)
|
253
|
+
simplecov_json_formatter (0.1.4)
|
254
|
+
site_prism (5.0)
|
255
|
+
addressable (~> 2.8, >= 2.8.1)
|
256
|
+
capybara (~> 3.31)
|
257
|
+
site_prism-all_there (> 2, < 5)
|
258
|
+
site_prism-all_there (3.0.3)
|
259
|
+
stringio (3.1.0)
|
260
|
+
sys-uname (1.2.3)
|
261
|
+
ffi (~> 1.1)
|
262
|
+
thor (1.3.0)
|
263
|
+
timeout (0.4.1)
|
264
|
+
tzinfo (2.0.6)
|
265
|
+
concurrent-ruby (~> 1.0)
|
266
|
+
webrick (1.8.1)
|
267
|
+
websocket (1.2.10)
|
268
|
+
websocket-driver (0.7.6)
|
269
|
+
websocket-extensions (>= 0.1.0)
|
270
|
+
websocket-extensions (0.1.5)
|
271
|
+
xpath (3.2.0)
|
272
|
+
nokogiri (~> 1.8)
|
273
|
+
zeitwerk (2.6.12)
|
274
|
+
|
275
|
+
PLATFORMS
|
276
|
+
ruby
|
277
|
+
|
278
|
+
DEPENDENCIES
|
279
|
+
bundler
|
280
|
+
capybara
|
281
|
+
cornucopia!
|
282
|
+
cucumber
|
283
|
+
cucumber-rails
|
284
|
+
faker
|
285
|
+
gem-release
|
286
|
+
launchy
|
287
|
+
rack
|
288
|
+
rails
|
289
|
+
rake
|
290
|
+
rspec-rails
|
291
|
+
selenium-webdriver
|
292
|
+
simplecov
|
293
|
+
site_prism
|
294
|
+
webrick
|
295
|
+
|
296
|
+
BUNDLED WITH
|
297
|
+
2.5.4
|
data/cornucopia.gemspec
CHANGED
@@ -7,25 +7,25 @@ require "cornucopia/version"
|
|
7
7
|
|
8
8
|
# Describe your gem and declare its dependencies:
|
9
9
|
Gem::Specification.new do |spec|
|
10
|
-
spec.name
|
11
|
-
spec.version
|
12
|
-
spec.authors
|
13
|
-
spec.email
|
14
|
-
spec.summary
|
15
|
-
spec.description
|
16
|
-
spec.homepage
|
17
|
-
spec.license
|
10
|
+
spec.name = "cornucopia"
|
11
|
+
spec.version = Cornucopia::VERSION
|
12
|
+
spec.authors = ["RealNobody"]
|
13
|
+
spec.email = ["RealNobody1@cox.net"]
|
14
|
+
spec.summary = "A collection of tools to simplify testing tasks."
|
15
|
+
spec.description = "A collection of tools I created to simplify and make it easier to see what is happening."
|
16
|
+
spec.homepage = "https://github.com/RealNobody/cornucopia"
|
17
|
+
spec.license = "MIT"
|
18
|
+
spec.required_ruby_version = '>= 3'
|
18
19
|
|
19
20
|
# spec.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
20
|
-
spec.files
|
21
|
+
spec.files = `git ls-files`.split($/)
|
21
22
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
22
23
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
23
24
|
spec.require_paths = ["lib"]
|
24
25
|
|
25
|
-
spec.add_dependency "activesupport", "<
|
26
|
+
spec.add_dependency "activesupport", "> 4.0", "< 8.0"
|
26
27
|
|
27
28
|
spec.add_development_dependency "rails"
|
28
|
-
# spec.add_development_dependency "mysql2"
|
29
29
|
spec.add_development_dependency "bundler"
|
30
30
|
spec.add_development_dependency "rake"
|
31
31
|
spec.add_development_dependency "rspec-rails"
|
@@ -38,4 +38,5 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency "simplecov"
|
39
39
|
spec.add_development_dependency "launchy"
|
40
40
|
spec.add_development_dependency "rack"
|
41
|
-
|
41
|
+
spec.add_development_dependency "webrick"
|
42
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require ::File.expand_path("../../../util/configuration", File.dirname(__FILE__))
|
4
|
+
require ::File.expand_path("../../../util/report_builder", File.dirname(__FILE__))
|
5
|
+
|
6
|
+
module Cornucopia
|
7
|
+
module Capybara
|
8
|
+
class FinderDiagnostics
|
9
|
+
class FindAction
|
10
|
+
# A class representing an emelement that was found as a possible match for an action.
|
11
|
+
class FoundElement
|
12
|
+
ELEMENT_ATTRIBUTES = %w[
|
13
|
+
text
|
14
|
+
value
|
15
|
+
visible?
|
16
|
+
checked?
|
17
|
+
selected?
|
18
|
+
tag_name
|
19
|
+
location
|
20
|
+
id
|
21
|
+
src
|
22
|
+
name
|
23
|
+
href
|
24
|
+
style
|
25
|
+
path
|
26
|
+
outerHTML
|
27
|
+
].freeze
|
28
|
+
|
29
|
+
NATIVE_ATTRIBUTES = %w[
|
30
|
+
size
|
31
|
+
type
|
32
|
+
].freeze
|
33
|
+
|
34
|
+
PREDEFINED_ATTRIBUTES = (NATIVE_ATTRIBUTES + ELEMENT_ATTRIBUTES).freeze
|
35
|
+
|
36
|
+
attr_reader :found_element
|
37
|
+
|
38
|
+
def capybara_session
|
39
|
+
if Object.const_defined?("::Capybara") &&
|
40
|
+
::Capybara.send(:session_pool).present?
|
41
|
+
my_page = ::Capybara.current_session
|
42
|
+
|
43
|
+
my_page if (my_page && my_page.current_url.present? && my_page.current_url != "about:blank")
|
44
|
+
end
|
45
|
+
rescue StandardError
|
46
|
+
nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def ==(comparison_object)
|
50
|
+
comparison_object.equal?(self) ||
|
51
|
+
(comparison_object.instance_of?(self.class) &&
|
52
|
+
(comparison_object.found_element == found_element
|
53
|
+
# ||
|
54
|
+
# (comparison_object.instance_variable_get(:@elem_text) == @elem_text &&
|
55
|
+
# comparison_object.instance_variable_get(:@elem_value) == @elem_value &&
|
56
|
+
# comparison_object.instance_variable_get(:@elem_visible) == @elem_visible &&
|
57
|
+
# comparison_object.instance_variable_get(:@elem_checked) == @elem_checked &&
|
58
|
+
# comparison_object.instance_variable_get(:@elem_selected) == @elem_selected &&
|
59
|
+
# comparison_object.instance_variable_get(:@elem_tag_name) == @elem_tag_name &&
|
60
|
+
# comparison_object.instance_variable_get(:@elem_location) == @elem_location &&
|
61
|
+
# comparison_object.instance_variable_get(:@elem_size) == @elem_size &&
|
62
|
+
# comparison_object.instance_variable_get(:@elem_id) == @elem_id &&
|
63
|
+
# comparison_object.instance_variable_get(:@elem_name) == @elem_name &&
|
64
|
+
# comparison_object.instance_variable_get(:@elem_href) == @elem_href &&
|
65
|
+
# comparison_object.instance_variable_get(:@elem_style) == @elem_style &&
|
66
|
+
# comparison_object.instance_variable_get(:@elem_path) == @elem_path &&
|
67
|
+
# comparison_object.instance_variable_get(:@elem_outerHTML) == @elem_outerHTML &&
|
68
|
+
# comparison_object.instance_variable_get(:@native_class) == @native_class &&
|
69
|
+
# comparison_object.instance_variable_get(:@native_value) == @native_value &&
|
70
|
+
# comparison_object.instance_variable_get(:@native_type) == @native_type
|
71
|
+
# )
|
72
|
+
)
|
73
|
+
) ||
|
74
|
+
comparison_object == found_element
|
75
|
+
end
|
76
|
+
|
77
|
+
def initialize(found_element)
|
78
|
+
@found_element = found_element
|
79
|
+
ELEMENT_ATTRIBUTES.each do |attrib|
|
80
|
+
variable_name = attrib.to_s.gsub("?", "")
|
81
|
+
instance_variable_set("@elem_#{variable_name.gsub(/[\-]/, "_")}", get_attribute(attrib))
|
82
|
+
end
|
83
|
+
|
84
|
+
NATIVE_ATTRIBUTES.each do |attrib|
|
85
|
+
instance_variable_set("@native_#{attrib.gsub(/[\-]/, "_")}", get_native_attribute(attrib))
|
86
|
+
end
|
87
|
+
|
88
|
+
instance_variable_set("@native_class", @found_element[:class])
|
89
|
+
|
90
|
+
session = capybara_session
|
91
|
+
if session.driver.respond_to?(:browser) &&
|
92
|
+
session.driver.browser.respond_to?(:execute_script) &&
|
93
|
+
session.driver.browser.method(:execute_script).arity != 1
|
94
|
+
begin
|
95
|
+
# This is a "trick" that works with Selenium, but which might not work with other drivers...
|
96
|
+
script = "var attrib_list = [];
|
97
|
+
var attrs = arguments[0].attributes;
|
98
|
+
for (var nIndex = 0; nIndex < attrs.length; nIndex += 1)
|
99
|
+
{
|
100
|
+
var a = attrs[nIndex];
|
101
|
+
attrib_list.push(a.name);
|
102
|
+
};
|
103
|
+
return attrib_list;"
|
104
|
+
|
105
|
+
attributes = session.driver.browser.execute_script(script, @found_element.native)
|
106
|
+
attributes.each do |attritue|
|
107
|
+
unless PREDEFINED_ATTRIBUTES.include?(attritue)
|
108
|
+
instance_variable_set("@native_#{attritue.gsub(/[\-]/, "_")}", @found_element[attritue])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
@elem_outerHTML ||= session.driver.browser.execute_script("return arguments[0].outerHTML", @found_element.native)
|
113
|
+
rescue ::Capybara::NotSupportedByDriverError
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# information from Selenium that may not be available depending on the form, the full outerHTML of the element
|
118
|
+
if (session.respond_to?(:evaluate_script))
|
119
|
+
unless (@elem_id.blank?)
|
120
|
+
begin
|
121
|
+
@elem_outerHTML ||= session.evaluate_script("document.getElementById('#{@elem_id}').outerHTML")
|
122
|
+
rescue ::Capybara::NotSupportedByDriverError
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def get_attribute(attribute)
|
129
|
+
if found_element.respond_to?(attribute)
|
130
|
+
begin
|
131
|
+
found_element.send(attribute)
|
132
|
+
rescue ::Capybara::NotSupportedByDriverError
|
133
|
+
rescue ArgumentError
|
134
|
+
end
|
135
|
+
elsif found_element.respond_to?(:[]) && found_element[attribute]
|
136
|
+
found_element[attribute]
|
137
|
+
else
|
138
|
+
get_native_attribute(attribute)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def get_native_attribute(attribute)
|
143
|
+
if found_element.native.respond_to?(attribute)
|
144
|
+
found_element.native.send(attribute)
|
145
|
+
elsif found_element.native.respond_to?(:[])
|
146
|
+
found_element.native[attribute]
|
147
|
+
else
|
148
|
+
nil
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|