appom 1.3.3 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b7303f11e73610c1a3303bfe2ba1d502ffece2ad2b26e18cbc47889318d25a8
4
- data.tar.gz: 3ab20f9d02933108b3d7556bae7c0409ce527d0cb8baf9ce7d007204e23e9b13
3
+ metadata.gz: e9a6de43f053bda132bbb8858033c9321366faf11ecc1a2f00f4182cb84c49ee
4
+ data.tar.gz: ebd235ad562a8277b0bf5b6875da253e5f6f5ba804265f102115c0bf55b9c304
5
5
  SHA512:
6
- metadata.gz: f9d8e7c83ec95a20297b2f5c2d884ff630fdace446996b5eadbc25a00352828156262ca275745789a78aea6ef9194550e6b46c49c0a989efcdc20b2cec6b7dae
7
- data.tar.gz: 0fb77d98ae662ccf901f8e3ab2121137b441c7c34c63bd8242ffda9eef3804cdcf84daa3df518d01ea2a8f4fb508fb0164a7c6d9783ae9095c801c28ea15fd68
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'
@@ -25,7 +25,7 @@ module Appom
25
25
  return element
26
26
  end
27
27
  end
28
- raise Appom::ElementsEmptyError, "Can not found element with args = #{find_args}"
28
+ raise StandardError, "Can not found element with args = #{find_args}"
29
29
  end
30
30
  end
31
31
 
@@ -92,9 +92,9 @@ module Appom
92
92
  wait = Wait.new(timeout: Appom.max_wait_time)
93
93
  wait.until do
94
94
  result = page.find_elements(*find_args)
95
- # If reponse is empty we will return false to make it not pass Wait condition
95
+ # If response is empty we will return false to make it not pass Wait condition
96
96
  if result.empty?
97
- raise Appom::ElementsEmptyError, "Can not found any elements with args = #{find_args}"
97
+ raise StandardError, "Can not found any elements with args = #{find_args}"
98
98
  end
99
99
  # Return result
100
100
  return result
@@ -112,13 +112,30 @@ module Appom
112
112
  _find(*find_args).enabled?
113
113
  # Function only return true if element disabled or raise an error if time out
114
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
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
117
121
  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
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
120
129
  when 'no element exists'
121
- _all(*find_args).empty?
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
122
139
  end
123
140
  end
124
141
  end
data/lib/appom/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Appom
2
- VERSION = '1.3.3'.freeze
2
+ VERSION = '1.4.0'.freeze
3
3
  end
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 Appom::TimeoutError, "Timed out after #{@timeout}s."
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.3.3
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-13 00:00:00.000000000 Z
11
+ date: 2021-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appium_lib