appom 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/appom.rb +2 -0
- data/lib/appom/element_container.rb +32 -9
- data/lib/appom/element_finder.rb +1 -1
- data/lib/appom/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37ebc727ef6c2feb2f7d4098ad6fed4a6921de7715686bb9c70c155b5c85b710
|
4
|
+
data.tar.gz: 6110ce4011fefa4f4615d8b160b7dc654da546d2874b90d1dfaf61150a686dc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f78893b02b096e667223f2ad3d55da4844ebedcaacccb37c4b96126b4b1087449ab8201fc2ccf69722c1df8e4b04548be90384e4292a1a6fd6d685a358697a8
|
7
|
+
data.tar.gz: eb5e5b89e891e58743ea002a637ce0eef046a22d7476c994831c9b1c104688b917d6be25a714b04344a5fe0dc8292cb0f29a96fb9594e030ca93e2ecedfe9b05
|
data/lib/appom.rb
CHANGED
@@ -14,6 +14,8 @@ module Appom
|
|
14
14
|
class TimeoutError < StandardError; end
|
15
15
|
# An element could not be located on the page using the given search parameters.
|
16
16
|
class NoSuchElementError < StandardError; end
|
17
|
+
# An elements is empty using the given search parameters.
|
18
|
+
class ElementsEmptyError < StandardError; end
|
17
19
|
|
18
20
|
autoload :ElementContainer, 'appom/element_container'
|
19
21
|
autoload :Page, 'appom/page'
|
@@ -92,7 +92,7 @@ module Appom
|
|
92
92
|
|
93
93
|
def sections(name, *args, &block)
|
94
94
|
section_class, find_args = extract_section_options(args, &block)
|
95
|
-
|
95
|
+
build_sections(section_class, name, *find_args) do
|
96
96
|
define_method(name) do |*runtime_args, &block|
|
97
97
|
raise_if_block(self, name, !block.nil?, :sections)
|
98
98
|
_all(*merge_args(find_args, runtime_args)).map do |element|
|
@@ -117,7 +117,7 @@ module Appom
|
|
117
117
|
|
118
118
|
private
|
119
119
|
|
120
|
-
# Add item to @mapped_items or define method for element
|
120
|
+
# Add item to @mapped_items or define method for element and section
|
121
121
|
def build_element(name, *find_args)
|
122
122
|
if find_args.empty?
|
123
123
|
create_error_method(name)
|
@@ -146,6 +146,20 @@ module Appom
|
|
146
146
|
create_get_all_elements(name, *find_args)
|
147
147
|
end
|
148
148
|
|
149
|
+
# Add item to @mapped_items or define method for elements
|
150
|
+
def build_sections(section_class, name, *find_args)
|
151
|
+
if find_args.empty?
|
152
|
+
create_error_method(name)
|
153
|
+
else
|
154
|
+
add_to_mapped_items(name)
|
155
|
+
yield
|
156
|
+
end
|
157
|
+
|
158
|
+
create_existence_checker(name, *find_args)
|
159
|
+
create_nonexistence_checker(name, *find_args)
|
160
|
+
create_get_all_sections(section_class, name, *find_args)
|
161
|
+
end
|
162
|
+
|
149
163
|
# Define method to notify that we can't find item without args
|
150
164
|
def create_error_method(name)
|
151
165
|
define_method(name) do
|
@@ -153,12 +167,6 @@ module Appom
|
|
153
167
|
end
|
154
168
|
end
|
155
169
|
|
156
|
-
def add_helper_methods(name, *find_args)
|
157
|
-
create_existence_checker(name, *find_args)
|
158
|
-
create_nonexistence_checker(name, *find_args)
|
159
|
-
create_get_all_elements(name, *find_args)
|
160
|
-
end
|
161
|
-
|
162
170
|
def create_helper_method(proposed_method_name, *find_args)
|
163
171
|
if find_args.empty?
|
164
172
|
create_error_method(proposed_method_name)
|
@@ -205,7 +213,22 @@ module Appom
|
|
205
213
|
create_helper_method(method_name, *find_args) do
|
206
214
|
define_method(method_name) do |*runtime_args|
|
207
215
|
args = merge_args(find_args, runtime_args)
|
208
|
-
|
216
|
+
wait_util_get_not_empty(*args)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
##
|
222
|
+
# Try to get all sections until not get empty array
|
223
|
+
#
|
224
|
+
def create_get_all_sections(section_class, element_name, *find_args)
|
225
|
+
method_name = "get_all_#{element_name}"
|
226
|
+
create_helper_method(method_name, *find_args) do
|
227
|
+
define_method(method_name) do |*runtime_args|
|
228
|
+
args = merge_args(find_args, runtime_args)
|
229
|
+
wait_util_get_not_empty(*args).map do |element|
|
230
|
+
section_class.new(self, element)
|
231
|
+
end
|
209
232
|
end
|
210
233
|
end
|
211
234
|
end
|
data/lib/appom/element_finder.rb
CHANGED
@@ -43,7 +43,7 @@ module Appom
|
|
43
43
|
result = page.find_elements(*find_args)
|
44
44
|
# If reponse is empty we will return false to make it not pass Wait condition
|
45
45
|
if result.empty?
|
46
|
-
|
46
|
+
raise Appom::ElementsEmptyError, "Array is empty"
|
47
47
|
end
|
48
48
|
# Return result
|
49
49
|
return result
|
data/lib/appom/version.rb
CHANGED