appom 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cafb8a939a6ef3b7bc2c06438923c6eb67633b5231553633bff5aad3af94ab67
4
- data.tar.gz: 5f5a702a61a8550d0826183e36e7bd42d62de9b8aea8957886ed3487bb1eea11
3
+ metadata.gz: e2853e5118fd75268ff6297448f91e01994b2f4a06a22e00cd92963dc08215b0
4
+ data.tar.gz: d911296d61b4568e3e9f73453bd931aba4647a86e81b4fc3bf20c92c7c26ae0b
5
5
  SHA512:
6
- metadata.gz: d38ab6b6237cf7a7620ab177d3081c39de1b8deae54e82ecf4a93fc66f40dc16aab951af3d5f18a65bf15a4ad66d2604978feca49a56baf3b1edb3e775737cd9
7
- data.tar.gz: 042205757568fee70037fafcb32a424f6847dc446cf67645351c3139483bb30d854f5f44951073c97f1354c9f3dc5d6d798550ad584fd1ef4c93dfddf1595a47
6
+ metadata.gz: a822cac2b1155cd1aa21eeb6263f361e669f0c90911ffd444b041d37ed2fb6ec03a054d5d2bd87a2a21f6f097ebb80dfd98c661aac5c1a44fa135e0ba9e2d597
7
+ data.tar.gz: 3cfaea41cb2cdb4ec8c337f53d8342d0153c2e8483412d0c43cfdbbd0a74f4b1f1a18afc9ba64030885f72ad228c7c183a5ac32ec7c783fe0221587e574b1c22
@@ -14,6 +14,38 @@ module Appom
14
14
  raise Appom::UnsupportedBlockError
15
15
  end
16
16
 
17
+ # # Check container has element
18
+ # def not_contain_element(element_name)
19
+ # element_params = send("#{element_name}_params")
20
+ # wait_until('no element exists', *element_params)
21
+ # end
22
+ #
23
+ # # Check container has elements
24
+ # def contain_elements(element_names)
25
+ # element_names.each do |element|
26
+ # contain_element(element)
27
+ # end
28
+ # end
29
+ #
30
+ # Check container has element
31
+ # def contain_element(element_name)
32
+ # element_params = send("#{element_name}_params")
33
+ # puts "Elemenet params = #{element_params}"
34
+ # wait_until('at least one element exists', *element_params)
35
+ # end
36
+ #
37
+ # # Check container has element and element is disabled
38
+ # def contain_disabled_element(element_name)
39
+ # element_params = send("#{element_name}_params")
40
+ # wait_until('element disable', *element_params)
41
+ # end
42
+ #
43
+ # # Check container has element and element is enabled
44
+ # def contain_enableb_element(element_name)
45
+ # element_params = send("#{element_name}_params")
46
+ # wait_until('element enable', *element_params)
47
+ # end
48
+
17
49
  ##
18
50
  # Options re-combiner. This takes the original inputs and combines
19
51
  # them such that there is only one hash passed as a final argument
@@ -46,11 +78,16 @@ module Appom
46
78
  build_element(name, *args) do
47
79
  define_method(name) do |*runtime_args, &block|
48
80
  raise_if_block(self, name, !block.nil?, :element)
49
- _find(*merge_args(args, runtime_args))
81
+ if text.nil?
82
+ _find(*merge_args(args, runtime_args))
83
+ else
84
+ find_element_has_text(text, *merge_args(args, runtime_args))
85
+ end
50
86
  end
51
87
 
52
- create_get_element_params(name, args)
53
88
  create_verify_element_text(name, text, args)
89
+
90
+ create_get_element_params(name, find_args)
54
91
  end
55
92
  end
56
93
 
@@ -87,8 +124,6 @@ module Appom
87
124
 
88
125
  create_get_element_params(name, find_args)
89
126
  end
90
-
91
-
92
127
  end
93
128
 
94
129
  def sections(name, *args, &block)
@@ -190,21 +225,6 @@ module Appom
190
225
  end
191
226
  end
192
227
 
193
- ##
194
- # Check element non-existent
195
- # We will try to find all elements with *find_args
196
- # Condition is pass when response is empty
197
- #
198
- def create_nonexistence_checker(element_name, *find_args)
199
- method_name = "wait_until_has_no_#{element_name}"
200
- create_helper_method(method_name, *find_args) do
201
- define_method(method_name) do |*runtime_args|
202
- args = merge_args(find_args, runtime_args)
203
- wait_check_until_empty(*args)
204
- end
205
- end
206
- end
207
-
208
228
  ##
209
229
  # Try to get all elements until not get empty array
210
230
  #
@@ -233,28 +253,44 @@ module Appom
233
253
  end
234
254
  end
235
255
 
256
+
236
257
  ##
237
- # Try wait until element will be enable
258
+ # Check element non-existent
259
+ # We will try to find all elements with *find_args
260
+ # Condition is pass when response is empty
261
+ #
262
+ def create_nonexistence_checker(element_name, *find_args)
263
+ method_name = "wait_until_has_no_#{element_name}"
264
+ create_helper_method(method_name, *find_args) do
265
+ define_method(method_name) do |*runtime_args|
266
+ args = merge_args(find_args, runtime_args)
267
+ wait_check_until_empty(*args)
268
+ end
269
+ end
270
+ end
271
+
272
+ ##
273
+ # Wait until element will be enable
238
274
  #
239
275
  def create_enable_checker(element_name, *find_args)
240
276
  method_name = "wait_until_#{element_name}_enable"
241
277
  create_helper_method(method_name, *find_args) do
242
278
  define_method(method_name) do |*runtime_args|
243
279
  args = merge_args(find_args, runtime_args)
244
- wait_until_element_enabled(*args)
280
+ wait_until('element enabled', *args)
245
281
  end
246
282
  end
247
283
  end
248
284
 
249
285
  ##
250
- # Wait until an element will be
286
+ # Wait until an element will be disable
251
287
  #
252
288
  def create_disable_checker(element_name, *find_args)
253
289
  method_name = "wait_until_#{element_name}_disable"
254
290
  create_helper_method(method_name, *find_args) do
255
291
  define_method(method_name) do |*runtime_args|
256
292
  args = merge_args(find_args, runtime_args)
257
- wait_until_element_disabled(*args)
293
+ wait_until('element disabled', *args)
258
294
  end
259
295
  end
260
296
  end
@@ -360,7 +396,6 @@ module Appom
360
396
  def extract_search_arguments(args)
361
397
  args if args && !args.empty?
362
398
  end
363
-
364
399
  end
365
400
  end
366
401
  end
@@ -33,9 +33,32 @@ module Appom
33
33
  end
34
34
  end
35
35
 
36
+
37
+
38
+ ##
39
+ # Wait until an element will be enable
40
+ #
41
+ def wait_until_element_enabled(*find_args)
42
+ wait = Wait.new(timeout: Appom.max_wait_time)
43
+ wait.until { page.find_element(*find_args).enabled? }
44
+ end
45
+
46
+ ##
47
+ # Wait until an element will be disable
48
+ #
49
+ def wait_until_element_disabled(*find_args)
50
+ wait = Wait.new(timeout: Appom.max_wait_time)
51
+ wait.until do !page.
52
+ find_element(*find_args).enabled?
53
+ end
54
+ end
55
+
56
+
57
+
58
+
36
59
  ##
37
60
  # Use wait to get elements
38
- # Before timeout we will try to find elements until response is not empty
61
+ # Before timeout we will try to find elements until response return array is not empty
39
62
  #
40
63
  def wait_until_get_not_empty(*find_args)
41
64
  wait = Wait.new(timeout: Appom.max_wait_time)
@@ -50,20 +73,47 @@ module Appom
50
73
  end
51
74
  end
52
75
 
53
- ##
54
- # Wait until an element will be enable
55
- #
56
- def wait_until_element_enabled(*find_args)
76
+ # Find element with has text match with `text` value
77
+ # If not find element will raise error
78
+ def find_element_has_text(text, *find_args)
57
79
  wait = Wait.new(timeout: Appom.max_wait_time)
58
- wait.until { page.find_element(*find_args).enabled? }
80
+ wait.until do
81
+ elements = page.find_elements(*find_args)
82
+ is_found = false
83
+ elements.each do |element|
84
+ element_text = element.text
85
+ if element_text == text
86
+ return element
87
+ end
88
+ end
89
+
90
+ if !is_found
91
+ raise Appom::ElementsEmptyError, "Not found element with text #{text}"
92
+ end
93
+ return result
94
+ end
59
95
  end
60
96
 
61
- ##
62
- # Wait until an element will be disable
63
- #
64
- def wait_until_element_disabled(*find_args)
97
+ # Function is used to check
98
+ # Note: Function WILL NOT RETURN ELEMENT
99
+ def wait_until(type, *find_args)
65
100
  wait = Wait.new(timeout: Appom.max_wait_time)
66
- wait.until { !page.find_element(*find_args).enabled? }
101
+ wait.until do
102
+ case type
103
+ # Function only return true if element enabled or raise an error if time out
104
+ when 'element enable'
105
+ page.find_element(*find_args).enabled?
106
+ # Function only return true if element disabled or raise an error if time out
107
+ when 'element disable'
108
+ !page.find_element(*find_args).enabled?
109
+ # Function only return true if we can find at leat one element (array is not empty) or raise error
110
+ when 'at least one element exists'
111
+ !page.find_elements(*find_args).empty?
112
+ # Function only return true if we can't find at leat one element (array is empty) or raise error
113
+ when 'no element exists'
114
+ page.find_elements(*find_args).empty?
115
+ end
116
+ end
67
117
  end
68
118
  end
69
119
  end
@@ -1,3 +1,3 @@
1
1
  module Appom
2
- VERSION = '1.0.3'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appom
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry.Tran
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-11-19 00:00:00.000000000 Z
11
+ date: 2019-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appium_lib
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  version: '0'
91
91
  requirements: []
92
92
  rubyforge_project:
93
- rubygems_version: 2.7.7
93
+ rubygems_version: 2.7.9
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: A Page Object Model for Appium