appom 1.2.2 → 1.3.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: 2f484560756312f1f488680c7dac395f8a811c38d01f691fcb3259ea905c4bd6
4
- data.tar.gz: 9e282e64e0afdaf5c38d7e91d5304ee5136543039bc30df66761ff8281079751
3
+ metadata.gz: 75497e842dc00bf929ffd3752fdc74c3dfb34094c8f74b360e51c137e654f93d
4
+ data.tar.gz: bf5f95feb5aaf74bc1ee39f7a9592c9d6f3b63b3a60d5225777f8f5f506ee806
5
5
  SHA512:
6
- metadata.gz: c39d03e79e31c983eda9dca7d4bafcf00994b2f60783f3d1723f108d89e9eb965bbd5d8aa197e394c4a60c0201a325e16ec700487a82ef34441ae401703de734
7
- data.tar.gz: dc9c89c08d924e9e9d932f29598c42c3a852845c62083fd65b582d3007160993c6c163bffcbf1d8ac234db7cabe90537e2c7334a475068df060bc1952aecb80f
6
+ metadata.gz: '09ea6e4f15eaadcad9627066bad3c51f228882a59b36470a1ff4fc5360b525220bf1f7769bebf019b827ac5c1d6632015695a98c63f19581a5059d3d77bc4a0b'
7
+ data.tar.gz: 8b135b65504c6212668ef6d3a6be1f4dd819e44bb11c14a166f4ab229202603ca50e4e4d9d795418b8f6b6c673f0b7be800f7e8304eaa3e2fe99c6b66bdcaa6d
@@ -2,6 +2,5 @@
2
2
 
3
3
  # We will start driver before each scenario
4
4
  Before do
5
- puts "---------Start Appom --------1"
6
5
  Appom.start_driver
7
6
  end
@@ -5,28 +5,27 @@ module Appom
5
5
  args, text, visible = deduce_element_args(find_args)
6
6
  wait = Wait.new(timeout: Appom.max_wait_time)
7
7
 
8
- if visible.nil? && text.nil?
9
- wait.until { page.find_element(*find_args) }
10
- else
11
- wait.until do
12
- elements = page.find_elements(*args)
13
- elements.each do |element|
14
- if !visible.nil? && !text.nil?
15
- if element.displayed? && element.text == text
16
- return element
17
- end
18
- elsif !visible.nil?
19
- if element.displayed?
20
- return element
21
- end
22
- elsif !text.nil?
23
- if element.text == text
24
- return element
25
- end
8
+ wait.until do
9
+ elements = page.find_elements(*args)
10
+ elements.each do |element|
11
+ if !visible.nil? && !text.nil?
12
+ if element.displayed? && element.text == text
13
+ return element
14
+ end
15
+ elsif !visible.nil?
16
+ if element.displayed?
17
+ return element
18
+ end
19
+ elsif !text.nil?
20
+ if element.text == text
21
+ return element
26
22
  end
23
+ # Just return first element
24
+ else
25
+ return element
27
26
  end
28
- raise Appom::ElementsEmptyError, "Not found element with text #{text}"
29
27
  end
28
+ raise Appom::ElementsEmptyError, "Can not found element with args = #{find_args}"
30
29
  end
31
30
  end
32
31
 
@@ -38,8 +37,29 @@ module Appom
38
37
  # Check page has or has not element with find_args
39
38
  # If page has element return TRUE else return FALSE
40
39
  def _check_has_element(*find_args)
41
- elements = page.find_elements(*find_args)
42
- return elements.empty? ? false : true
40
+ elements = page.find_elements(*args)
41
+
42
+ if visible.nil? && text.nil?
43
+ return elements.empty? ? false : true
44
+ else
45
+ is_found = false
46
+ elements.each do |element|
47
+ if !visible.nil? && !text.nil?
48
+ if element.displayed? && element.text == text
49
+ is_found = true
50
+ end
51
+ elsif !visible.nil?
52
+ if element.displayed?
53
+ is_found = true
54
+ end
55
+ elsif !text.nil?
56
+ if element.text == text
57
+ is_found = true
58
+ end
59
+ end
60
+ end
61
+ return is_found
62
+ end
43
63
  end
44
64
 
45
65
  ##
@@ -52,7 +72,7 @@ module Appom
52
72
  result = page.find_elements(*find_args)
53
73
  # If reponse is empty we will return false to make it not pass Wait condition
54
74
  if result.empty?
55
- raise Appom::ElementsEmptyError, "Array is empty"
75
+ raise Appom::ElementsEmptyError, "Can not found any elements with args = #{find_args}"
56
76
  end
57
77
  # Return result
58
78
  return result
@@ -63,113 +83,23 @@ module Appom
63
83
  # Note: Function WILL NOT RETURN ELEMENT
64
84
  def wait_until(type, *find_args)
65
85
  wait = Wait.new(timeout: Appom.max_wait_time)
66
- args, text, visible = deduce_element_args(find_args)
67
-
68
- if visible.nil? && text.nil?
69
- wait.until do
70
- case type
71
- # Function only return true if element enabled or raise an error if time out
72
- when 'element enable'
73
- _find(*args).enabled?
74
-
75
- # Function only return true if element disabled or raise an error if time out
76
- when 'element disable'
77
- !_find(*args).enabled?
78
-
79
- # Function only return true if we can find at leat one element (array is not empty) or raise error
80
- when 'at least one element exists'
81
- !page.find_elements(*args).empty?
82
-
83
- # Function only return true if we can't find at leat one element (array is empty) or raise error
84
- when 'no element exists'
85
- page.find_elements(*args).empty?
86
- end
87
- end
88
- else
89
- wait.until do
90
- case type
91
- # Function only return true if element enabled or raise an error if time out
92
- when 'element enable'
93
- elements = page.find_elements(*args)
94
- elements.each do |element|
95
- if !visible.nil? && !text.nil?
96
- if element.displayed? && element.text == text && element.enabled?
97
- return element
98
- end
99
- elsif !visible.nil?
100
- if element.displayed? && element.enabled?
101
- return element
102
- end
103
- elsif !text.nil?
104
- if element.text == text && element.enabled?
105
- return element
106
- end
107
- end
108
- end
109
- raise Appom::ElementsEmptyError, "Not found element"
110
-
111
- # Function only return true if element disabled or raise an error if time out
112
- when 'element disable'
113
- elements = page.find_elements(*args)
114
- elements.each do |element|
115
- if !visible.nil? && !text.nil?
116
- if element.displayed? && element.text == text && !element.enabled?
117
- return element
118
- end
119
- elsif !visible.nil?
120
- if element.displayed? && !element.enabled?
121
- return element
122
- end
123
- elsif !text.nil?
124
- if element.text == text && !element.enabled?
125
- return element
126
- end
127
- end
128
- end
129
- raise Appom::ElementsEmptyError, "Not found element"
130
-
131
- # Function only return true if we can find at leat one element (array is not empty) or raise error
132
- when 'at least one element exists'
133
- elements = page.find_elements(*args)
134
- elements.each do |element|
135
- if !visible.nil? && !text.nil?
136
- if element.displayed? && element.text == text
137
- return element
138
- end
139
- elsif !visible.nil?
140
- if element.displayed?
141
- return element
142
- end
143
- elsif !text.nil?
144
- if element.text == text
145
- return element
146
- end
147
- end
148
- end
149
- raise Appom::ElementsEmptyError, "Not found element"
150
-
151
- # Function only return true if we can't find at leat one element (array is empty) or raise error
152
- when 'no element exists'
153
- elements = page.find_elements(*args)
154
- elements.each do |element|
155
- if !visible.nil? && !text.nil?
156
- if element.displayed? && element.text == text
157
- raise Appom::ElementsEmptyError, "Not found element"
158
- end
159
- elsif !visible.nil?
160
- if element.displayed?
161
- raise Appom::ElementsEmptyError, "Not found element"
162
- end
163
- elsif !text.nil?
164
- if element.text == text
165
- raise Appom::ElementsEmptyError, "Not found element"
166
- end
167
- end
168
- end
169
- return true
170
- end
86
+ wait.until do
87
+ case type
88
+ # Function only return true if element enabled or raise an error if time out
89
+ when 'element enable'
90
+ _find(*find_args).enabled?
91
+ # Function only return true if element disabled or raise an error if time out
92
+ when 'element disable'
93
+ !_find(*find_args).enabled?
94
+ # Function only return true if we can find at leat one element (array is not empty) or raise error
95
+ when 'at least one element exists'
96
+ args, text, visible = deduce_element_args(find_args)
97
+ !page.find_elements(*args).empty?
98
+ # Function only return true if we can't find at leat one element (array is empty) or raise error
99
+ when 'no element exists'
100
+ args, text, visible = deduce_element_args(find_args)
101
+ page.find_elements(*args).empty?
171
102
  end
172
-
173
103
  end
174
104
  end
175
105
 
data/lib/appom/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Appom
2
- VERSION = '1.2.2'.freeze
2
+ VERSION = '1.3.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.2.2
4
+ version: 1.3.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: 2021-03-15 00:00:00.000000000 Z
11
+ date: 2021-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appium_lib
@@ -82,14 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 2.6.3
85
+ version: 2.2.3
86
86
  required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubygems_version: 3.0.8
92
+ rubygems_version: 3.2.19
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: A Page Object Model for Appium