appom 1.2.2 → 1.3.3
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 +4 -4
- data/lib/appom/cucumber.rb +0 -1
- data/lib/appom/element_finder.rb +79 -129
- data/lib/appom/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b7303f11e73610c1a3303bfe2ba1d502ffece2ad2b26e18cbc47889318d25a8
|
4
|
+
data.tar.gz: 3ab20f9d02933108b3d7556bae7c0409ce527d0cb8baf9ce7d007204e23e9b13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9d8e7c83ec95a20297b2f5c2d884ff630fdace446996b5eadbc25a00352828156262ca275745789a78aea6ef9194550e6b46c49c0a989efcdc20b2cec6b7dae
|
7
|
+
data.tar.gz: 0fb77d98ae662ccf901f8e3ab2121137b441c7c34c63bd8242ffda9eef3804cdcf84daa3df518d01ea2a8f4fb508fb0164a7c6d9783ae9095c801c28ea15fd68
|
data/lib/appom/cucumber.rb
CHANGED
data/lib/appom/element_finder.rb
CHANGED
@@ -5,41 +5,83 @@ 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
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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
|
26
18
|
end
|
19
|
+
elsif !text.nil?
|
20
|
+
if element.text == text
|
21
|
+
return element
|
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
|
|
33
32
|
# Find elements
|
34
33
|
def _all(*find_args)
|
35
|
-
|
34
|
+
args, text, visible = deduce_element_args(find_args)
|
35
|
+
elements = page.find_elements(*args)
|
36
|
+
els = []
|
37
|
+
|
38
|
+
elements.each do |element|
|
39
|
+
if !visible.nil? && !text.nil?
|
40
|
+
if element.displayed? && element.text == text
|
41
|
+
els.push(element)
|
42
|
+
end
|
43
|
+
elsif !visible.nil?
|
44
|
+
if element.displayed?
|
45
|
+
els.push(element)
|
46
|
+
end
|
47
|
+
elsif !text.nil?
|
48
|
+
if element.text == text
|
49
|
+
els.push(element)
|
50
|
+
end
|
51
|
+
else
|
52
|
+
els.push(element)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
return els
|
36
56
|
end
|
37
57
|
|
38
58
|
# Check page has or has not element with find_args
|
39
59
|
# If page has element return TRUE else return FALSE
|
40
60
|
def _check_has_element(*find_args)
|
41
|
-
|
42
|
-
|
61
|
+
args, text, visible = deduce_element_args(find_args)
|
62
|
+
elements = page.find_elements(*args)
|
63
|
+
|
64
|
+
if visible.nil? && text.nil?
|
65
|
+
return elements.empty? ? false : true
|
66
|
+
else
|
67
|
+
is_found = false
|
68
|
+
elements.each do |element|
|
69
|
+
if !visible.nil? && !text.nil?
|
70
|
+
if element.displayed? && element.text == text
|
71
|
+
is_found = true
|
72
|
+
end
|
73
|
+
elsif !visible.nil?
|
74
|
+
if element.displayed?
|
75
|
+
is_found = true
|
76
|
+
end
|
77
|
+
elsif !text.nil?
|
78
|
+
if element.text == text
|
79
|
+
is_found = true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
return is_found
|
84
|
+
end
|
43
85
|
end
|
44
86
|
|
45
87
|
##
|
@@ -52,7 +94,7 @@ module Appom
|
|
52
94
|
result = page.find_elements(*find_args)
|
53
95
|
# If reponse is empty we will return false to make it not pass Wait condition
|
54
96
|
if result.empty?
|
55
|
-
raise Appom::ElementsEmptyError, "
|
97
|
+
raise Appom::ElementsEmptyError, "Can not found any elements with args = #{find_args}"
|
56
98
|
end
|
57
99
|
# Return result
|
58
100
|
return result
|
@@ -63,113 +105,21 @@ module Appom
|
|
63
105
|
# Note: Function WILL NOT RETURN ELEMENT
|
64
106
|
def wait_until(type, *find_args)
|
65
107
|
wait = Wait.new(timeout: Appom.max_wait_time)
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
108
|
+
wait.until do
|
109
|
+
case type
|
110
|
+
# Function only return true if element enabled or raise an error if time out
|
111
|
+
when 'element enable'
|
112
|
+
_find(*find_args).enabled?
|
113
|
+
# Function only return true if element disabled or raise an error if time out
|
114
|
+
when 'element disable'
|
115
|
+
!_find(*find_args).enabled?
|
116
|
+
# Function only return true if we can find at leat one element (array is not empty) or raise error
|
117
|
+
when 'at least one element exists'
|
118
|
+
!_all(*find_args).empty?
|
119
|
+
# Function only return true if we can't find at leat one element (array is empty) or raise error
|
120
|
+
when 'no element exists'
|
121
|
+
_all(*find_args).empty?
|
171
122
|
end
|
172
|
-
|
173
123
|
end
|
174
124
|
end
|
175
125
|
|
data/lib/appom/version.rb
CHANGED
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.
|
4
|
+
version: 1.3.3
|
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-
|
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.
|
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.
|
92
|
+
rubygems_version: 3.2.19
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: A Page Object Model for Appium
|