watigiri 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/watigiri/locators/element/locator.rb +45 -18
- data/watigiri.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b72b888e42e3c48e712af1d1b52d8d33abd9f78
|
4
|
+
data.tar.gz: 392b4c4e20b03cf400b2df0eeec7d1600f6766a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 853cca62feb297f9ccef578e63dfba6ce0dcd1a088b462ca1335889a5914388d8af490326d7e452ba194fd50a43df8dbe656ab5a0d2dcd3c0b9574b46c58c3c5
|
7
|
+
data.tar.gz: 8be0f3f162b0845ac0e7c8f652f8a100aa43f48e8d365a2dcaa8245dede92507d6a1fdcc450b1107d8e9a750dba9fce9f48e061e5171cdd05c757234d249a5af
|
@@ -18,17 +18,23 @@ module Watigiri
|
|
18
18
|
@nokogiri = @selector.delete(:nokogiri)
|
19
19
|
return super unless @nokogiri || regex?
|
20
20
|
|
21
|
-
|
22
|
-
# https://github.com/sparklemotion/nokogiri/issues/572
|
23
|
-
method = @query_scope.is_a?(Watir::Browser) ? :html : :inner_html
|
24
|
-
|
25
|
-
@query_scope.doc ||= Nokogiri::HTML(@query_scope.send(method)).tap { |d| d.css('script').remove }
|
21
|
+
set_nokogiri
|
26
22
|
|
27
23
|
element = using_watir(:first)
|
28
24
|
return if element.nil?
|
29
25
|
@nokogiri ? element.element : nokogiri_to_selenium(element)
|
30
26
|
end
|
31
27
|
|
28
|
+
def locate_all
|
29
|
+
@nokogiri = @selector.delete(:nokogiri)
|
30
|
+
return super unless @nokogiri || regex?
|
31
|
+
|
32
|
+
set_nokogiri
|
33
|
+
|
34
|
+
elements = using_watir(:all)
|
35
|
+
@nokogiri ? elements.map(&:element) : elements.map { |el| nokogiri_to_selenium(el) }
|
36
|
+
end
|
37
|
+
|
32
38
|
# Is only used when there is no regex, index or visibility locators
|
33
39
|
def locate_element(how, what, _driver_scope = @query_scope.wd)
|
34
40
|
return super unless @nokogiri
|
@@ -47,18 +53,16 @@ module Watigiri
|
|
47
53
|
end
|
48
54
|
|
49
55
|
def fetch_value(element, how)
|
50
|
-
|
51
|
-
return if
|
56
|
+
noko_element = noko_element(element)
|
57
|
+
return super if noko_element.nil?
|
52
58
|
|
53
59
|
case how
|
54
60
|
when :text
|
55
|
-
|
61
|
+
noko_element.inner_text
|
56
62
|
when :tag_name
|
57
|
-
|
58
|
-
when :href
|
59
|
-
element.attribute('href')&.to_s
|
63
|
+
noko_element.name.downcase
|
60
64
|
else
|
61
|
-
|
65
|
+
noko_element.attribute(how.to_s.tr('_', '-')).to_s.strip
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
@@ -71,11 +75,12 @@ module Watigiri
|
|
71
75
|
|
72
76
|
def regex?
|
73
77
|
return @regex unless @regex.nil?
|
74
|
-
|
78
|
+
|
79
|
+
return false unless (@selector.keys & %i[adjacent visible label text visible_text visible_label]).empty?
|
75
80
|
@regex = @selector.values.any? { |v| v.is_a?(Regexp) }
|
76
81
|
end
|
77
82
|
|
78
|
-
def
|
83
|
+
def noko_element(element)
|
79
84
|
if !(@nokogiri || regex?) || element.is_a?(Selenium::WebDriver::Element)
|
80
85
|
nil
|
81
86
|
elsif element.is_a?(Watigiri::Element)
|
@@ -84,6 +89,24 @@ module Watigiri
|
|
84
89
|
element
|
85
90
|
end
|
86
91
|
end
|
92
|
+
|
93
|
+
def set_nokogiri
|
94
|
+
return if @query_scope.doc
|
95
|
+
|
96
|
+
# should be using `#fragment` instead of `#inner_html`, but can't because of
|
97
|
+
# https://github.com/sparklemotion/nokogiri/issues/572
|
98
|
+
doc = if @query_scope.is_a?(Watir::Browser)
|
99
|
+
Nokogiri::HTML(@query_scope.html)
|
100
|
+
else
|
101
|
+
Nokogiri::HTML(@query_scope.inner_html)
|
102
|
+
end
|
103
|
+
|
104
|
+
@query_scope.doc = doc.tap { |d| d.css('script').remove }
|
105
|
+
end
|
106
|
+
|
107
|
+
def text_regexp_deprecation(*)
|
108
|
+
# Nokogiri can not determine visible text so no need to check
|
109
|
+
end
|
87
110
|
end
|
88
111
|
|
89
112
|
class Element
|
@@ -125,8 +148,10 @@ module Watigiri
|
|
125
148
|
include LocatorHelpers
|
126
149
|
|
127
150
|
def regex?
|
128
|
-
return
|
129
|
-
|
151
|
+
return @regex unless @regex.nil?
|
152
|
+
|
153
|
+
return false unless (@selector.keys & %i[adjacent visible label text visible_text visible_label]).empty?
|
154
|
+
@regex = @selector.any? { |k, v| v.is_a?(Regexp) && k != :value }
|
130
155
|
end
|
131
156
|
end
|
132
157
|
end
|
@@ -154,8 +179,10 @@ module Watigiri
|
|
154
179
|
end
|
155
180
|
|
156
181
|
def regex?
|
157
|
-
return
|
158
|
-
|
182
|
+
return @regex unless @regex.nil?
|
183
|
+
|
184
|
+
return false unless (@selector.keys & %i[adjacent visible label text visible_text visible_label]).empty?
|
185
|
+
@regex = @selector.any? { |k, v| v.is_a?(Regexp) && k != :value }
|
159
186
|
end
|
160
187
|
end
|
161
188
|
end
|
data/watigiri.gemspec
CHANGED