Ifd_Mobile 0.1.6 → 0.1.7

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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/lib/Ifd_Mobile/lib_steps.rb +145 -140
  3. data/lib/Ifd_Mobile/methods/IFD_Assertion.rb +44 -44
  4. data/lib/Ifd_Mobile/methods/core.rb +256 -256
  5. data/lib/Ifd_Mobile/methods/lib_var.rb +53 -53
  6. data/lib/Ifd_Mobile/version.rb +5 -5
  7. data/project/Gemfile +9 -9
  8. data/project/Gemfile.lock +50 -137
  9. data/project/apps/Bedder_2.0_0.17_VN.apk +0 -0
  10. data/project/apps/TestApp/Test App 2/GestureTestViewController.h +18 -18
  11. data/project/apps/TestApp/Test App 2/GestureTestViewController.m +48 -48
  12. data/project/apps/TestApp/Test App 2/GestureTestViewController.xib +46 -46
  13. data/project/apps/TestApp/Test App 2/MyViewControllerViewController.h +42 -42
  14. data/project/apps/TestApp/Test App 2/MyViewControllerViewController.m +193 -193
  15. data/project/apps/TestApp/Test App 2/TA2AppDelegate.h +28 -28
  16. data/project/apps/TestApp/Test App 2/TA2AppDelegate.m +85 -85
  17. data/project/apps/TestApp/Test App 2/TestApp-Info.plist +40 -40
  18. data/project/apps/TestApp/Test App 2/TestApp-Prefix.pch +29 -29
  19. data/project/apps/TestApp/Test App 2/en.lproj/InfoPlist.strings +21 -21
  20. data/project/apps/TestApp/Test App 2/en.lproj/MyViewControllerViewController.xib +175 -175
  21. data/project/apps/TestApp/Test App 2/main.m +31 -31
  22. data/project/apps/TestApp/TestApp.xcodeproj/project.pbxproj +336 -336
  23. data/project/apps/TestApp/TestApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -7
  24. data/project/apps/TestApp/TestApp.xcodeproj/xcuserdata/anhpham.xcuserdatad/xcschemes/TestApp.xcscheme +88 -88
  25. data/project/apps/TestApp/TestApp.xcodeproj/xcuserdata/anhpham.xcuserdatad/xcschemes/xcschememanagement.plist +22 -22
  26. data/project/apps/polyclaim.apk +0 -0
  27. data/project/features/android/Android_test1.feature +16 -14
  28. data/project/features/android/Android_test2.feature +14 -14
  29. data/project/features/iOS/iOS_test.feature +15 -15
  30. data/project/features/step_definitions/lib_steps/PolyClaim_homepage.rb +12 -2
  31. data/project/features/step_definitions/lib_steps/PolyClaim_loginpage.rb +3 -3
  32. data/project/features/step_definitions/repositories/android_ob_test.rb +9 -9
  33. data/project/features/step_definitions/repositories/ios_ob_test.rb +6 -6
  34. data/project/features/support/env.rb +36 -36
  35. data/project/features/support/hooks.rb +8 -8
  36. data/project/features/support/project_env.rb +42 -42
  37. metadata +41 -45
@@ -1,256 +1,256 @@
1
- $_RP_OBJECT = {}
2
-
3
- def call_step str_step
4
- put_log "\n-=> call step: #{str_step}"
5
- step %{#{str_step}}
6
- end
7
-
8
- def put_log str
9
- puts str if $_CONFIG['Print Log'] == true
10
- end
11
-
12
- def find_object string_object
13
- # startTime = Time.new.to_i
14
- string_object = string_object.gsub(/"/, "'")
15
- # puts string_object
16
- locator_matching = /(.*?)(\{.*?\})/.match(string_object)
17
- # puts "locator_matching : #{locator_matching}"
18
- dyn_pros = {}
19
- if locator_matching != nil
20
- string_object = locator_matching[1]
21
- eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
22
- dyn_pros[k.to_s.upcase] = v
23
- }
24
- end
25
- hash_object = $_RP_OBJECT[string_object]
26
- puts hash_object
27
- if hash_object == nil
28
- put_log ">>> OBJECT NAME MAYBE NOT FOUND!!!"
29
- true.should eq false
30
- end
31
- attribute = {}
32
- if hash_object != nil
33
- hash_object.each { |k, v|
34
- k = k.to_s
35
- if k =~ /ph_/i
36
- if dyn_pros[k] != nil
37
- # Assign place holder value to place holder property, also remove prefix ph_ from property key,
38
- # also remove this pl from dyn_pros <= should be consider to continue transfer into inner object in relation
39
- if v =~ /<ph_value>/i
40
- attribute[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k])
41
- else
42
- attribute[k[3..k.size-1]] = dyn_pros[k]
43
- end
44
- dyn_pros.delete(k)
45
- end
46
- else
47
- attribute[k.to_s] = v
48
- end
49
- }
50
- end
51
- # put_log string_object
52
- # put_log "\nattribute: #{attribute}"
53
-
54
- attribute.each { |key, value|
55
- $element_tag = key
56
- $element_value = value
57
- }
58
- return selenium.find_element($element_tag, $element_value)
59
- end
60
-
61
- def execute_click element
62
- found_element = find_object element
63
- if found_element != nil
64
- startTime = Time.new.to_i
65
- begin
66
- sleep(1)
67
- currentTime= Time.new.to_i
68
- end while (currentTime - startTime) < $_CONFIG['Wait Time']
69
- # selenium.execute_script('mobile: scroll', found_element)
70
- found_element.click
71
- else
72
- put_log "\nERROR: *** not found object: #{element}"
73
- end
74
- end
75
-
76
- def execute_settext element, text
77
- found_element = find_object element
78
- if found_element != nil
79
- begin
80
- sleep(1)
81
- # found_element.long_press_keycode(46)
82
- found_element.send_keys(text)
83
- rescue StandardError => myStandardError
84
- put_log "\nERROR: *** #{myStandardError}"
85
- end
86
- else
87
- put_log "\nERROR: *** not found object: #{element}"
88
- exit
89
- end
90
- end
91
-
92
- def execute_checkproperty element, property, negate, value
93
- found_element = find_object element
94
- check = false
95
- if found_element == nil and value == ""
96
- check = true
97
- expect(check).to eq true
98
- else
99
- put_log "\n*** Execute_CheckProperty: finish to found element"
100
- if found_element != nil
101
- if property.upcase == 'VALUE'
102
- actual_value = found_element.attribute("value")
103
- elsif property.upcase == 'NAME'
104
- actual_value = found_element.attribute("name")
105
- elsif property.upcase == 'LABEL'
106
- actual_value = found_element.attribute("label")
107
- elsif property.upcase == 'TYPE'
108
- actual_value = found_element.attribute("type")
109
- elsif property.upcase == 'ENABLE'
110
- actual_value = found_element.attribute("enable")
111
- else
112
- actual_value = found_element.attribute("#{property}")
113
- end
114
- if actual_value == nil
115
- actual_value = ''
116
- end
117
- else
118
- put_log "ERROR: *** Not found object: #{element}"
119
- end
120
-
121
- if IFD_Assertion.reg_compare(actual_value, value)
122
- check = true
123
- end
124
-
125
- put_log "\n#{property} :: Actual Result Is '#{actual_value}' -- Expected Result Is '#{value}'"
126
-
127
- if negate == " not"
128
- expect(check).not_to eql true
129
- elsif expect(check).to eq true
130
- end
131
- end
132
- end
133
-
134
- def click_by_coordinate x, y
135
- selenium.execute_script 'mobile: tap', :x => x, :y => y
136
- end
137
-
138
- # method to navigate back & forward
139
- def navigate(direction)
140
- if direction == 'back'
141
- selenium.navigate.back
142
- else
143
- selenium.navigate.forward
144
- end
145
- end
146
-
147
- def swipe_direction(direction)
148
- size = selenium.manage.window.size
149
- height = size.height.to_i - 10
150
- width = size.width.to_i - 10
151
-
152
- if direction == 'right'
153
- start_x = (width/100) * 15 # 83
154
- start_y = height/2 # 695
155
- end_x = (width/100) * 90 # 900
156
- end_y = height/2 # 630
157
- elsif direction == 'left'
158
- start_x = (width/100) * 90
159
- start_y = height/2
160
- end_x = (width/100) * 15
161
- end_y = height/2
162
- elsif direction == 'up'
163
- start_x = width/2
164
- start_y = (height/100) * 90
165
- end_x = width/2
166
- end_y = (height/100) * 15
167
- elsif direction == 'down'
168
- start_x = width/2
169
- start_y = (height/100) * 15
170
- end_x = width/2
171
- end_y = (height/100) * 90
172
- else
173
- raise "invalid direction"
174
- end
175
-
176
- swipe(start_x, start_y, end_x, end_y)
177
- end
178
-
179
- def swipe(start_x, start_y, end_x, end_y)
180
- action = Appium::TouchAction.new.press(x: "#{start_x}", y: "#{start_y}").wait(1000).move_to(x: "#{end_x}", y: "#{end_y}").release()
181
- action.perform
182
- end
183
-
184
-
185
- def long_press_on_element_default_duration(element)
186
- begin
187
- ele_from = find_object element.location
188
- x = ele_from.x
189
- y = ele_from.y
190
-
191
- action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
192
- action.perform
193
- rescue Exception => e
194
- if e.to_s == 'The swipe did not complete successfully'
195
- print ""
196
- else
197
- raise e
198
- end
199
- end
200
- end
201
-
202
- def long_press_on_element_with_duration(element, duration)
203
- begin
204
- ele_from = find_object element.location
205
- x = ele_from.x
206
- y = ele_from.y
207
-
208
- duration = duration.to_i
209
- duration = duration * 1000
210
- action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
211
- action.perform
212
- rescue Exception => e
213
- if e.to_s == 'The swipe did not complete successfully'
214
- print ""
215
- else
216
- raise e
217
- end
218
- end
219
- end
220
-
221
- def long_press_on_coordinates(x, y)
222
- action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
223
- action.perform
224
- end
225
-
226
- def long_press_on_coordinates_with_duration(x, y, duration)
227
- duration = duration.to_i
228
- duration = duration * 1000
229
- puts duration
230
- action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
231
- action.perform
232
- end
233
-
234
- def close_app
235
- selenium.close_app
236
- end
237
-
238
- def launch_app
239
- selenium.launch
240
- end
241
-
242
- def reset_app
243
- selenium.reset
244
- end
245
-
246
- def delete_an_character_android
247
- system('adb shell input keyevent 67')
248
- end
249
-
250
- def take_photo_android
251
- system('adb shell input keyevent 27')
252
- end
253
-
254
- def move_home
255
- selenium.key_event 3
256
- end
1
+ $_RP_OBJECT = {}
2
+
3
+ def call_step str_step
4
+ put_log "\n-=> call step: #{str_step}"
5
+ step %{#{str_step}}
6
+ end
7
+
8
+ def put_log str
9
+ puts str if $_CONFIG['Print Log'] == true
10
+ end
11
+
12
+ def find_object string_object
13
+ # startTime = Time.new.to_i
14
+ string_object = string_object.gsub(/"/, "'")
15
+ # puts string_object
16
+ locator_matching = /(.*?)(\{.*?\})/.match(string_object)
17
+ # puts "locator_matching : #{locator_matching}"
18
+ dyn_pros = {}
19
+ if locator_matching != nil
20
+ string_object = locator_matching[1]
21
+ eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
22
+ dyn_pros[k.to_s.upcase] = v
23
+ }
24
+ end
25
+ hash_object = $_RP_OBJECT[string_object]
26
+ puts hash_object
27
+ if hash_object == nil
28
+ put_log ">>> OBJECT NAME MAYBE NOT FOUND!!!"
29
+ true.should eq false
30
+ end
31
+ attribute = {}
32
+ if hash_object != nil
33
+ hash_object.each { |k, v|
34
+ k = k.to_s
35
+ if k =~ /ph_/i
36
+ if dyn_pros[k] != nil
37
+ # Assign place holder value to place holder property, also remove prefix ph_ from property key,
38
+ # also remove this pl from dyn_pros <= should be consider to continue transfer into inner object in relation
39
+ if v =~ /<ph_value>/i
40
+ attribute[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k])
41
+ else
42
+ attribute[k[3..k.size-1]] = dyn_pros[k]
43
+ end
44
+ dyn_pros.delete(k)
45
+ end
46
+ else
47
+ attribute[k.to_s] = v
48
+ end
49
+ }
50
+ end
51
+ # put_log string_object
52
+ # put_log "\nattribute: #{attribute}"
53
+
54
+ attribute.each { |key, value|
55
+ $element_tag = key
56
+ $element_value = value
57
+ }
58
+ return selenium.find_element($element_tag, $element_value)
59
+ end
60
+
61
+ def execute_click element
62
+ found_element = find_object element
63
+ if found_element != nil
64
+ startTime = Time.new.to_i
65
+ begin
66
+ sleep(1)
67
+ currentTime= Time.new.to_i
68
+ end while (currentTime - startTime) < $_CONFIG['Wait Time']
69
+ # selenium.execute_script('mobile: scroll', found_element)
70
+ found_element.click
71
+ else
72
+ put_log "\nERROR: *** not found object: #{element}"
73
+ end
74
+ end
75
+
76
+ def execute_settext element, text
77
+ found_element = find_object element
78
+ if found_element != nil
79
+ begin
80
+ sleep(1)
81
+ # found_element.long_press_keycode(46)
82
+ found_element.send_keys(text)
83
+ rescue StandardError => myStandardError
84
+ put_log "\nERROR: *** #{myStandardError}"
85
+ end
86
+ else
87
+ put_log "\nERROR: *** not found object: #{element}"
88
+ exit
89
+ end
90
+ end
91
+
92
+ def execute_checkproperty element, property, negate, value
93
+ found_element = find_object element
94
+ check = false
95
+ if found_element == nil and value == ""
96
+ check = true
97
+ expect(check).to eq true
98
+ else
99
+ put_log "\n*** Execute_CheckProperty: finish to found element"
100
+ if found_element != nil
101
+ if property.upcase == 'VALUE'
102
+ actual_value = found_element.attribute("value")
103
+ elsif property.upcase == 'NAME'
104
+ actual_value = found_element.attribute("name")
105
+ elsif property.upcase == 'LABEL'
106
+ actual_value = found_element.attribute("label")
107
+ elsif property.upcase == 'TYPE'
108
+ actual_value = found_element.attribute("type")
109
+ elsif property.upcase == 'ENABLE'
110
+ actual_value = found_element.attribute("enable")
111
+ else
112
+ actual_value = found_element.attribute("#{property}")
113
+ end
114
+ if actual_value == nil
115
+ actual_value = ''
116
+ end
117
+ else
118
+ put_log "ERROR: *** Not found object: #{element}"
119
+ end
120
+
121
+ if IFD_Assertion.reg_compare(actual_value, value)
122
+ check = true
123
+ end
124
+
125
+ put_log "\n#{property} :: Actual Result Is '#{actual_value}' -- Expected Result Is '#{value}'"
126
+
127
+ if negate == " not"
128
+ expect(check).not_to eql true
129
+ elsif expect(check).to eq true
130
+ end
131
+ end
132
+ end
133
+
134
+ def click_by_coordinate x, y
135
+ selenium.execute_script 'mobile: tap', :x => x, :y => y
136
+ end
137
+
138
+ # method to navigate back & forward
139
+ def navigate(direction)
140
+ if direction == 'back'
141
+ selenium.navigate.back
142
+ else
143
+ selenium.navigate.forward
144
+ end
145
+ end
146
+
147
+ # def swipe_direction(direction)
148
+ # size = selenium.manage.window.size
149
+ # height = size.height.to_i - 10
150
+ # width = size.width.to_i - 10
151
+ #
152
+ # if direction == 'right'
153
+ # start_x = (width/100) * 15 # 83
154
+ # start_y = height/2 # 695
155
+ # end_x = (width/100) * 90 # 900
156
+ # end_y = height/2 # 630
157
+ # elsif direction == 'left'
158
+ # start_x = (width/100) * 90
159
+ # start_y = height/2
160
+ # end_x = (width/100) * 15
161
+ # end_y = height/2
162
+ # elsif direction == 'up'
163
+ # start_x = width/2
164
+ # start_y = (height/100) * 90
165
+ # end_x = width/2
166
+ # end_y = (height/100) * 15
167
+ # elsif direction == 'down'
168
+ # start_x = width/2
169
+ # start_y = (height/100) * 15
170
+ # end_x = width/2
171
+ # end_y = (height/100) * 90
172
+ # else
173
+ # raise "invalid direction"
174
+ # end
175
+ #
176
+ # swipe(start_x, start_y, end_x, end_y)
177
+ # end
178
+
179
+ # def swipe(start_x, start_y, end_x, end_y)
180
+ # action = Appium::TouchAction.new.press(x: "#{start_x}", y: "#{start_y}").wait(1000).move_to(x: "#{end_x}", y: "#{end_y}").release()
181
+ # action.perform
182
+ # end
183
+
184
+
185
+ def long_press_on_element_default_duration(element)
186
+ begin
187
+ ele_from = find_object element.location
188
+ x = ele_from.x
189
+ y = ele_from.y
190
+
191
+ action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
192
+ action.perform
193
+ rescue Exception => e
194
+ if e.to_s == 'The swipe did not complete successfully'
195
+ print ""
196
+ else
197
+ raise e
198
+ end
199
+ end
200
+ end
201
+
202
+ def long_press_on_element_with_duration(element, duration)
203
+ begin
204
+ ele_from = find_object element.location
205
+ x = ele_from.x
206
+ y = ele_from.y
207
+
208
+ duration = duration.to_i
209
+ duration = duration * 1000
210
+ action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
211
+ action.perform
212
+ rescue Exception => e
213
+ if e.to_s == 'The swipe did not complete successfully'
214
+ print ""
215
+ else
216
+ raise e
217
+ end
218
+ end
219
+ end
220
+
221
+ def long_press_on_coordinates(x, y)
222
+ action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
223
+ action.perform
224
+ end
225
+
226
+ def long_press_on_coordinates_with_duration(x, y, duration)
227
+ duration = duration.to_i
228
+ duration = duration * 1000
229
+ puts duration
230
+ action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
231
+ action.perform
232
+ end
233
+
234
+ def close_app
235
+ selenium.close_app
236
+ end
237
+
238
+ def launch_app
239
+ selenium.launch
240
+ end
241
+
242
+ def reset_app
243
+ selenium.reset
244
+ end
245
+
246
+ def delete_an_character_android
247
+ system('adb shell input keyevent 67')
248
+ end
249
+
250
+ def take_photo_android
251
+ system('adb shell input keyevent 27')
252
+ end
253
+
254
+ def move_home
255
+ selenium.key_event 3
256
+ end
@@ -1,54 +1,54 @@
1
- def var_collect string_var
2
- if string_var =~ /^.*{year}.*$/
3
- string_var = replace_year(string_var)
4
- end
5
-
6
- if string_var =~ /^.*{month}.*$/
7
- string_var = replace_month(string_var)
8
- end
9
-
10
- if string_var =~ /^.*{day}.*$/
11
- string_var = replace_day(string_var)
12
- end
13
-
14
- if string_var =~ /^.*{store_value}.*$/
15
- string_var = $context_value
16
- end
17
-
18
- return string_var
19
- end
20
-
21
- def replace_year str
22
- t = Time.now()
23
- return str.gsub("{year}", t.year.to_s)
24
- end
25
-
26
- def replace_month str
27
- t = Time.now()
28
- _month = t.month
29
- if _month < 10
30
- return str.gsub("{month}", "0#{_month.to_s}")
31
- else
32
- return str.gsub("{month}", "#{_month.to_s}")
33
- end
34
- return str
35
- end
36
-
37
- def replace_day str
38
- t = Time.now()
39
- _day = t.day
40
- if _day < 10
41
- return str.gsub("{day}", "0#{_day.to_s}")
42
- else
43
- return str.gsub("{day}", "#{_day.to_s}")
44
- end
45
- return str
46
- end
47
-
48
- def replace_pipe str_pipe
49
- put_log ">>>> #{str_pipe}"
50
- if str_pipe =~ /^.*{pipe}.*$/
51
- return str_pipe.gsub("{pipe}", "|")
52
- end
53
- return str_pipe
1
+ def var_collect string_var
2
+ if string_var =~ /^.*{year}.*$/
3
+ string_var = replace_year(string_var)
4
+ end
5
+
6
+ if string_var =~ /^.*{month}.*$/
7
+ string_var = replace_month(string_var)
8
+ end
9
+
10
+ if string_var =~ /^.*{day}.*$/
11
+ string_var = replace_day(string_var)
12
+ end
13
+
14
+ if string_var =~ /^.*{store_value}.*$/
15
+ string_var = $context_value
16
+ end
17
+
18
+ return string_var
19
+ end
20
+
21
+ def replace_year str
22
+ t = Time.now()
23
+ return str.gsub("{year}", t.year.to_s)
24
+ end
25
+
26
+ def replace_month str
27
+ t = Time.now()
28
+ _month = t.month
29
+ if _month < 10
30
+ return str.gsub("{month}", "0#{_month.to_s}")
31
+ else
32
+ return str.gsub("{month}", "#{_month.to_s}")
33
+ end
34
+ return str
35
+ end
36
+
37
+ def replace_day str
38
+ t = Time.now()
39
+ _day = t.day
40
+ if _day < 10
41
+ return str.gsub("{day}", "0#{_day.to_s}")
42
+ else
43
+ return str.gsub("{day}", "#{_day.to_s}")
44
+ end
45
+ return str
46
+ end
47
+
48
+ def replace_pipe str_pipe
49
+ put_log ">>>> #{str_pipe}"
50
+ if str_pipe =~ /^.*{pipe}.*$/
51
+ return str_pipe.gsub("{pipe}", "|")
52
+ end
53
+ return str_pipe
54
54
  end
@@ -1,5 +1,5 @@
1
- module Ifd
2
- module Mobile
3
- VERSION = '0.1.6'
4
- end
5
- end
1
+ module Ifd
2
+ module Mobile
3
+ VERSION = '0.1.7'
4
+ end
5
+ end
data/project/Gemfile CHANGED
@@ -1,10 +1,10 @@
1
- source "https://www.rubygems.org"
2
-
3
- gem "rest-client"
4
- gem "rspec"
5
- gem "selenium-webdriver"
6
- gem "cucumber"
7
- gem "rspec-expectations"
8
- gem "appium_lib"
9
- gem "rack-utf8_sanitizer"
1
+ source "http://www.rubygems.org"
2
+
3
+ gem "rest-client"
4
+ gem "rspec"
5
+ gem "selenium-webdriver"
6
+ gem "cucumber"
7
+ gem "rspec-expectations"
8
+ gem "appium_lib"
9
+ gem "rack-utf8_sanitizer"
10
10
  gem "Ifd_Mobile"