Ifd_Mobile 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/lib/Ifd_Mobile/lib_steps.rb +145 -145
  3. data/lib/Ifd_Mobile/methods/IFD_Assertion.rb +44 -44
  4. data/lib/Ifd_Mobile/methods/IFD_Connection.rb +28 -0
  5. data/lib/Ifd_Mobile/methods/core.rb +256 -256
  6. data/lib/Ifd_Mobile/methods/database_methods.rb +25 -0
  7. data/lib/Ifd_Mobile/methods/lib_schema_data_steps.rb +53 -0
  8. data/lib/Ifd_Mobile/methods/lib_var.rb +53 -53
  9. data/lib/Ifd_Mobile/methods/required_files.rb +3 -0
  10. data/lib/Ifd_Mobile/version.rb +5 -5
  11. data/project/Gemfile +11 -9
  12. data/project/Gemfile.lock +137 -50
  13. data/project/apps/TestApp/Test App 2/GestureTestViewController.h +18 -18
  14. data/project/apps/TestApp/Test App 2/GestureTestViewController.m +48 -48
  15. data/project/apps/TestApp/Test App 2/GestureTestViewController.xib +46 -46
  16. data/project/apps/TestApp/Test App 2/MyViewControllerViewController.h +42 -42
  17. data/project/apps/TestApp/Test App 2/MyViewControllerViewController.m +193 -193
  18. data/project/apps/TestApp/Test App 2/TA2AppDelegate.h +28 -28
  19. data/project/apps/TestApp/Test App 2/TA2AppDelegate.m +85 -85
  20. data/project/apps/TestApp/Test App 2/TestApp-Info.plist +40 -40
  21. data/project/apps/TestApp/Test App 2/TestApp-Prefix.pch +29 -29
  22. data/project/apps/TestApp/Test App 2/en.lproj/InfoPlist.strings +21 -21
  23. data/project/apps/TestApp/Test App 2/en.lproj/MyViewControllerViewController.xib +175 -175
  24. data/project/apps/TestApp/Test App 2/main.m +31 -31
  25. data/project/apps/TestApp/TestApp.xcodeproj/project.pbxproj +336 -336
  26. data/project/apps/TestApp/TestApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -7
  27. data/project/apps/TestApp/TestApp.xcodeproj/xcuserdata/anhpham.xcuserdatad/xcschemes/TestApp.xcscheme +88 -88
  28. data/project/apps/TestApp/TestApp.xcodeproj/xcuserdata/anhpham.xcuserdatad/xcschemes/xcschememanagement.plist +22 -22
  29. data/project/features/TestData/SqlScript/test.sql +0 -0
  30. data/project/features/android/Android_test1.feature +14 -16
  31. data/project/features/android/Android_test2.feature +14 -14
  32. data/project/features/iOS/iOS_test.feature +15 -15
  33. data/project/features/step_definitions/lib_steps/PolyClaim_homepage.rb +2 -12
  34. data/project/features/step_definitions/lib_steps/PolyClaim_loginpage.rb +3 -3
  35. data/project/features/step_definitions/repositories/android_ob_test.rb +9 -9
  36. data/project/features/step_definitions/repositories/ios_ob_test.rb +6 -6
  37. data/project/features/support/env.rb +36 -36
  38. data/project/features/support/hooks.rb +8 -8
  39. data/project/features/support/project_env.rb +55 -42
  40. metadata +7 -5
  41. data/project/apps/Bedder_2.0_0.17_VN.apk +0 -0
  42. data/project/apps/polyclaim.apk +0 -0
@@ -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
@@ -0,0 +1,25 @@
1
+ class DatabaseMethods
2
+ def self.execute_select (schema,sql)
3
+ case $db_type.to_sym
4
+ when :sql_server then
5
+ conn = IFD_Connections.get_sql_server_db_connection(schema)
6
+ conn.execute sql
7
+ when :mysql then
8
+ conn = IFD_Connections.get_mysql_db_connection(schema)
9
+ conn.query sql
10
+ else
11
+ raise "*** ERROR: schema type (#{$db_type}) is not supported (SQL SERVER, MY SQL)."
12
+ end
13
+ end
14
+
15
+ def self.close_connection (schema)
16
+ case $db_type.to_sym
17
+ when :sql_server then
18
+ conn = IFD_Connections.get_sql_server_db_connection(schema)
19
+ conn.close
20
+ when :mysql then
21
+ conn = IFD_Connections.get_mysql_db_connection(schema)
22
+ conn.close
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,53 @@
1
+ require_relative 'methods/required_files'
2
+ #====================================
3
+ # INTERACTION STEPS
4
+ #====================================
5
+ # Step used to execute a SQL script on a specific schema
6
+ And /^I run sql script "([^\"]*)" on "([^\"]*)" schema$/ do |script, schema|
7
+ begin
8
+ sql = "#{script}"
9
+ DatabaseMethods.execute_select(schema, sql)
10
+ DatabaseMethods.close_connection(schema)
11
+ ensure
12
+ end
13
+ end
14
+ # Step used to execute SQL script from SQL file on specific schema
15
+ Given /^I run sql script from file "([^\"]*)" on "([^\"]*)" schema$/ do |sql_script, schema|
16
+ if sql_script != nil and sql_script != ""
17
+ begin
18
+ File.readlines($sql_dir + sql_script).each do |line|
19
+ if line.nil? || line =~ /^\s*\n*--/
20
+ # puts "\nSQL: " + line;
21
+ next;
22
+ end
23
+ line = line.strip();
24
+ line = line[0..-2];
25
+ #puts "\nSQL: " + line;
26
+ DatabaseMethods.execute_select(schema, line)
27
+ sleep(1);
28
+ end
29
+ DatabaseMethods.close_connection(schema)
30
+ end
31
+ end
32
+ end
33
+
34
+ # Step used to check if data exists in database or not with condition in file
35
+ Then /^I should ( not)? see data in schema "(.*)" database with SQL query in file "(.*)"$/ do |negative, schema, file|
36
+ sql = File.read($sql_dir + file)
37
+ filepath = ($sql_dir + file)
38
+ if File.exist?(filepath)
39
+ begin
40
+ rs = DatabaseMethods.execute_select(schema, sql)
41
+ obj_array = Array.new
42
+ rs.each { |row|
43
+ row.each_pair { |col, value|
44
+ assert(false) if negative.nil? && value == 0 || !negative.nil? && value == 1
45
+ }
46
+ }
47
+ ensure
48
+ DatabaseMethods.close_connection(schema)
49
+ end
50
+ else
51
+ raise "*** ERROR: Please check #{filepath} exists."
52
+ end
53
+ end