Top Level Namespace
Defined Under Namespace
Modules: Ifd
Classes: IFD_Assertion, IFD_Connections
Instance Method Summary
collapse
Instance Method Details
#call_step(str_step) ⇒ Object
1
2
3
4
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 1
def call_step str_step
put_log "\n-=> call step: #{str_step}"
step %{#{str_step}}
end
|
#click_by_coordinate(x, y) ⇒ Object
110
111
112
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 110
def click_by_coordinate x, y
selenium.execute_script 'mobile: tap', :x => x, :y => y
end
|
#close_app ⇒ Object
210
211
212
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 210
def close_app
selenium.close_app
end
|
#data(name) ⇒ Object
234
235
236
237
238
239
240
241
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 234
def data(name)
require 'yaml'
begin
return $globalData["#{name}"]
rescue Exception
return name
end
end
|
#delete_an_character_android ⇒ Object
222
223
224
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 222
def delete_an_character_android
system('adb shell input keyevent 67')
end
|
#execute_checkproperty(element, property, negate, value) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 68
def execute_checkproperty element, property, negate, value
found_element = find_object element
check = false
if found_element == nil and value == ""
check = true
expect(check).to eq true
else
put_log "\n*** Execute_CheckProperty: finish to found element"
if found_element != nil
if property.upcase == 'VALUE'
actual_value = found_element.attribute("value")
elsif property.upcase == 'NAME'
actual_value = found_element.attribute("name")
elsif property.upcase == 'LABEL'
actual_value = found_element.attribute("label")
elsif property.upcase == 'TYPE'
actual_value = found_element.attribute("type")
elsif property.upcase == 'ENABLE'
actual_value = found_element.attribute("enable")
else
actual_value = found_element.attribute("#{property}")
end
if actual_value == nil
actual_value = ''
end
else
put_log "ERROR: *** Not found object: #{element}"
end
if IFD_Assertion.reg_compare(actual_value, value)
check = true
end
put_log "\n#{property} :: Actual Result Is '#{actual_value}' -- Expected Result Is '#{value}'"
if negate == " not"
expect(check).not_to eql true
elsif expect(check).to eq true
end
end
end
|
#execute_click(element) ⇒ Object
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 37
def execute_click element
found_element = find_object element
if found_element != nil
startTime = Time.new.to_i
begin
sleep(1)
currentTime= Time.new.to_i
end while (currentTime - startTime) < $_CONFIG['Wait Time']
found_element.click
else
put_log "\nERROR: *** not found object: #{element}"
end
end
|
#execute_settext(element, text) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 52
def execute_settext element, text
found_element = find_object element
if found_element != nil
begin
sleep(1)
found_element.send_keys(text)
rescue StandardError => myStandardError
put_log "\nERROR: *** #{myStandardError}"
end
else
put_log "\nERROR: *** not found object: #{element}"
exit
end
end
|
#find_object(string_object) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 10
def find_object string_object
string_object = string_object.gsub(/"/, "'")
locator_matching = /(.*?)(\{.*?\})/.match(string_object)
dyn_pros = {}
if locator_matching != nil
string_object = locator_matching[1]
eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
dyn_pros[k.to_s.upcase] = v
}
end
hash_object = $OBJECT[string_object]
puts hash_object
if hash_object == nil
put_log ">>> OBJECT NAME MAYBE NOT FOUND!!!"
true.should eq false
else
hash_object.each { |key, value|
$element_tag = key
$element_value = value
}
end
return selenium.find_element($element_tag, $element_value)
end
|
#launch_app ⇒ Object
214
215
216
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 214
def launch_app
selenium.launch
end
|
#long_press_on_coordinates(x, y) ⇒ Object
197
198
199
200
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 197
def long_press_on_coordinates(x, y)
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
action.perform
end
|
#long_press_on_coordinates_with_duration(x, y, duration) ⇒ Object
202
203
204
205
206
207
208
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 202
def long_press_on_coordinates_with_duration(x, y, duration)
duration = duration.to_i
duration = duration * 1000
puts duration
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
action.perform
end
|
#long_press_on_element_default_duration(element) ⇒ Object
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 161
def long_press_on_element_default_duration(element)
begin
ele_from = find_object element.location
x = ele_from.x
y = ele_from.y
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait(2000).move_to(x: "#{x}", y: "#{y}").release()
action.perform
rescue Exception => e
if e.to_s == 'The swipe did not complete successfully'
print ""
else
raise e
end
end
end
|
#long_press_on_element_with_duration(element, duration) ⇒ Object
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 178
def long_press_on_element_with_duration(element, duration)
begin
ele_from = find_object element.location
x = ele_from.x
y = ele_from.y
duration = duration.to_i
duration = duration * 1000
action = Appium::TouchAction.new.press(x: "#{x}", y: "#{y}").wait("#{duration}").move_to(x: "#{x}", y: "#{y}").release()
action.perform
rescue Exception => e
if e.to_s == 'The swipe did not complete successfully'
print ""
else
raise e
end
end
end
|
#move_home ⇒ Object
230
231
232
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 230
def move_home
selenium.key_event 3
end
|
#navigate(direction) ⇒ Object
method to navigate back & forward
115
116
117
118
119
120
121
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 115
def navigate(direction)
if direction == 'back'
selenium.navigate.back
else
selenium.navigate.forward
end
end
|
#put_log(str) ⇒ Object
6
7
8
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 6
def put_log str
puts str if $_CONFIG['Print Log'] == true
end
|
#replace_day(str) ⇒ Object
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/Ifd_Mobile/methods/lib_var.rb', line 37
def replace_day str
t = Time.now()
_day = t.day
if _day < 10
return str.gsub("{day}", "0#{_day.to_s}")
else
return str.gsub("{day}", "#{_day.to_s}")
end
return str
end
|
#replace_month(str) ⇒ Object
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/Ifd_Mobile/methods/lib_var.rb', line 26
def replace_month str
t = Time.now()
_month = t.month
if _month < 10
return str.gsub("{month}", "0#{_month.to_s}")
else
return str.gsub("{month}", "#{_month.to_s}")
end
return str
end
|
#replace_pipe(str_pipe) ⇒ Object
48
49
50
51
52
53
54
|
# File 'lib/Ifd_Mobile/methods/lib_var.rb', line 48
def replace_pipe str_pipe
put_log ">>>> #{str_pipe}"
if str_pipe =~ /^.*{pipe}.*$/
return str_pipe.gsub("{pipe}", "|")
end
return str_pipe
end
|
#replace_year(str) ⇒ Object
21
22
23
24
|
# File 'lib/Ifd_Mobile/methods/lib_var.rb', line 21
def replace_year str
t = Time.now()
return str.gsub("{year}", t.year.to_s)
end
|
#reset_app ⇒ Object
218
219
220
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 218
def reset_app
selenium.reset
end
|
#take_photo_android ⇒ Object
226
227
228
|
# File 'lib/Ifd_Mobile/methods/core.rb', line 226
def take_photo_android
system('adb shell input keyevent 27')
end
|
#var_collect(string_var) ⇒ Object
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/Ifd_Mobile/methods/lib_var.rb', line 1
def var_collect string_var
if string_var =~ /^.*{year}.*$/
string_var = replace_year(string_var)
end
if string_var =~ /^.*{month}.*$/
string_var = replace_month(string_var)
end
if string_var =~ /^.*{day}.*$/
string_var = replace_day(string_var)
end
if string_var =~ /^.*{store_value}.*$/
string_var = $context_value
end
return string_var
end
|