appom 1.2.1 → 1.2.2

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: e601fd52165d14faf9034b72ff67ffa96debfc5cbdf4613b7c316ed8141fbf2d
4
- data.tar.gz: 6d66f8805aa55fc163f93bc08194711fa6e7858c7835eda3eeeff39fe02d9761
3
+ metadata.gz: 2f484560756312f1f488680c7dac395f8a811c38d01f691fcb3259ea905c4bd6
4
+ data.tar.gz: 9e282e64e0afdaf5c38d7e91d5304ee5136543039bc30df66761ff8281079751
5
5
  SHA512:
6
- metadata.gz: 5df8393fe36883906a7f60980f8eff1faf89d9013708d91bed32b2fba1da19a3566e6c8c316ead100eca40b850e9c8890049c7ecb05d5228d4861094fd5a97bd
7
- data.tar.gz: 66247fd2603d1250c168f0c8eeb634cd40d0e7178f6e37a825ec06a965ed07bcbd68b5eeb9f35ba3ee72eff4a7a8e14de7a21b6916db9e378b7f64290b4fa66b
6
+ metadata.gz: c39d03e79e31c983eda9dca7d4bafcf00994b2f60783f3d1723f108d89e9eb965bbd5d8aa197e394c4a60c0201a325e16ec700487a82ef34441ae401703de734
7
+ data.tar.gz: dc9c89c08d924e9e9d932f29598c42c3a852845c62083fd65b582d3007160993c6c163bffcbf1d8ac234db7cabe90537e2c7334a475068df060bc1952aecb80f
@@ -2,5 +2,6 @@
2
2
 
3
3
  # We will start driver before each scenario
4
4
  Before do
5
+ puts "---------Start Appom --------1"
5
6
  Appom.start_driver
6
7
  end
@@ -5,29 +5,28 @@ 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
- wait.until do
9
- elements = page.find_elements(*args)
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
- if !visible.nil? && !text.nil?
17
- if element.displayed? && element.text == text
18
- return element
19
- end
20
- elsif !visible.nil?
21
- if element.displayed?
22
- return element
23
- end
24
- elsif !text.nil?
25
- if element.text == text
26
- return element
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
27
26
  end
28
27
  end
28
+ raise Appom::ElementsEmptyError, "Not found element with text #{text}"
29
29
  end
30
- raise Appom::ElementsEmptyError, "Not found element with text #{text}"
31
30
  end
32
31
  end
33
32
 
@@ -64,23 +63,113 @@ module Appom
64
63
  # Note: Function WILL NOT RETURN ELEMENT
65
64
  def wait_until(type, *find_args)
66
65
  wait = Wait.new(timeout: Appom.max_wait_time)
67
- wait.until do
68
- case type
69
- # Function only return true if element enabled or raise an error if time out
70
- when 'element enable'
71
- _find(*find_args).enabled?
72
- # Function only return true if element disabled or raise an error if time out
73
- when 'element disable'
74
- !_find(*find_args).enabled?
75
- # Function only return true if we can find at leat one element (array is not empty) or raise error
76
- when 'at least one element exists'
77
- args, text, visible = deduce_element_args(find_args)
78
- !page.find_elements(*args).empty?
79
- # Function only return true if we can't find at leat one element (array is empty) or raise error
80
- when 'no element exists'
81
- args, text, visible = deduce_element_args(find_args)
82
- page.find_elements(*args).empty?
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
83
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
171
+ end
172
+
84
173
  end
85
174
  end
86
175
 
data/lib/appom/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Appom
2
- VERSION = '1.2.1'.freeze
2
+ VERSION = '1.2.2'.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.1
4
+ version: 1.2.2
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-11 00:00:00.000000000 Z
11
+ date: 2021-03-15 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
@@ -82,16 +82,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
82
  requirements:
83
83
  - - ">="
84
84
  - !ruby/object:Gem::Version
85
- version: 2.2.3
85
+ version: 2.6.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
- rubyforge_project:
93
- rubygems_version: 2.7.9
94
- signing_key:
92
+ rubygems_version: 3.0.8
93
+ signing_key:
95
94
  specification_version: 4
96
95
  summary: A Page Object Model for Appium
97
96
  test_files: []