Ifd_Mobile 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/Ifd_Mobile/lib_web.rb +118 -106
- data/lib/Ifd_Mobile/methods/IFD_Assertion.rb +44 -44
- data/lib/Ifd_Mobile/methods/core.rb +243 -231
- data/lib/Ifd_Mobile/methods/lib_var.rb +53 -53
- data/lib/Ifd_Mobile/version.rb +5 -5
- data/project/Gemfile +9 -9
- data/project/apps/TestApp/Test App 2/GestureTestViewController.h +18 -18
- data/project/apps/TestApp/Test App 2/GestureTestViewController.m +48 -48
- data/project/apps/TestApp/Test App 2/GestureTestViewController.xib +46 -46
- data/project/apps/TestApp/Test App 2/MyViewControllerViewController.h +42 -42
- data/project/apps/TestApp/Test App 2/MyViewControllerViewController.m +193 -193
- data/project/apps/TestApp/Test App 2/TA2AppDelegate.h +28 -28
- data/project/apps/TestApp/Test App 2/TA2AppDelegate.m +85 -85
- data/project/apps/TestApp/Test App 2/TestApp-Info.plist +40 -40
- data/project/apps/TestApp/Test App 2/TestApp-Prefix.pch +29 -29
- data/project/apps/TestApp/Test App 2/en.lproj/InfoPlist.strings +21 -21
- data/project/apps/TestApp/Test App 2/en.lproj/MyViewControllerViewController.xib +175 -175
- data/project/apps/TestApp/Test App 2/main.m +31 -31
- data/project/apps/TestApp/TestApp.xcodeproj/project.pbxproj +336 -336
- data/project/apps/TestApp/TestApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -7
- data/project/apps/TestApp/TestApp.xcodeproj/xcuserdata/anhpham.xcuserdatad/xcschemes/TestApp.xcscheme +88 -88
- data/project/apps/TestApp/TestApp.xcodeproj/xcuserdata/anhpham.xcuserdatad/xcschemes/xcschememanagement.plist +22 -22
- data/project/features/android/Android_test1.feature +14 -14
- data/project/features/android/Android_test2.feature +14 -14
- data/project/features/iOS/iOS_test.feature +15 -17
- data/project/features/step_definitions/lib_steps/PolyClaim_homepage.rb +2 -2
- data/project/features/step_definitions/lib_steps/PolyClaim_loginpage.rb +3 -3
- data/project/features/step_definitions/repositories/android_ob_test.rb +9 -9
- data/project/features/step_definitions/repositories/ios_ob_test.rb +6 -6
- data/project/features/support/env.rb +36 -36
- data/project/features/support/hooks.rb +8 -8
- data/project/features/support/project_env.rb +42 -42
- metadata +40 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29531fda5bb58f537c262d4fe275c5cbdb03390f
|
4
|
+
data.tar.gz: e1a423ebe2eca1d54734de37e45f46e7c1888f59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 210a2948c239bb7edd134f68ca46df26c53fea6fe4726f4e1d725c752f275289afa42111b4601078b96d8d2a872a3738be3a1fb87b35e62c15f80f808db65494
|
7
|
+
data.tar.gz: 123f938ce4cd4f9bc8e992011698e08257d5938e926b90321f7f1e943cc242e4133a018a4fa27752a6375f88835d4eb201a4044815e7ad75e51330595d2297c9
|
data/lib/Ifd_Mobile/lib_web.rb
CHANGED
@@ -1,106 +1,118 @@
|
|
1
|
-
require_relative 'methods/required_files'
|
2
|
-
|
3
|
-
Given(/^I have App running with appium$/) do
|
4
|
-
# Make sure you have started appium server
|
5
|
-
end
|
6
|
-
|
7
|
-
# Wait for the specific time
|
8
|
-
When /^I wait for (\d+) seconds$/ do |second|
|
9
|
-
sleep(second.to_i)
|
10
|
-
end
|
11
|
-
|
12
|
-
And /^I input text "(.*)" on "(.*)"$/ do |text,object|
|
13
|
-
execute_settext(object,text)
|
14
|
-
end
|
15
|
-
|
16
|
-
And /^I click on "(.*)"$/ do |object|
|
17
|
-
execute_click object
|
18
|
-
end
|
19
|
-
|
20
|
-
Then /^I verify property "(.*)" with "(.*)" has( | not)? value "(.*)"$/ do |object, property, negate, value|
|
21
|
-
sleep(0.5)
|
22
|
-
value = var_collect(value)
|
23
|
-
execute_checkproperty(object, property, negate, value)
|
24
|
-
end
|
25
|
-
|
26
|
-
Given /^I click on element with x: "(.*)", y: "(.*)"$/ do |x,y|
|
27
|
-
click_by_coordinate x,y
|
28
|
-
end
|
29
|
-
|
30
|
-
And /^I scroll the screen from startX (\d+) startY (\d+) to endX (\d+) endY (\d+) and millisecond timeout is (\d+)$/ do |startX, startY, endX, endY, timeout|
|
31
|
-
selenium.swipe(startX:startX, startY:startY, endX:endX,endY:endY, duration:timeout)
|
32
|
-
end
|
33
|
-
|
34
|
-
Given /^I get attribute of element "(.*)"$/ do |element|
|
35
|
-
found_element = find_object element
|
36
|
-
actual_value = found_element.attribute("name")
|
37
|
-
puts actual_value
|
38
|
-
end
|
39
|
-
|
40
|
-
And /^I rotate device to (landscape|portrait)$/ do |type|
|
41
|
-
case type.to_sym
|
42
|
-
when :landscape
|
43
|
-
$driver.rotate :landscape
|
44
|
-
when :portrait
|
45
|
-
$driver.rotate :portrait
|
46
|
-
else
|
47
|
-
raise "ERROR: *** unknown rotate type"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
And /^I accept alert$/ do
|
52
|
-
selenium.alert_accept
|
53
|
-
end
|
54
|
-
|
55
|
-
And /^I dismiss alert$/ do
|
56
|
-
selenium.alert_dismiss
|
57
|
-
end
|
58
|
-
|
59
|
-
And /^I hide the keyboard$/ do
|
60
|
-
selenium.hide_keyboard
|
61
|
-
end
|
62
|
-
|
63
|
-
And /^I delete an character$/ do
|
64
|
-
system('adb shell input keyevent 67')
|
65
|
-
end
|
66
|
-
|
67
|
-
Then(/^I tap on back button of device$/) do
|
68
|
-
navigate('back')
|
69
|
-
end
|
70
|
-
|
71
|
-
Then(/^I tap on forward button of device$/) do
|
72
|
-
navigate('forward')
|
73
|
-
end
|
74
|
-
|
75
|
-
#---------- Swipe with direction
|
76
|
-
Then(/^I swipe left$/) do
|
77
|
-
swipe_direction("left")
|
78
|
-
end
|
79
|
-
|
80
|
-
Then(/^I swipe right$/) do
|
81
|
-
swipe_direction("right")
|
82
|
-
end
|
83
|
-
|
84
|
-
Then(/^I swipe up$/) do
|
85
|
-
swipe_direction("up")
|
86
|
-
end
|
87
|
-
|
88
|
-
Then(/^I swipe down$/) do
|
89
|
-
swipe_direction("down")
|
90
|
-
end
|
91
|
-
|
92
|
-
Then(/^I long tap on element having "(.*?)"$/) do |element|
|
93
|
-
long_press_on_element_default_duration(element)
|
94
|
-
end
|
95
|
-
|
96
|
-
Then(/^I long tap on element having (.+) "(.*?)" for "(.*?)" sec$/) do |element, duration|
|
97
|
-
long_press_on_element_with_duration(element, duration)
|
98
|
-
end
|
99
|
-
|
100
|
-
Then(/^I long tap on co\-ordinate "(.*?)","(.*?)"$/) do |x, y|
|
101
|
-
long_press_on_coordinates(x, y)
|
102
|
-
end
|
103
|
-
|
104
|
-
Then(/^I long tap on co\-ordinate "(.*?)","(.*?)" for "(.*?)" sec$/) do |x, y, duration|
|
105
|
-
long_press_on_coordinates_with_duration(x, y, duration)
|
106
|
-
end
|
1
|
+
require_relative 'methods/required_files'
|
2
|
+
|
3
|
+
Given(/^I have App running with appium$/) do
|
4
|
+
# Make sure you have started appium server
|
5
|
+
end
|
6
|
+
|
7
|
+
# Wait for the specific time
|
8
|
+
When /^I wait for (\d+) seconds$/ do |second|
|
9
|
+
sleep(second.to_i)
|
10
|
+
end
|
11
|
+
|
12
|
+
And /^I input text "(.*)" on "(.*)"$/ do |text,object|
|
13
|
+
execute_settext(object,text)
|
14
|
+
end
|
15
|
+
|
16
|
+
And /^I click on "(.*)"$/ do |object|
|
17
|
+
execute_click object
|
18
|
+
end
|
19
|
+
|
20
|
+
Then /^I verify property "(.*)" with "(.*)" has( | not)? value "(.*)"$/ do |object, property, negate, value|
|
21
|
+
sleep(0.5)
|
22
|
+
value = var_collect(value)
|
23
|
+
execute_checkproperty(object, property, negate, value)
|
24
|
+
end
|
25
|
+
|
26
|
+
Given /^I click on element with x: "(.*)", y: "(.*)"$/ do |x,y|
|
27
|
+
click_by_coordinate x,y
|
28
|
+
end
|
29
|
+
|
30
|
+
And /^I scroll the screen from startX (\d+) startY (\d+) to endX (\d+) endY (\d+) and millisecond timeout is (\d+)$/ do |startX, startY, endX, endY, timeout|
|
31
|
+
selenium.swipe(startX:startX, startY:startY, endX:endX,endY:endY, duration:timeout)
|
32
|
+
end
|
33
|
+
|
34
|
+
Given /^I get attribute of element "(.*)"$/ do |element|
|
35
|
+
found_element = find_object element
|
36
|
+
actual_value = found_element.attribute("name")
|
37
|
+
puts actual_value
|
38
|
+
end
|
39
|
+
|
40
|
+
And /^I rotate device to (landscape|portrait)$/ do |type|
|
41
|
+
case type.to_sym
|
42
|
+
when :landscape
|
43
|
+
$driver.rotate :landscape
|
44
|
+
when :portrait
|
45
|
+
$driver.rotate :portrait
|
46
|
+
else
|
47
|
+
raise "ERROR: *** unknown rotate type"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
And /^I accept alert$/ do
|
52
|
+
selenium.alert_accept
|
53
|
+
end
|
54
|
+
|
55
|
+
And /^I dismiss alert$/ do
|
56
|
+
selenium.alert_dismiss
|
57
|
+
end
|
58
|
+
|
59
|
+
And /^I hide the keyboard$/ do
|
60
|
+
selenium.hide_keyboard
|
61
|
+
end
|
62
|
+
|
63
|
+
And /^I delete an character$/ do
|
64
|
+
system('adb shell input keyevent 67')
|
65
|
+
end
|
66
|
+
|
67
|
+
Then(/^I tap on back button of device$/) do
|
68
|
+
navigate('back')
|
69
|
+
end
|
70
|
+
|
71
|
+
Then(/^I tap on forward button of device$/) do
|
72
|
+
navigate('forward')
|
73
|
+
end
|
74
|
+
|
75
|
+
#---------- Swipe with direction
|
76
|
+
Then(/^I swipe left$/) do
|
77
|
+
swipe_direction("left")
|
78
|
+
end
|
79
|
+
|
80
|
+
Then(/^I swipe right$/) do
|
81
|
+
swipe_direction("right")
|
82
|
+
end
|
83
|
+
|
84
|
+
Then(/^I swipe up$/) do
|
85
|
+
swipe_direction("up")
|
86
|
+
end
|
87
|
+
|
88
|
+
Then(/^I swipe down$/) do
|
89
|
+
swipe_direction("down")
|
90
|
+
end
|
91
|
+
|
92
|
+
Then(/^I long tap on element having "(.*?)"$/) do |element|
|
93
|
+
long_press_on_element_default_duration(element)
|
94
|
+
end
|
95
|
+
|
96
|
+
Then(/^I long tap on element having (.+) "(.*?)" for "(.*?)" sec$/) do |element, duration|
|
97
|
+
long_press_on_element_with_duration(element, duration)
|
98
|
+
end
|
99
|
+
|
100
|
+
Then(/^I long tap on co\-ordinate "(.*?)","(.*?)"$/) do |x, y|
|
101
|
+
long_press_on_coordinates(x, y)
|
102
|
+
end
|
103
|
+
|
104
|
+
Then(/^I long tap on co\-ordinate "(.*?)","(.*?)" for "(.*?)" sec$/) do |x, y, duration|
|
105
|
+
long_press_on_coordinates_with_duration(x, y, duration)
|
106
|
+
end
|
107
|
+
|
108
|
+
Then(/^I close app$/) do
|
109
|
+
close_app
|
110
|
+
end
|
111
|
+
|
112
|
+
Then(/^I launch app$/) do
|
113
|
+
launch_app
|
114
|
+
end
|
115
|
+
|
116
|
+
Then(/^I reset app$/) do
|
117
|
+
reset_app
|
118
|
+
end
|
@@ -1,44 +1,44 @@
|
|
1
|
-
# include Test::Unit::Assertions
|
2
|
-
class IFD_Assertion
|
3
|
-
# Assert 2 values
|
4
|
-
def self.reg_compare sActual, regValue, isSpecialChar=false
|
5
|
-
begin
|
6
|
-
if !isSpecialChar
|
7
|
-
sActual = sActual.strip
|
8
|
-
regValue = regValue.strip.gsub("[", "\\[").gsub("]", "\\]").gsub("(", "\\(").gsub(")", "\\)").gsub(">", "\\>")
|
9
|
-
end
|
10
|
-
rescue StandardError => myStandardError
|
11
|
-
put_log "\n>>> Error: #{myStandardError}"
|
12
|
-
end
|
13
|
-
|
14
|
-
# put_log "\nsActual:#{sActual}, regValue:#{regValue}"
|
15
|
-
if ((sActual.nil? and regValue.nil?) or (!sActual.nil? and sActual.empty? and !regValue.nil? and regValue.empty?))
|
16
|
-
return true
|
17
|
-
end
|
18
|
-
|
19
|
-
if ((sActual.nil? and !regValue.nil?) or (!sActual.nil? and regValue.nil?))
|
20
|
-
return false
|
21
|
-
end
|
22
|
-
|
23
|
-
if (!sActual.nil? and !sActual.empty?)
|
24
|
-
sCookActual = sActual.gsub(/\n|\r/, " ")
|
25
|
-
if (sCookActual == regValue or (isSpecialChar and sCookActual.include? regValue) or (!isSpecialChar and sCookActual =~ /^.*#{regValue}.*$/))
|
26
|
-
return true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
return false
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.assert_string_contain(expected, actual)
|
34
|
-
unless (actual.to_s).include? (expected.to_s)
|
35
|
-
raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def self.assert_string_equal(expected, actual)
|
40
|
-
if expected.to_s != actual.to_s
|
41
|
-
raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
1
|
+
# include Test::Unit::Assertions
|
2
|
+
class IFD_Assertion
|
3
|
+
# Assert 2 values
|
4
|
+
def self.reg_compare sActual, regValue, isSpecialChar=false
|
5
|
+
begin
|
6
|
+
if !isSpecialChar
|
7
|
+
sActual = sActual.strip
|
8
|
+
regValue = regValue.strip.gsub("[", "\\[").gsub("]", "\\]").gsub("(", "\\(").gsub(")", "\\)").gsub(">", "\\>")
|
9
|
+
end
|
10
|
+
rescue StandardError => myStandardError
|
11
|
+
put_log "\n>>> Error: #{myStandardError}"
|
12
|
+
end
|
13
|
+
|
14
|
+
# put_log "\nsActual:#{sActual}, regValue:#{regValue}"
|
15
|
+
if ((sActual.nil? and regValue.nil?) or (!sActual.nil? and sActual.empty? and !regValue.nil? and regValue.empty?))
|
16
|
+
return true
|
17
|
+
end
|
18
|
+
|
19
|
+
if ((sActual.nil? and !regValue.nil?) or (!sActual.nil? and regValue.nil?))
|
20
|
+
return false
|
21
|
+
end
|
22
|
+
|
23
|
+
if (!sActual.nil? and !sActual.empty?)
|
24
|
+
sCookActual = sActual.gsub(/\n|\r/, " ")
|
25
|
+
if (sCookActual == regValue or (isSpecialChar and sCookActual.include? regValue) or (!isSpecialChar and sCookActual =~ /^.*#{regValue}.*$/))
|
26
|
+
return true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
return false
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.assert_string_contain(expected, actual)
|
34
|
+
unless (actual.to_s).include? (expected.to_s)
|
35
|
+
raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.assert_string_equal(expected, actual)
|
40
|
+
if expected.to_s != actual.to_s
|
41
|
+
raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -1,232 +1,244 @@
|
|
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
|
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
|
+
$driver.close_app
|
236
|
+
end
|
237
|
+
|
238
|
+
def launch_app
|
239
|
+
$driver.launch_app
|
240
|
+
end
|
241
|
+
|
242
|
+
def reset_app
|
243
|
+
$driver.reset
|
232
244
|
end
|