appom 1.2.0 → 1.3.1

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: 35d79b86da3958d465691aa8f67adff728310412cfe8f898ec1f00b16efc0102
4
- data.tar.gz: 3bea92052029e696b96c86bdacbdddaeaca1972fced1bb0e27592d0d13e1ca46
3
+ metadata.gz: 2f34beb277b19dd56062d095dfc710b587ba210334fbaddca1ca278f1944a34a
4
+ data.tar.gz: 6d72a01178c225dec28c1320ac1aeb937b78f6b577d39c439f9645a364d8d3fd
5
5
  SHA512:
6
- metadata.gz: 9dfdae46709e5bc0657ae10c92010e2979ad8285673545b662fb04402b0dae1fa4a360b4755b05e5da303a66b9796e66be6b2cf113df4af05241b32cb8f2915c
7
- data.tar.gz: d49e352631b8cd97fb50b5ba7bd5e712eb63cb23e01cdefb1125802382f79b200c590a042c5a511da794bd2b191ce010c27257a9207322c79ad93cafe2c1a578
6
+ metadata.gz: 2313c1979765e4af47c8b453183cd30507e0f2309879234c233f2f3671df2fbd82bb66d47c3c21721dfe903a4f96af7af9e4619598de7cfca505c9ece75077af
7
+ data.tar.gz: fd4da56697db614455a4c1334d3ec097bc229a97be03e006853aa2239300ab631f7d6ffaaed8f1a4249f17f391db2421d17005a974c876599744c0b3e6357bf2
@@ -8,11 +8,6 @@ module Appom
8
8
  wait.until do
9
9
  elements = page.find_elements(*args)
10
10
  elements.each do |element|
11
- # No need to check. Just return first element
12
- if visible.nil? && text.nil?
13
- return element
14
- end
15
-
16
11
  if !visible.nil? && !text.nil?
17
12
  if element.displayed? && element.text == text
18
13
  return element
@@ -25,22 +20,67 @@ module Appom
25
20
  if element.text == text
26
21
  return element
27
22
  end
23
+ # Just return first element
24
+ else
25
+ return element
28
26
  end
29
27
  end
30
- raise Appom::ElementsEmptyError, "Not found element with text #{text}"
28
+ raise Appom::ElementsEmptyError, "Can not found element with args = #{find_args}"
31
29
  end
32
30
  end
33
31
 
34
32
  # Find elements
35
33
  def _all(*find_args)
36
- page.find_elements(*find_args)
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
37
56
  end
38
57
 
39
- # Check page has or has not elment with find_args
58
+ # Check page has or has not element with find_args
40
59
  # If page has element return TRUE else return FALSE
41
60
  def _check_has_element(*find_args)
42
- elements = page.find_elements(*find_args)
43
- return elements.empty? ? false : true
61
+ elements = page.find_elements(*args)
62
+
63
+ if visible.nil? && text.nil?
64
+ return elements.empty? ? false : true
65
+ else
66
+ is_found = false
67
+ elements.each do |element|
68
+ if !visible.nil? && !text.nil?
69
+ if element.displayed? && element.text == text
70
+ is_found = true
71
+ end
72
+ elsif !visible.nil?
73
+ if element.displayed?
74
+ is_found = true
75
+ end
76
+ elsif !text.nil?
77
+ if element.text == text
78
+ is_found = true
79
+ end
80
+ end
81
+ end
82
+ return is_found
83
+ end
44
84
  end
45
85
 
46
86
  ##
@@ -53,7 +93,7 @@ module Appom
53
93
  result = page.find_elements(*find_args)
54
94
  # If reponse is empty we will return false to make it not pass Wait condition
55
95
  if result.empty?
56
- raise Appom::ElementsEmptyError, "Array is empty"
96
+ raise Appom::ElementsEmptyError, "Can not found any elements with args = #{find_args}"
57
97
  end
58
98
  # Return result
59
99
  return result
@@ -68,16 +108,16 @@ module Appom
68
108
  case type
69
109
  # Function only return true if element enabled or raise an error if time out
70
110
  when 'element enable'
71
- page.find_element(*find_args).enabled?
111
+ _find(*find_args).enabled?
72
112
  # Function only return true if element disabled or raise an error if time out
73
113
  when 'element disable'
74
- !page.find_element(*find_args).enabled?
114
+ !_find(*find_args).enabled?
75
115
  # Function only return true if we can find at leat one element (array is not empty) or raise error
76
116
  when 'at least one element exists'
77
- !page.find_elements(*find_args).empty?
117
+ !_all(*find_args).empty?
78
118
  # Function only return true if we can't find at leat one element (array is empty) or raise error
79
119
  when 'no element exists'
80
- page.find_elements(*find_args).empty?
120
+ _all(*find_args).empty?
81
121
  end
82
122
  end
83
123
  end
data/lib/appom/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Appom
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.3.1'.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.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry.Tran
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-09 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
@@ -74,7 +74,7 @@ homepage: https://github.com/hoangtaiki/appom
74
74
  licenses:
75
75
  - MIT
76
76
  metadata: {}
77
- post_install_message:
77
+ post_install_message:
78
78
  rdoc_options: []
79
79
  require_paths:
80
80
  - lib
@@ -89,9 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubyforge_project:
93
- rubygems_version: 2.7.9
94
- signing_key:
92
+ rubygems_version: 3.2.19
93
+ signing_key:
95
94
  specification_version: 4
96
95
  summary: A Page Object Model for Appium
97
96
  test_files: []