cornucopia 0.1.46 → 0.1.47
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cornucopia/capybara/finder_diagnostics.rb +34 -9
- data/lib/cornucopia/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb400b1cefc8f1c4c8c8c36aa3f269b934f692d6
|
4
|
+
data.tar.gz: 4fedbfb5533530aca447da92ebd865ee920161c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e15791520031a874468210ce5c25c476119dd38eac13dce59076b2674fef68947292c91300e74576fa0daa44abc012467e757e8c27702b87c85133ccabbc2d3
|
7
|
+
data.tar.gz: 1df746c8c07b51e05641b3446c31479afc400d1896cc0e63bc0100c948f7a6e351eff2eaf5874255f348096970ac53f9e378038e0136df62d399ad289c8bd291
|
@@ -142,10 +142,21 @@ module Cornucopia
|
|
142
142
|
can_dump
|
143
143
|
end
|
144
144
|
|
145
|
+
def capybara_session
|
146
|
+
if Object.const_defined?("::Capybara") &&
|
147
|
+
::Capybara.send(:session_pool).present?
|
148
|
+
my_page = ::Capybara.current_session
|
149
|
+
|
150
|
+
my_page if (my_page && my_page.current_url.present? && my_page.current_url != "about:blank")
|
151
|
+
end
|
152
|
+
rescue StandardError
|
153
|
+
nil
|
154
|
+
end
|
155
|
+
|
145
156
|
# def dump_detail_args(attempt_retry, attempt_alternate_retry)
|
146
157
|
def dump_detail_args(attempt_retry)
|
147
158
|
check_args = search_args.clone
|
148
|
-
my_page =
|
159
|
+
my_page = capybara_session
|
149
160
|
|
150
161
|
check_args << options.clone
|
151
162
|
check_args << !!attempt_retry
|
@@ -363,7 +374,9 @@ module Cornucopia
|
|
363
374
|
|
364
375
|
def all_other_elements
|
365
376
|
unless @all_other_elements
|
366
|
-
from_element =
|
377
|
+
from_element = capybara_session
|
378
|
+
|
379
|
+
return unless from_element
|
367
380
|
|
368
381
|
begin
|
369
382
|
@all_other_elements = from_element.all(*search_args, visible: false, __cornucopia_no_analysis: true).to_a
|
@@ -464,6 +477,17 @@ module Cornucopia
|
|
464
477
|
|
465
478
|
attr_reader :found_element
|
466
479
|
|
480
|
+
def capybara_session
|
481
|
+
if Object.const_defined?("::Capybara") &&
|
482
|
+
::Capybara.send(:session_pool).present?
|
483
|
+
my_page = ::Capybara.current_session
|
484
|
+
|
485
|
+
my_page if (my_page && my_page.current_url.present? && my_page.current_url != "about:blank")
|
486
|
+
end
|
487
|
+
rescue StandardError
|
488
|
+
nil
|
489
|
+
end
|
490
|
+
|
467
491
|
def ==(comparison_object)
|
468
492
|
comparison_object.equal?(self) ||
|
469
493
|
(comparison_object.instance_of?(self.class) &&
|
@@ -505,9 +529,10 @@ module Cornucopia
|
|
505
529
|
|
506
530
|
instance_variable_set("@native_class", @found_element[:class])
|
507
531
|
|
508
|
-
|
509
|
-
|
510
|
-
|
532
|
+
session = capybara_session
|
533
|
+
if session.driver.respond_to?(:browser) &&
|
534
|
+
session.driver.browser.respond_to?(:execute_script) &&
|
535
|
+
session.driver.browser.method(:execute_script).arity != 1
|
511
536
|
begin
|
512
537
|
# This is a "trick" that works with Selenium, but which might not work with other drivers...
|
513
538
|
script = "var attrib_list = [];
|
@@ -519,23 +544,23 @@ for (var nIndex = 0; nIndex < attrs.length; nIndex += 1)
|
|
519
544
|
};
|
520
545
|
return attrib_list;"
|
521
546
|
|
522
|
-
attributes =
|
547
|
+
attributes = session.driver.browser.execute_script(script, @found_element.native)
|
523
548
|
attributes.each do |attritue|
|
524
549
|
unless PREDEFINED_ATTRIBUTES.include?(attritue)
|
525
550
|
instance_variable_set("@native_#{attritue.gsub(/[\-]/, "_")}", @found_element[attritue])
|
526
551
|
end
|
527
552
|
end
|
528
553
|
|
529
|
-
@elem_outerHTML ||=
|
554
|
+
@elem_outerHTML ||= session.driver.browser.execute_script("return arguments[0].outerHTML", @found_element.native)
|
530
555
|
rescue ::Capybara::NotSupportedByDriverError
|
531
556
|
end
|
532
557
|
end
|
533
558
|
|
534
559
|
# information from Selenium that may not be available depending on the form, the full outerHTML of the element
|
535
|
-
if (
|
560
|
+
if (session.respond_to?(:evaluate_script))
|
536
561
|
unless (@elem_id.blank?)
|
537
562
|
begin
|
538
|
-
@elem_outerHTML ||=
|
563
|
+
@elem_outerHTML ||= session.evaluate_script("document.getElementById('#{@elem_id}').outerHTML")
|
539
564
|
rescue ::Capybara::NotSupportedByDriverError
|
540
565
|
end
|
541
566
|
end
|
data/lib/cornucopia/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cornucopia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.47
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RealNobody
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|