appom 1.3.0 → 1.4.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 +4 -4
- data/lib/appom.rb +0 -11
- data/lib/appom/element_finder.rb +48 -11
- data/lib/appom/version.rb +1 -1
- data/lib/appom/wait.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9a6de43f053bda132bbb8858033c9321366faf11ecc1a2f00f4182cb84c49ee
|
4
|
+
data.tar.gz: ebd235ad562a8277b0bf5b6875da253e5f6f5ba804265f102115c0bf55b9c304
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a82fc453c96e887cecca965b5a470aef664ef10cb005d89b50d29dda56be3bd30a1c8b133473086c4bdd71a46834c5324aa6846fa1b010f2509d622f71b7e320
|
7
|
+
data.tar.gz: 5c20db78987ad7edf20eeccf52c5361ff0ba23cd9f57d038cab7e70161304887503a85de391a0fefd1b6e2dc9a1cac01ec5c470526d01dcf2984c6c4dce1511e
|
data/lib/appom.rb
CHANGED
@@ -9,17 +9,6 @@ module Appom
|
|
9
9
|
class InvalidElementError < StandardError; end
|
10
10
|
# A block was passed to the method, which it cannot interpreter.
|
11
11
|
class UnsupportedBlockError < StandardError; end
|
12
|
-
# The condition that was being evaluated inside the block did not evaluate
|
13
|
-
# to true within the time limit.
|
14
|
-
class TimeoutError < StandardError; end
|
15
|
-
# An element could not be located on the page using the given search parameters.
|
16
|
-
class NoSuchElementError < StandardError; end
|
17
|
-
# An elements is empty using the given search parameters.
|
18
|
-
class ElementsEmptyError < StandardError; end
|
19
|
-
# Text from an element not equal expected text
|
20
|
-
class ElementsTextVerifyError < StandardError; end
|
21
|
-
# An element is define with no text value
|
22
|
-
class ElementsDefineNoTextError < StandardError; end
|
23
12
|
|
24
13
|
autoload :ElementContainer, 'appom/element_container'
|
25
14
|
autoload :Page, 'appom/page'
|
data/lib/appom/element_finder.rb
CHANGED
@@ -25,18 +25,40 @@ module Appom
|
|
25
25
|
return element
|
26
26
|
end
|
27
27
|
end
|
28
|
-
raise
|
28
|
+
raise StandardError, "Can not found element with args = #{find_args}"
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
# Find elements
|
33
33
|
def _all(*find_args)
|
34
|
-
|
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
|
35
56
|
end
|
36
57
|
|
37
58
|
# Check page has or has not element with find_args
|
38
59
|
# If page has element return TRUE else return FALSE
|
39
60
|
def _check_has_element(*find_args)
|
61
|
+
args, text, visible = deduce_element_args(find_args)
|
40
62
|
elements = page.find_elements(*args)
|
41
63
|
|
42
64
|
if visible.nil? && text.nil?
|
@@ -70,9 +92,9 @@ module Appom
|
|
70
92
|
wait = Wait.new(timeout: Appom.max_wait_time)
|
71
93
|
wait.until do
|
72
94
|
result = page.find_elements(*find_args)
|
73
|
-
# If
|
95
|
+
# If response is empty we will return false to make it not pass Wait condition
|
74
96
|
if result.empty?
|
75
|
-
raise
|
97
|
+
raise StandardError, "Can not found any elements with args = #{find_args}"
|
76
98
|
end
|
77
99
|
# Return result
|
78
100
|
return result
|
@@ -90,15 +112,30 @@ module Appom
|
|
90
112
|
_find(*find_args).enabled?
|
91
113
|
# Function only return true if element disabled or raise an error if time out
|
92
114
|
when 'element disable'
|
93
|
-
|
94
|
-
|
115
|
+
result = _find(*find_args)
|
116
|
+
if result.enabled?
|
117
|
+
raise StandardError, "Still found an element enable with args = #{find_args}"
|
118
|
+
end
|
119
|
+
return true
|
120
|
+
# Function only return true if we can find at least one element (array is not empty) or raise error
|
95
121
|
when 'at least one element exists'
|
96
|
-
|
97
|
-
|
98
|
-
|
122
|
+
result = _all(*find_args)
|
123
|
+
if result.empty?
|
124
|
+
raise StandardError, "Could not find any elements with args = #{find_args}"
|
125
|
+
end
|
126
|
+
return true
|
127
|
+
|
128
|
+
# Function only return true if we can't find at least one element (array is empty) or raise error
|
99
129
|
when 'no element exists'
|
100
|
-
|
101
|
-
|
130
|
+
result = _all(*find_args)
|
131
|
+
if !result.empty?
|
132
|
+
if result.size > 1
|
133
|
+
raise StandardError, "Still found #{result.size} elements with args = #{find_args}"
|
134
|
+
else
|
135
|
+
raise StandardError, "Still found #{result.size} element with args = #{find_args}"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
return true
|
102
139
|
end
|
103
140
|
end
|
104
141
|
end
|
data/lib/appom/version.rb
CHANGED
data/lib/appom/wait.rb
CHANGED
@@ -23,18 +23,20 @@ module Appom
|
|
23
23
|
#
|
24
24
|
def until
|
25
25
|
end_time = Time.now + @timeout
|
26
|
+
error_message = ""
|
26
27
|
|
27
28
|
until Time.now > end_time
|
28
29
|
begin
|
29
30
|
result = yield
|
30
31
|
return result if result
|
31
|
-
rescue
|
32
|
+
rescue => error
|
33
|
+
error_message = error.message
|
32
34
|
end
|
33
35
|
|
34
36
|
sleep @interval
|
35
37
|
end
|
36
38
|
|
37
|
-
raise
|
39
|
+
raise StandardError, error_message
|
38
40
|
end
|
39
41
|
end
|
40
42
|
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.
|
4
|
+
version: 1.4.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-08-
|
11
|
+
date: 2021-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: appium_lib
|