meglish 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/{meglish.rb → meglish_core.rb} +48 -30
- data/lib/meglish_helper.rb +5 -0
- data/lib/meglish_log.rb +9 -0
- metadata +28 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3e4962ed4645bc91877f34b17287d739c6c755b
|
4
|
+
data.tar.gz: 1046efe069e8127e5a4021146008d6af94df1681
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cb4bd87803ec8bdc4b91e2929ce2ed49153919e91fbb330e2ea6653e2270cebd1d22c86e1585768a7b92fdcf6fe3e85ed55ddcc3aaa54505525fd492d3fab77
|
7
|
+
data.tar.gz: bad064fb7ba732d7fc78ec942dcc0d3f1a72de9591a3f23dc1d5141dbb240a8eb9af8de3e016e96b6eba22d8c81098b4e1d3df5fbfc7739ad8c240962b9e190b
|
@@ -1,21 +1,23 @@
|
|
1
|
-
module
|
1
|
+
module Meglish
|
2
|
+
MELGISH_CONDITIONS = {
|
3
|
+
clear_text: true,
|
4
|
+
scroll_to_element: true,
|
5
|
+
include_all: true,
|
6
|
+
timeout: 30,
|
7
|
+
confirm_alert: true
|
8
|
+
}
|
2
9
|
|
3
10
|
def clear_text_element(_query, _options = {})
|
4
|
-
|
5
|
-
touch(_query.strip)
|
11
|
+
touch_element(_query.strip, _options)
|
6
12
|
clear_text
|
7
13
|
end
|
8
14
|
|
9
15
|
def element_enabled?(_query, _options = {})
|
10
|
-
|
11
|
-
find_element_on_screen(_query, _options)
|
12
|
-
find_elements(_query, _options).first['enabled'] unless element.nil?
|
16
|
+
get_element['enabled']
|
13
17
|
end
|
14
18
|
|
15
19
|
def element_visible?(_query, _options = {})
|
16
|
-
|
17
|
-
find_element_on_screen(_query, _options) unless element.nil?
|
18
|
-
find_elements(_query, _options).first['visible'] unless element.nil?
|
20
|
+
get_element['visible']
|
19
21
|
end
|
20
22
|
|
21
23
|
def find_coordinate_element(_query, _options = {})
|
@@ -25,11 +27,10 @@ module MeglishCommands
|
|
25
27
|
|
26
28
|
def find_element_on_screen(_query, _options = {})
|
27
29
|
_query = include_all(_query, _options)
|
28
|
-
|
29
|
-
|
30
|
-
wait_for_element_exists(_query, timeout: timeout)
|
30
|
+
MeglishLog.new.log(_query)
|
31
|
+
wait_for_element_exists(_query, get_option(:timeout, _options))
|
31
32
|
sleep 0.5
|
32
|
-
scroll_to_element(_query, _options)
|
33
|
+
scroll_to_element(_query, _options)
|
33
34
|
end
|
34
35
|
|
35
36
|
def find_elements(_query, _options = {})
|
@@ -62,9 +63,9 @@ module MeglishCommands
|
|
62
63
|
return []
|
63
64
|
end
|
64
65
|
|
65
|
-
def keyboard_enter_text_element(
|
66
|
+
def keyboard_enter_text_element(_text, _options = {})
|
66
67
|
wait_for_keyboard
|
67
|
-
keyboard_enter_text
|
68
|
+
keyboard_enter_text _text
|
68
69
|
hide_soft_keyboard
|
69
70
|
end
|
70
71
|
|
@@ -89,7 +90,19 @@ module MeglishCommands
|
|
89
90
|
touch_element(_touch_element_query, _options)
|
90
91
|
end
|
91
92
|
|
93
|
+
def set_date_element(_query_input, _date, _options = {})
|
94
|
+
new_date = _date.match(/(^[\d]{4})\/([\d]{1,2})\/([\d]{1,2})/)
|
95
|
+
year = new_date[1].to_i
|
96
|
+
month = (new_date[2].to_i) - 1
|
97
|
+
day = new_date[3].to_i
|
98
|
+
|
99
|
+
touch_element(_query_input, _options)
|
100
|
+
query("DatePicker" ,{method_name: :updateDate, arguments: [year, month, day]})
|
101
|
+
touch("MDButton id:'md_buttonDefaultPositive'") unless get_option(:confirm_alert, _options)
|
102
|
+
end
|
103
|
+
|
92
104
|
def scroll_to_element(_query, _to_top_first = false, _options = {})
|
105
|
+
return unless get_option(:scroll_to_element, _options)
|
93
106
|
hide_soft_keyboard
|
94
107
|
unless (query(_query).first['rect']['height']).zero? && (query(_query).first['rect']['width']).zero?
|
95
108
|
w, h = get_device_size
|
@@ -99,7 +112,7 @@ module MeglishCommands
|
|
99
112
|
swipe_until_find_element(_query, w, x, h, y)
|
100
113
|
end
|
101
114
|
rescue
|
102
|
-
|
115
|
+
MeglishLog.new.log('Scroll to element was ignored')
|
103
116
|
query(_query)
|
104
117
|
end
|
105
118
|
|
@@ -134,8 +147,7 @@ module MeglishCommands
|
|
134
147
|
end
|
135
148
|
|
136
149
|
def touch_element(_query, _options = {})
|
137
|
-
|
138
|
-
touch(_query.strip)
|
150
|
+
touch_element(_query.strip, _options)
|
139
151
|
end
|
140
152
|
|
141
153
|
def touch_element_by_text_position(_query, _text, _options = {})
|
@@ -148,11 +160,9 @@ module MeglishCommands
|
|
148
160
|
end
|
149
161
|
|
150
162
|
def touch_and_keyboard_text_element(_query, _text, _options = {})
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
keyboard_enter_text(_text)
|
155
|
-
hide_soft_keyboard
|
163
|
+
touch_element(_query.strip, _options)
|
164
|
+
clear_text if get_element(:clear_text, _options)
|
165
|
+
keyboard_enter_text_element(_text, _options)
|
156
166
|
end
|
157
167
|
|
158
168
|
def wait_for_or_ignore(_query, _timeout = 3, _options = {})
|
@@ -169,12 +179,12 @@ module MeglishCommands
|
|
169
179
|
found
|
170
180
|
end
|
171
181
|
|
172
|
-
def wait_for_text_element(_query, _timeout = 10,
|
182
|
+
def wait_for_text_element(_query, _timeout = 10, _options = {})
|
173
183
|
count = 0
|
174
184
|
filled = ''
|
175
185
|
while (filled.nil? || filled.empty?)
|
176
186
|
return if count >= _timeout
|
177
|
-
filled = text_element(_query,
|
187
|
+
filled = text_element(_query, _options)
|
178
188
|
sleep 1
|
179
189
|
count += 1
|
180
190
|
end
|
@@ -196,11 +206,7 @@ module MeglishCommands
|
|
196
206
|
private
|
197
207
|
|
198
208
|
def include_all(_query, _options = {})
|
199
|
-
|
200
|
-
unless _options.empty?
|
201
|
-
include_all = _options[:include_all].nil? ? true : _options[:include_all]
|
202
|
-
end
|
203
|
-
_query = 'all ' + _query if _query.include?('all ') == false && include_all == true
|
209
|
+
_query = 'all ' + _query if _query.include?('all ') == false && get_option(:include_all, _options)
|
204
210
|
_query
|
205
211
|
end
|
206
212
|
|
@@ -227,4 +233,16 @@ module MeglishCommands
|
|
227
233
|
swipe_left(_query) until query(_query).first['visible'] || (count_times += 1) >= 5
|
228
234
|
end
|
229
235
|
end
|
236
|
+
|
237
|
+
def get_option(_option, _options)
|
238
|
+
default_value = ENV[_option]
|
239
|
+
default_value = MELGISH_CONDITIONS[_option] if default_value.nil? || default_value.empty?
|
240
|
+
return default_value unless has_option?(_option, _options)
|
241
|
+
_options[option]
|
242
|
+
end
|
243
|
+
|
244
|
+
def has_option?(_option, _options)
|
245
|
+
return (_options[_option].nil? ? false : true) unless _options.nil? || _options.empty?
|
246
|
+
return false
|
247
|
+
end
|
230
248
|
end
|
data/lib/meglish_log.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meglish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eduardo Gomes Heinen
|
@@ -9,17 +9,39 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2016-11-12 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
13
|
-
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: calabash-android
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.2
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.8.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.2
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.8.2
|
33
|
+
description: Meglish find automatically your elements inside your Android Apps
|
14
34
|
email: eduardogheinen@gmail.com
|
15
35
|
executables: []
|
16
36
|
extensions: []
|
17
37
|
extra_rdoc_files: []
|
18
38
|
files:
|
19
|
-
- lib/
|
39
|
+
- lib/meglish_core.rb
|
40
|
+
- lib/meglish_helper.rb
|
41
|
+
- lib/meglish_log.rb
|
20
42
|
homepage: http://rubygems.org/gems/meglish
|
21
43
|
licenses:
|
22
|
-
-
|
44
|
+
- AGPL-3.0
|
23
45
|
metadata: {}
|
24
46
|
post_install_message:
|
25
47
|
rdoc_options: []
|
@@ -40,5 +62,5 @@ rubyforge_project:
|
|
40
62
|
rubygems_version: 2.5.1
|
41
63
|
signing_key:
|
42
64
|
specification_version: 4
|
43
|
-
summary: Meglish a super framework to Calabash
|
65
|
+
summary: Meglish is a super framework to Calabash-Android
|
44
66
|
test_files: []
|