selenium-cucumber 2.1.4 → 3.1.4
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.
- checksums.yaml +4 -4
- data/bin/generate.rb +19 -20
- data/bin/helper.rb +50 -50
- data/bin/selenium-cucumber +29 -30
- data/doc/canned_steps.md +656 -656
- data/doc/installation.md +16 -16
- data/doc/selenium-cucumber-API.md +120 -120
- data/doc/selenium-cucumber-help.md +18 -18
- data/features-skeleton/my_first.feature +5 -5
- data/features-skeleton/step_definitions/custom_steps.rb +4 -4
- data/features-skeleton/support/env.rb +51 -51
- data/features-skeleton/support/hooks.rb +47 -38
- data/lib/selenium-cucumber.rb +1 -1
- data/lib/selenium-cucumber/assertion_steps.rb +89 -89
- data/lib/selenium-cucumber/click_elements_steps.rb +36 -36
- data/lib/selenium-cucumber/configuration_steps.rb +6 -6
- data/lib/selenium-cucumber/input_steps.rb +69 -69
- data/lib/selenium-cucumber/javascript_handling_steps.rb +9 -9
- data/lib/selenium-cucumber/methods/assertion_methods.rb +295 -344
- data/lib/selenium-cucumber/methods/click_elements_methods.rb +23 -23
- data/lib/selenium-cucumber/methods/configuration_methods.rb +35 -35
- data/lib/selenium-cucumber/methods/error_handling_methods.rb +86 -86
- data/lib/selenium-cucumber/methods/input_methods.rb +67 -67
- data/lib/selenium-cucumber/methods/javascript_handling_methods.rb +9 -9
- data/lib/selenium-cucumber/methods/misc_methods.rb +34 -34
- data/lib/selenium-cucumber/methods/mobile_methods.rb +241 -241
- data/lib/selenium-cucumber/methods/navigate_methods.rb +165 -165
- data/lib/selenium-cucumber/methods/progress_methods.rb +15 -15
- data/lib/selenium-cucumber/methods/required_files.rb +10 -10
- data/lib/selenium-cucumber/methods/screenshot_methods.rb +6 -6
- data/lib/selenium-cucumber/mobile_steps.rb +99 -99
- data/lib/selenium-cucumber/navigation_steps.rb +105 -105
- data/lib/selenium-cucumber/progress_steps.rb +18 -18
- data/lib/selenium-cucumber/screenshot_steps.rb +5 -5
- data/lib/selenium-cucumber/version.rb +5 -5
- metadata +69 -91
- data/example/android/android_app/HinduCalendar.zip +0 -0
- data/example/android/android_app/HinduCalendar/HinduCalendar.apk +0 -0
- data/example/android/android_app/HinduCalendar/README.md +0 -19
- data/example/android/android_app/HinduCalendar/Results.html +0 -472
- data/example/android/android_app/HinduCalendar/features/01_HC_homepage_menu_validation.feature +0 -36
- data/example/android/android_app/HinduCalendar/features/02_HC_homepage_menu_navigation.feature +0 -71
- data/example/android/android_app/HinduCalendar/features/03_HC_Create_Save_View_Delete_Kundali.feature +0 -63
- data/example/android/android_app/HinduCalendar/features/actual_images/test.png +0 -0
- data/example/android/android_app/HinduCalendar/features/expected_images/test.png +0 -0
- data/example/android/android_app/HinduCalendar/features/image_difference/test.png +0 -0
- data/example/android/android_app/HinduCalendar/features/my_first.feature +0 -1
- data/example/android/android_app/HinduCalendar/features/screenshots/test.png +0 -0
- data/example/android/android_app/HinduCalendar/features/step_definitions/01_HC_homepage_menu_validation.rb +0 -81
- data/example/android/android_app/HinduCalendar/features/step_definitions/02_HC_homepage_menu_navigation.rb +0 -132
- data/example/android/android_app/HinduCalendar/features/step_definitions/03_HC_Create_Save_View_Delete_Kundali.rb +0 -413
- data/example/android/android_app/HinduCalendar/features/step_definitions/custom_steps.rb +0 -5
- data/example/android/android_app/HinduCalendar/features/support/env.rb +0 -51
- data/example/android/android_app/HinduCalendar/features/support/hooks.rb +0 -38
- data/example/android/android_app/android_app_calculator.zip +0 -0
- data/example/android/android_app/android_app_calculator/AndroidCalculator.apk +0 -0
- data/example/android/android_app/android_app_calculator/features/actual_images/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/calculator.feature +0 -36
- data/example/android/android_app/android_app_calculator/features/expected_images/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/image_difference/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/my_first.feature +0 -13
- data/example/android/android_app/android_app_calculator/features/screenshots/test.png +0 -0
- data/example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb +0 -5
- data/example/android/android_app/android_app_calculator/features/support/env.rb +0 -51
- data/example/android/android_app/android_app_calculator/features/support/hooks.rb +0 -38
- data/example/android/android_web/android_web_gmail_login.zip +0 -0
- data/example/android/android_web/android_web_gmail_login/features/actual_images/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/expected_images/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/gmail_login.feature +0 -12
- data/example/android/android_web/android_web_gmail_login/features/image_difference/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/my_first.feature +0 -1
- data/example/android/android_web/android_web_gmail_login/features/screenshots/test.png +0 -0
- data/example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb +0 -5
- data/example/android/android_web/android_web_gmail_login/features/support/env.rb +0 -51
- data/example/android/android_web/android_web_gmail_login/features/support/hooks.rb +0 -38
- data/example/desktop web/desktop_web_gmail_login.zip +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/actual_images/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/expected_images/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/gmail_login.feature +0 -10
- data/example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature +0 -22
- data/example/desktop web/desktop_web_gmail_login/features/image_difference/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/my_first.feature +0 -1
- data/example/desktop web/desktop_web_gmail_login/features/result.html b/data/example/desktop → web/desktop_web_gmail_login/features/result.html +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/screenshots/test.png +0 -0
- data/example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb +0 -5
- data/example/desktop web/desktop_web_gmail_login/features/support/env.rb +0 -51
- data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +0 -38
- data/example/desktop web/desktop_web_gmail_login/result.html +0 -478
|
@@ -1,166 +1,166 @@
|
|
|
1
|
-
require_relative 'required_files'
|
|
2
|
-
|
|
3
|
-
# method to open link
|
|
4
|
-
def navigate_to(link)
|
|
5
|
-
$driver.get link
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
# method to navigate back & forword
|
|
9
|
-
def navigate(direction)
|
|
10
|
-
if direction == 'back'
|
|
11
|
-
$driver.navigate.back
|
|
12
|
-
else
|
|
13
|
-
$driver.navigate.forward
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# method to quite webdriver instance
|
|
18
|
-
def close_driver
|
|
19
|
-
$driver.quit
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# method to return key (control/command) by os wise
|
|
23
|
-
def get_key
|
|
24
|
-
os =
|
|
25
|
-
if os.to_s == '
|
|
26
|
-
return 'control'
|
|
27
|
-
elsif os.to_s == '
|
|
28
|
-
return 'command'
|
|
29
|
-
else
|
|
30
|
-
raise 'Invalid OS'
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
# Method to zoom in/out/reset page
|
|
35
|
-
def zoom_in_out(operation)
|
|
36
|
-
if $driver.capabilities.browser_name == 'chrome'
|
|
37
|
-
actual_zoom = $driver.execute_script "return document.body.style.zoom"
|
|
38
|
-
puts "actual_zoom:#{actual_zoom}"
|
|
39
|
-
if actual_zoom == '' or actual_zoom == nil
|
|
40
|
-
actual_zoom = 100
|
|
41
|
-
else
|
|
42
|
-
actual_zoom = actual_zoom.delete '%'
|
|
43
|
-
actual_zoom = actual_zoom.to_i
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
if operation == 'add'
|
|
47
|
-
actual_zoom += 15 unless actual_zoom >= 500
|
|
48
|
-
elsif operation == 'subtract'
|
|
49
|
-
actual_zoom -= 15 unless actual_zoom <= 25
|
|
50
|
-
else
|
|
51
|
-
actual_zoom = 100
|
|
52
|
-
end
|
|
53
|
-
puts "actual_zoom:#{actual_zoom}"
|
|
54
|
-
$driver.execute_script "document.body.style.zoom='#{actual_zoom}%'"
|
|
55
|
-
else
|
|
56
|
-
html = $driver.find_element(:tag_name => "body")
|
|
57
|
-
$driver.action.send_keys(html, :"#{get_key}", :"#{operation}" ).perform
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
# Method to zoom in/out web page until web element displyas
|
|
62
|
-
def zoom_in_out_till_element_display(access_type, operation, access_name)
|
|
63
|
-
while true
|
|
64
|
-
if WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }.displayed?
|
|
65
|
-
break
|
|
66
|
-
else
|
|
67
|
-
zoom_in_out(operation)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
# Method to resize browser
|
|
73
|
-
def resize_browser(width, heigth)
|
|
74
|
-
$driver.manage.window.resize_to(width, heigth)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
# Method to maximize browser
|
|
78
|
-
def maximize_browser
|
|
79
|
-
$driver.manage.window.maximize
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
# Method to hover on element
|
|
83
|
-
def hover_over_element(access_type, access_name)
|
|
84
|
-
element =
|
|
85
|
-
$driver.action.move_to(element).perform
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
# Method to scroll page to perticular element
|
|
89
|
-
def scroll_to_element(access_type, access_name)
|
|
90
|
-
ele_scroll =
|
|
91
|
-
ele_scroll.location_once_scrolled_into_view
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
# method to scroll page to top or end
|
|
95
|
-
def scroll_page(to)
|
|
96
|
-
if to == 'end'
|
|
97
|
-
$driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));')
|
|
98
|
-
elsif to == 'top'
|
|
99
|
-
$driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);')
|
|
100
|
-
else
|
|
101
|
-
raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")"
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# Method to switch to old window
|
|
106
|
-
def switch_to_previous_window
|
|
107
|
-
$driver.switch_to.window $previous_window
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
# Method to switch to new window
|
|
111
|
-
def switch_to_new_window
|
|
112
|
-
$previous_window = $driver.window_handle
|
|
113
|
-
$driver.switch_to.window($driver.window_handles.last)
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
# Method to switch to main window
|
|
117
|
-
def switch_to_main_window
|
|
118
|
-
$previous_window = $driver.window_handle
|
|
119
|
-
$driver.switch_to.window($driver.window_handles.first)
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
# Method to switch to window by title
|
|
123
|
-
def switch_to_window_by_title window_title
|
|
124
|
-
$previous_window = $driver.window_handle
|
|
125
|
-
window_found = false
|
|
126
|
-
$driver.window_handles.each{ |handle|
|
|
127
|
-
$driver.switch_to.window handle
|
|
128
|
-
if $driver.title == window_title
|
|
129
|
-
window_found = true
|
|
130
|
-
break
|
|
131
|
-
end
|
|
132
|
-
}
|
|
133
|
-
raise "Window having title \"#{window_title}\" not found" if not window_found
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
# Method to close new window
|
|
137
|
-
def close_new_window
|
|
138
|
-
$driver.close
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# method to switch frame
|
|
142
|
-
def switch_frame frame
|
|
143
|
-
$driver.switch_to.frame(frame)
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
# method to switch to main window
|
|
147
|
-
def switch_to_main_content
|
|
148
|
-
$driver.switch_to.default_content
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
=begin
|
|
152
|
-
def switch_to_new_window
|
|
153
|
-
win_handles = $driver.window_handles
|
|
154
|
-
|
|
155
|
-
puts $driver.title
|
|
156
|
-
puts win_handles.length
|
|
157
|
-
|
|
158
|
-
$driver.switch_to.window($driver.window_handles[1])
|
|
159
|
-
puts $driver.window_handles[1]
|
|
160
|
-
puts $driver.title
|
|
161
|
-
|
|
162
|
-
$driver.switch_to.window($driver.window_handles[2])
|
|
163
|
-
puts $driver.window_handles[2]
|
|
164
|
-
puts $driver.title
|
|
165
|
-
end
|
|
1
|
+
require_relative 'required_files'
|
|
2
|
+
|
|
3
|
+
# method to open link
|
|
4
|
+
def navigate_to(link)
|
|
5
|
+
$driver.get link
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
# method to navigate back & forword
|
|
9
|
+
def navigate(direction)
|
|
10
|
+
if direction == 'back'
|
|
11
|
+
$driver.navigate.back
|
|
12
|
+
else
|
|
13
|
+
$driver.navigate.forward
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# method to quite webdriver instance
|
|
18
|
+
def close_driver
|
|
19
|
+
$driver.quit
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# method to return key (control/command) by os wise
|
|
23
|
+
def get_key
|
|
24
|
+
os = $driver.capabilities.platform.to_s.upcase
|
|
25
|
+
if os.to_s == 'WINDOWS' || os.to_s == 'LINUX'
|
|
26
|
+
return 'control'
|
|
27
|
+
elsif os.to_s == 'DARWIN'
|
|
28
|
+
return 'command'
|
|
29
|
+
else
|
|
30
|
+
raise 'Invalid OS'
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Method to zoom in/out/reset page
|
|
35
|
+
def zoom_in_out(operation)
|
|
36
|
+
if $driver.capabilities.browser_name == 'chrome'
|
|
37
|
+
actual_zoom = $driver.execute_script "return document.body.style.zoom"
|
|
38
|
+
puts "actual_zoom:#{actual_zoom}"
|
|
39
|
+
if actual_zoom == '' or actual_zoom == nil
|
|
40
|
+
actual_zoom = 100
|
|
41
|
+
else
|
|
42
|
+
actual_zoom = actual_zoom.delete '%'
|
|
43
|
+
actual_zoom = actual_zoom.to_i
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
if operation == 'add'
|
|
47
|
+
actual_zoom += 15 unless actual_zoom >= 500
|
|
48
|
+
elsif operation == 'subtract'
|
|
49
|
+
actual_zoom -= 15 unless actual_zoom <= 25
|
|
50
|
+
else
|
|
51
|
+
actual_zoom = 100
|
|
52
|
+
end
|
|
53
|
+
puts "actual_zoom:#{actual_zoom}"
|
|
54
|
+
$driver.execute_script "document.body.style.zoom='#{actual_zoom}%'"
|
|
55
|
+
else
|
|
56
|
+
html = $driver.find_element(:tag_name => "body")
|
|
57
|
+
$driver.action.send_keys(html, :"#{get_key}", :"#{operation}" ).perform
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
# Method to zoom in/out web page until web element displyas
|
|
62
|
+
def zoom_in_out_till_element_display(access_type, operation, access_name)
|
|
63
|
+
while true
|
|
64
|
+
if WAIT.until { $driver.find_element(:"#{access_type}" => "#{access_name}") }.displayed?
|
|
65
|
+
break
|
|
66
|
+
else
|
|
67
|
+
zoom_in_out(operation)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
# Method to resize browser
|
|
73
|
+
def resize_browser(width, heigth)
|
|
74
|
+
$driver.manage.window.resize_to(width, heigth)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Method to maximize browser
|
|
78
|
+
def maximize_browser
|
|
79
|
+
$driver.manage.window.maximize
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Method to hover on element
|
|
83
|
+
def hover_over_element(access_type, access_name)
|
|
84
|
+
element = $driver.find_element(:"#{access_type}" => "#{access_name}")
|
|
85
|
+
$driver.action.move_to(element).perform
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Method to scroll page to perticular element
|
|
89
|
+
def scroll_to_element(access_type, access_name)
|
|
90
|
+
ele_scroll = $driver.find_element(:"#{access_type}" => "#{access_name}")
|
|
91
|
+
ele_scroll.location_once_scrolled_into_view
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# method to scroll page to top or end
|
|
95
|
+
def scroll_page(to)
|
|
96
|
+
if to == 'end'
|
|
97
|
+
$driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));')
|
|
98
|
+
elsif to == 'top'
|
|
99
|
+
$driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);')
|
|
100
|
+
else
|
|
101
|
+
raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")"
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Method to switch to old window
|
|
106
|
+
def switch_to_previous_window
|
|
107
|
+
$driver.switch_to.window $previous_window
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Method to switch to new window
|
|
111
|
+
def switch_to_new_window
|
|
112
|
+
$previous_window = $driver.window_handle
|
|
113
|
+
$driver.switch_to.window($driver.window_handles.last)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# Method to switch to main window
|
|
117
|
+
def switch_to_main_window
|
|
118
|
+
$previous_window = $driver.window_handle
|
|
119
|
+
$driver.switch_to.window($driver.window_handles.first)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Method to switch to window by title
|
|
123
|
+
def switch_to_window_by_title window_title
|
|
124
|
+
$previous_window = $driver.window_handle
|
|
125
|
+
window_found = false
|
|
126
|
+
$driver.window_handles.each{ |handle|
|
|
127
|
+
$driver.switch_to.window handle
|
|
128
|
+
if $driver.title == window_title
|
|
129
|
+
window_found = true
|
|
130
|
+
break
|
|
131
|
+
end
|
|
132
|
+
}
|
|
133
|
+
raise "Window having title \"#{window_title}\" not found" if not window_found
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# Method to close new window
|
|
137
|
+
def close_new_window
|
|
138
|
+
$driver.close
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# method to switch frame
|
|
142
|
+
def switch_frame frame
|
|
143
|
+
$driver.switch_to.frame(frame)
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
# method to switch to main window
|
|
147
|
+
def switch_to_main_content
|
|
148
|
+
$driver.switch_to.default_content
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
=begin
|
|
152
|
+
def switch_to_new_window
|
|
153
|
+
win_handles = $driver.window_handles
|
|
154
|
+
|
|
155
|
+
puts $driver.title
|
|
156
|
+
puts win_handles.length
|
|
157
|
+
|
|
158
|
+
$driver.switch_to.window($driver.window_handles[1])
|
|
159
|
+
puts $driver.window_handles[1]
|
|
160
|
+
puts $driver.title
|
|
161
|
+
|
|
162
|
+
$driver.switch_to.window($driver.window_handles[2])
|
|
163
|
+
puts $driver.window_handles[2]
|
|
164
|
+
puts $driver.title
|
|
165
|
+
end
|
|
166
166
|
=end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
require_relative 'required_files'
|
|
2
|
-
|
|
3
|
-
def wait(time)
|
|
4
|
-
sleep time.to_i
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
def wait_for_element_to_display(access_type, access_name, duration)
|
|
8
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i) # seconds
|
|
9
|
-
wait.until { $driver.find_element(:"#{access_type}" => "#{access_name}").displayed? }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def wait_for_element_to_enable(access_type, access_name, duration)
|
|
13
|
-
wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i) # seconds
|
|
14
|
-
wait.until { $driver.find_element(:"#{access_type}" => "#{access_name}").enabled? }
|
|
15
|
-
end
|
|
1
|
+
require_relative 'required_files'
|
|
2
|
+
|
|
3
|
+
def wait(time)
|
|
4
|
+
sleep time.to_i
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def wait_for_element_to_display(access_type, access_name, duration)
|
|
8
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i) # seconds
|
|
9
|
+
wait.until { $driver.find_element(:"#{access_type}" => "#{access_name}").displayed? }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def wait_for_element_to_enable(access_type, access_name, duration)
|
|
13
|
+
wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i) # seconds
|
|
14
|
+
wait.until { $driver.find_element(:"#{access_type}" => "#{access_name}").enabled? }
|
|
15
|
+
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
require 'rubygems'
|
|
2
|
-
require 'selenium-webdriver'
|
|
3
|
-
require 'chunky_png'
|
|
4
|
-
require 'open-uri'
|
|
5
|
-
require 'rbconfig'
|
|
6
|
-
require 'appium_lib'
|
|
7
|
-
include RbConfig
|
|
8
|
-
|
|
9
|
-
require_relative 'misc_methods'
|
|
10
|
-
require_relative 'error_handling_methods'
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'selenium-webdriver'
|
|
3
|
+
require 'chunky_png'
|
|
4
|
+
require 'open-uri'
|
|
5
|
+
require 'rbconfig'
|
|
6
|
+
require 'appium_lib'
|
|
7
|
+
include RbConfig
|
|
8
|
+
|
|
9
|
+
require_relative 'misc_methods'
|
|
10
|
+
require_relative 'error_handling_methods'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
require_relative 'required_files'
|
|
2
|
-
|
|
3
|
-
def take_screenshot
|
|
4
|
-
cur_time = Time.now.strftime('%Y%m%d%H%M%S%L')
|
|
5
|
-
$driver.save_screenshot('./features/screenshots/screenshot' + cur_time + '.png')
|
|
6
|
-
end
|
|
1
|
+
require_relative 'required_files'
|
|
2
|
+
|
|
3
|
+
def take_screenshot
|
|
4
|
+
cur_time = Time.now.strftime('%Y%m%d%H%M%S%L')
|
|
5
|
+
$driver.save_screenshot('./features/screenshots/screenshot' + cur_time + '.png')
|
|
6
|
+
end
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
require_relative 'methods/mobile_methods'
|
|
2
|
-
require_relative 'methods/navigate_methods'
|
|
3
|
-
|
|
4
|
-
#---------- swipe with elements
|
|
5
|
-
Then(/^I swipe from element having (.+) "(.*?)" to element having (.+) "(.*?)"$/) do |type1,access_name1,type2,access_name2|
|
|
6
|
-
validate_locator type1
|
|
7
|
-
validate_locator type2
|
|
8
|
-
swipe_using_elements(type1,access_name1,type2,access_name2)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
#---------- swipe with co-ordinates
|
|
12
|
-
Then(/^I swipe from co\-ordinates "(.*?)","(.*?)" to co\-ordinates "(.*?)","(.*?)"$/) do |start_x, start_y, end_x, end_y|
|
|
13
|
-
swipe(start_x, start_y, end_x, end_y)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
#---------- Swipe with direction
|
|
17
|
-
Then(/^I swipe left$/) do
|
|
18
|
-
swipe_direction("left")
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
Then(/^I swipe right$/) do
|
|
22
|
-
swipe_direction("right")
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
Then(/^I swipe up$/) do
|
|
26
|
-
swipe_direction("up")
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
Then(/^I swipe down$/) do
|
|
30
|
-
swipe_direction("down")
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
#----------- Swipe element with direction
|
|
34
|
-
Then(/^I swipe element having (.+) "(.*?)" to right$/) do |type, access_name|
|
|
35
|
-
validate_locator type
|
|
36
|
-
swipe_element_with_direction(type, access_name, "right")
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
Then(/^I swipe element having (.+) "(.*?)" to left$/) do |type, access_name|
|
|
40
|
-
swipe_element_with_direction(type, access_name, "left")
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
Then(/^I swipe element having (.+) "(.*?)" to up$/) do |type, access_name|
|
|
44
|
-
swipe_element_with_direction(type, access_name, "up")
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
Then(/^I swipe element having (.+) "(.*?)" to down$/) do |type, access_name|
|
|
48
|
-
swipe_element_with_direction(type, access_name, "down")
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
#swipe co-ordinates with direction
|
|
52
|
-
|
|
53
|
-
Then(/^I swipe co\-ordinates "(.*?)","(.*?)" to left$/) do |start_x, start_y|
|
|
54
|
-
swipe_coordinates_with_direction(start_x, start_y, "left")
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
Then(/^I swipe co\-ordinates "(.*?)","(.*?)" to right$/) do |start_x, start_y|
|
|
59
|
-
swipe_coordinates_with_direction(start_x, start_y, "right")
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
Then(/^I swipe co\-ordinates "(.*?)","(.*?)" to up$/) do |start_x, start_y|
|
|
64
|
-
swipe_coordinates_with_direction(start_x, start_y, "up")
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Then(/^I swipe co\-ordinates "(.*?)","(.*?)" to down$/) do |start_x, start_y|
|
|
69
|
-
swipe_coordinates_with_direction(start_x, start_y, "down")
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
Then(/^I long tap on element having (.+) "(.*?)"$/) do |type, access_name|
|
|
73
|
-
validate_locator type
|
|
74
|
-
long_press_on_element_default_duration(type, access_name)
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
Then(/^I long tap on element having (.+) "(.*?)" for "(.*?)" sec$/) do |type, access_name, duration|
|
|
78
|
-
validate_locator type
|
|
79
|
-
long_press_on_element_with_duration(type, access_name, duration)
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
Then(/^I long tap on co\-ordinate "(.*?)","(.*?)"$/) do |x, y|
|
|
83
|
-
long_press_on_coordinates(x, y)
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
Then(/^I long tap on co\-ordinate "(.*?)","(.*?)" for "(.*?)" sec$/) do |x, y, duration|
|
|
87
|
-
long_press_on_coordinates_with_duration(x, y, duration)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
Then(/^I close app$/) do
|
|
91
|
-
close_app
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
Then(/^I tap on back button of device$/) do
|
|
95
|
-
navigate('back')
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
Then(/^I press back button of device$/) do
|
|
99
|
-
navigate('back')
|
|
1
|
+
require_relative 'methods/mobile_methods'
|
|
2
|
+
require_relative 'methods/navigate_methods'
|
|
3
|
+
|
|
4
|
+
#---------- swipe with elements
|
|
5
|
+
Then(/^I swipe from element having (.+) "(.*?)" to element having (.+) "(.*?)"$/) do |type1,access_name1,type2,access_name2|
|
|
6
|
+
validate_locator type1
|
|
7
|
+
validate_locator type2
|
|
8
|
+
swipe_using_elements(type1,access_name1,type2,access_name2)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
#---------- swipe with co-ordinates
|
|
12
|
+
Then(/^I swipe from co\-ordinates "(.*?)","(.*?)" to co\-ordinates "(.*?)","(.*?)"$/) do |start_x, start_y, end_x, end_y|
|
|
13
|
+
swipe(start_x, start_y, end_x, end_y)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
#---------- Swipe with direction
|
|
17
|
+
Then(/^I swipe left$/) do
|
|
18
|
+
swipe_direction("left")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Then(/^I swipe right$/) do
|
|
22
|
+
swipe_direction("right")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Then(/^I swipe up$/) do
|
|
26
|
+
swipe_direction("up")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
Then(/^I swipe down$/) do
|
|
30
|
+
swipe_direction("down")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
#----------- Swipe element with direction
|
|
34
|
+
Then(/^I swipe element having (.+) "(.*?)" to right$/) do |type, access_name|
|
|
35
|
+
validate_locator type
|
|
36
|
+
swipe_element_with_direction(type, access_name, "right")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
Then(/^I swipe element having (.+) "(.*?)" to left$/) do |type, access_name|
|
|
40
|
+
swipe_element_with_direction(type, access_name, "left")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
Then(/^I swipe element having (.+) "(.*?)" to up$/) do |type, access_name|
|
|
44
|
+
swipe_element_with_direction(type, access_name, "up")
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
Then(/^I swipe element having (.+) "(.*?)" to down$/) do |type, access_name|
|
|
48
|
+
swipe_element_with_direction(type, access_name, "down")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
#swipe co-ordinates with direction
|
|
52
|
+
|
|
53
|
+
Then(/^I swipe co\-ordinates "(.*?)","(.*?)" to left$/) do |start_x, start_y|
|
|
54
|
+
swipe_coordinates_with_direction(start_x, start_y, "left")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
Then(/^I swipe co\-ordinates "(.*?)","(.*?)" to right$/) do |start_x, start_y|
|
|
59
|
+
swipe_coordinates_with_direction(start_x, start_y, "right")
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Then(/^I swipe co\-ordinates "(.*?)","(.*?)" to up$/) do |start_x, start_y|
|
|
64
|
+
swipe_coordinates_with_direction(start_x, start_y, "up")
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
Then(/^I swipe co\-ordinates "(.*?)","(.*?)" to down$/) do |start_x, start_y|
|
|
69
|
+
swipe_coordinates_with_direction(start_x, start_y, "down")
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
Then(/^I long tap on element having (.+) "(.*?)"$/) do |type, access_name|
|
|
73
|
+
validate_locator type
|
|
74
|
+
long_press_on_element_default_duration(type, access_name)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
Then(/^I long tap on element having (.+) "(.*?)" for "(.*?)" sec$/) do |type, access_name, duration|
|
|
78
|
+
validate_locator type
|
|
79
|
+
long_press_on_element_with_duration(type, access_name, duration)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
Then(/^I long tap on co\-ordinate "(.*?)","(.*?)"$/) do |x, y|
|
|
83
|
+
long_press_on_coordinates(x, y)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
Then(/^I long tap on co\-ordinate "(.*?)","(.*?)" for "(.*?)" sec$/) do |x, y, duration|
|
|
87
|
+
long_press_on_coordinates_with_duration(x, y, duration)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
Then(/^I close app$/) do
|
|
91
|
+
close_app
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
Then(/^I tap on back button of device$/) do
|
|
95
|
+
navigate('back')
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
Then(/^I press back button of device$/) do
|
|
99
|
+
navigate('back')
|
|
100
100
|
end
|