itms_automation 2.5 → 2.5.6

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 (75) hide show
  1. checksums.yaml +4 -4
  2. data/bin/generate.rb +3 -37
  3. data/bin/helper.rb +23 -10
  4. data/bin/itms_automation +18 -23
  5. data/doc/installation.md +16 -0
  6. data/doc/itms-automation-API.md +103 -0
  7. data/doc/itms-automation-help.md +18 -0
  8. data/example/android/android_app/android_app_calculator.zip +0 -0
  9. data/example/android/android_app/android_app_calculator/AndroidCalculator.apk +0 -0
  10. data/example/android/android_app/android_app_calculator/features/calculator.feature +36 -0
  11. data/example/android/android_app/android_app_calculator/features/my_first.feature +13 -0
  12. data/example/android/android_app/android_app_calculator/features/screenshots/test.png +0 -0
  13. data/example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb +5 -0
  14. data/example/android/android_app/android_app_calculator/features/support/env.rb +52 -0
  15. data/example/android/android_app/android_app_calculator/features/support/hooks.rb +26 -0
  16. data/example/android/android_web/android_web_gmail_login.zip +0 -0
  17. data/example/android/android_web/android_web_gmail_login/features/gmail_login.feature +12 -0
  18. data/example/android/android_web/android_web_gmail_login/features/my_first.feature +1 -0
  19. data/example/android/android_web/android_web_gmail_login/features/screenshots/test.png +0 -0
  20. data/example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
  21. data/example/android/android_web/android_web_gmail_login/features/support/env.rb +51 -0
  22. data/example/android/android_web/android_web_gmail_login/features/support/hooks.rb +27 -0
  23. data/example/desktop web/desktop_web_gmail_login.zip +0 -0
  24. data/example/desktop web/desktop_web_gmail_login/features/gmail_login.feature +9 -0
  25. data/example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature +21 -0
  26. data/example/desktop web/desktop_web_gmail_login/features/my_first.feature +1 -0
  27. data/example/desktop web/desktop_web_gmail_login/features/screenshots/test.png +0 -0
  28. data/example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb +5 -0
  29. data/example/desktop web/desktop_web_gmail_login/features/support/env.rb +51 -0
  30. data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +26 -0
  31. data/features-skeleton/my_first.feature +5 -0
  32. data/features-skeleton/screenshots/test.png +0 -0
  33. data/features-skeleton/step_definitions/custom_steps.rb +5 -0
  34. data/features-skeleton/support/env.rb +104 -0
  35. data/features-skeleton/support/hooks.rb +74 -0
  36. data/lib/itms_automation.rb +1 -3
  37. data/lib/itms_automation/assertion_steps.rb +68 -0
  38. data/lib/itms_automation/click_elements_steps.rb +24 -0
  39. data/lib/itms_automation/configuration_steps.rb +7 -0
  40. data/lib/itms_automation/input_steps.rb +59 -0
  41. data/lib/itms_automation/javascript_handling_steps.rb +10 -0
  42. data/lib/itms_automation/methods/assertion_methods.rb +344 -0
  43. data/lib/itms_automation/methods/click_elements_methods.rb +23 -0
  44. data/lib/itms_automation/methods/configuration_methods.rb +35 -0
  45. data/lib/itms_automation/methods/error_handling_methods.rb +87 -0
  46. data/lib/itms_automation/methods/input_methods.rb +69 -0
  47. data/lib/itms_automation/methods/javascript_handling_methods.rb +9 -0
  48. data/lib/itms_automation/methods/misc_methods.rb +47 -0
  49. data/lib/itms_automation/methods/navigate_methods.rb +123 -0
  50. data/lib/itms_automation/methods/progress_methods.rb +15 -0
  51. data/lib/itms_automation/methods/required_files.rb +9 -0
  52. data/lib/itms_automation/methods/screenshot_methods.rb +6 -0
  53. data/lib/itms_automation/navigation_steps.rb +79 -0
  54. data/lib/itms_automation/progress_steps.rb +17 -0
  55. data/lib/itms_automation/screenshot_steps.rb +6 -0
  56. data/lib/itms_automation/version.rb +5 -3
  57. metadata +84 -95
  58. data/bin/console +0 -14
  59. data/bin/documentation_generator.rb +0 -119
  60. data/bin/setup +0 -8
  61. data/lib/itms_automation/all_steps.rb +0 -8
  62. data/lib/itms_automation/assertion_helper.rb +0 -29
  63. data/lib/itms_automation/auto_util.rb +0 -707
  64. data/lib/itms_automation/database_steps_helper.rb +0 -125
  65. data/lib/itms_automation/web_steps_helper.rb +0 -867
  66. data/project/Gemfile +0 -3
  67. data/project/Gemfile.lock +0 -92
  68. data/project/README.md +0 -34
  69. data/project/Rakefile +0 -24
  70. data/project/cucumber.yml +0 -4
  71. data/project/features/TestSuite/WebGUI.feature +0 -5
  72. data/project/features/step_definitions/lib_steps/steps_definition.rb +0 -46
  73. data/project/features/step_definitions/repositories/project_object.yml +0 -26
  74. data/project/features/support/env.rb +0 -9
  75. data/project/features/support/hooks.rb +0 -122
@@ -0,0 +1,24 @@
1
+ # require 'cucumber'
2
+ # require_relative 'methods/click_elements_methods'
3
+
4
+ # # click on web element
5
+ # When(/^I click on element"(.*?)"$/) do |element|
6
+ # click(element)
7
+ # end
8
+
9
+ # Then(/^I forcefully click on element "(.*?)"$/) do |element|
10
+ # click_forcefully(element)
11
+ # end
12
+
13
+ # # double click on web element
14
+ # Then(/^I double click on element "(.*?)"$/) do |element|
15
+ # double_click(element)
16
+ # end
17
+
18
+ # When(/^I tap on element"(.*?)"$/) do |element|
19
+ # click(element)
20
+ # end
21
+
22
+ # Then(/^I long press on element "(.*?)"$/) do |element|
23
+ # long_press(element, duration)
24
+ # end
@@ -0,0 +1,7 @@
1
+ # require 'cucumber'
2
+ # require_relative 'methods/configuration_methods'
3
+
4
+ # # step to print configuration
5
+ # Then(/^I print configuration$/) do
6
+ # print_congifugartion
7
+ # end
@@ -0,0 +1,59 @@
1
+ # require 'cucumber'
2
+ # require_relative 'methods/input_methods'
3
+
4
+ # # enter text into input field steps
5
+ # Then(/^I enter "([^\"]*)" into element "(.*?)"$/) do |text, element|
6
+ # enter_text(type, element)
7
+ # end
8
+
9
+ # # clear input field steps
10
+ # Then(/^I clear input element "(.*?)"$/) do |type, element|
11
+ # clear_text(type, element)
12
+ # end
13
+
14
+ # # select option by text/value from dropdown/multiselect
15
+ # Then(/^I select "(.*?)" option by (.+) from\s*((?:multiselect)?)\sdropdown "(.*?)"$/) do |option, option_by, present, element|
16
+ # validate_option_by option_by
17
+ # select_option_from_dropdown(element, option_by, option)
18
+ # end
19
+
20
+ # # select option by index from dropdown/multiselect
21
+ # Then(/^I select (\d+) option by index from\s*((?:multiselect)?)\sdropdown "(.*?)"$/) do |option, present, element|
22
+ # select_option_from_dropdown(element, 'index', (option.to_i) -1)
23
+ # end
24
+
25
+ # # step to select option from mutliselect dropdown list
26
+ # Then(/^I select all options from multiselect dropdown "(.*?)"$/) do |element|
27
+ # select_all_option_from_multiselect_dropdown(element)
28
+ # end
29
+
30
+ # # step to unselect option from mutliselect dropdown list
31
+ # Then(/^I unselect all options from multiselect dropdown "(.*?)"$/) do |element|
32
+ # unselect_all_option_from_multiselect_dropdown(element)
33
+ # end
34
+
35
+ # # check checkbox steps
36
+ # Then(/^I check the checkbox "(.*?)"$/) do |element|
37
+ # check_checkbox(element)
38
+ # end
39
+
40
+ # # uncheck checkbox steps
41
+ # Then(/^I uncheck the checkbox "(.*?)"$/) do |element|
42
+ # uncheck_checkbox(element)
43
+ # end
44
+
45
+ # # steps to toggle checkbox
46
+ # Then(/^I toggle checkbox "(.*?)"$/) do |element|
47
+ # toggle_checkbox(element)
48
+ # end
49
+
50
+ # # step to select radio button
51
+ # Then(/^I select radio button "(.*?)"$/) do |element|
52
+ # select_radio_button(element)
53
+ # end
54
+
55
+ # # steps to select option by text from radio button group
56
+ # Then(/^I select "(.*?)" option by (.+) from radio button group "(.*?)"$/) do |option, option_by, element|
57
+ # validate_option_by option_by
58
+ # select_option_from_radio_button_group(element, option_by, option)
59
+ # end
@@ -0,0 +1,10 @@
1
+ # require 'cucumber'
2
+ # require_relative 'methods/javascript_handling_methods'
3
+
4
+ # Then(/^I accept alert$/) do
5
+ # handle_alert('accept')
6
+ # end
7
+
8
+ # Then(/^I dismiss alert$/) do
9
+ # handle_alert('dismiss')
10
+ # end
@@ -0,0 +1,344 @@
1
+ require 'net/https'
2
+ require_relative 'required_files'
3
+
4
+ # This file contains assertion methods which are called from assertion_steps.rb
5
+
6
+ # Method to return page title
7
+ def get_page_title
8
+ $driver.title
9
+ end
10
+
11
+ # Method to verify title
12
+ # param 1 : String : expected title
13
+ # param 2 : Boolean : test case [true or flase]
14
+ def check_title(title, test_case)
15
+ page_title = get_page_title
16
+ if test_case
17
+ if page_title != "#{title}"
18
+ raise TestCaseFailed, "Page Title Not Matched, Actual Page Title : #{page_title}"
19
+ end
20
+ else
21
+ if page_title == "#{title}"
22
+ raise TestCaseFailed, "Page Title Matched, Actual Page Title:#{page_title}"
23
+ end
24
+ end
25
+ end
26
+
27
+ # Method to verify partial title
28
+ # param 1 : String : partial title string
29
+ # param 2 : Boolean : test case [true or flase]
30
+ def check_partial_title(partial_text_title, test_case)
31
+ page_title = get_page_title
32
+ if test_case
33
+ if not page_title.include? "#{partial_text_title}"
34
+ raise TestCaseFailed, 'Partial Page Title Not Present'
35
+ end
36
+ else
37
+ if page_title.include? "#{partial_text_title}"
38
+ raise TestCaseFailed, 'Page Title Matched'
39
+ end
40
+ end
41
+ end
42
+
43
+ # Method to get element text
44
+ # param 1 : String : Locator type (id, name, class, xpath, css)
45
+ # param 2 : String : Locator value
46
+ def get_element_text(element)
47
+ WAIT.until { find_object(element) }.text
48
+ end
49
+
50
+ # Method to check element text
51
+ # param 1 : String : Locator type (id, name, class, xpath, css)
52
+ # param 2 : String : Expected element text
53
+ # param 3 : String : Locator value
54
+ # param 4 : Boolean : test case [true or flase]
55
+ def check_element_text(element, actual_value, test_case)
56
+ element_text = get_element_text(element)
57
+
58
+ if test_case
59
+ if element_text != actual_value
60
+ raise TestCaseFailed, 'Text Not Matched'
61
+ end
62
+ else
63
+ if element_text == actual_value
64
+ raise TestCaseFailed, 'Text Matched'
65
+ end
66
+ end
67
+ end
68
+
69
+ # Method to check partial element text
70
+ # param 1 : String : Locator type (id, name, class, xpath, css)
71
+ # param 2 : String : Expected element partial text
72
+ # param 3 : String : Locator value
73
+ # param 4 : Boolean : test case [true or flase]
74
+ def check_element_partial_text(element, actual_value, test_case)
75
+ element_text = get_element_text(element)
76
+
77
+ if test_case
78
+ if not element_text.include? "#{actual_value}"
79
+ raise TestCaseFailed, 'Text Not Matched'
80
+ end
81
+ else
82
+ if element_text.include? "#{actual_value}"
83
+ raise TestCaseFailed, 'Text Matched'
84
+ end
85
+ end
86
+ end
87
+
88
+ # Method to return element status - enabled?
89
+ # param 1 : String : Locator type (id, name, class, xpath, css)
90
+ # param 2 : String : Locator value
91
+ def is_element_enabled(element)
92
+ WAIT.until{ find_object(element) }.enabled?
93
+ end
94
+
95
+ # Element enabled checking
96
+ # param 1 : String : Locator type (id, name, class, xpath, css)
97
+ # param 2 : String : Expected element text
98
+ # param 4 : Boolean : test case [true or flase]
99
+ def check_element_enable(element, test_case)
100
+ result = is_element_enabled(element)
101
+
102
+ if test_case
103
+ raise TestCaseFailed, 'Element Not Enabled' unless result
104
+ else
105
+ raise TestCaseFailed, 'Element Enabled' unless !result
106
+ end
107
+ end
108
+
109
+ # method to get attribute value
110
+ # param 1 : String : Locator type (id, name, class, xpath, css)
111
+ # param 2 : String : Expected element text
112
+ # param 3 : String : atrribute name
113
+ def get_element_attribute(element, attribute_name)
114
+ WAIT.until{ find_object(element) }.attribute("#{attribute_name}")
115
+ end
116
+
117
+ # method to check attribute value
118
+ # param 1 : String : Locator type (id, name, class, xpath, css)
119
+ # param 2 : String : atrribute name
120
+ # param 3 : String : atrribute value
121
+ # param 4 : String : Locator value
122
+ # param 5 : Boolean : test case [true or flase]
123
+ def check_element_attribute(element, attribute_name, attribute_value, test_case)
124
+
125
+ attr_val = get_element_attribute(element, attribute_name)
126
+
127
+ if test_case
128
+ if attr_val != attribute_value
129
+ raise TestCaseFailed, 'Attribute Value Not Matched'
130
+ end
131
+ else
132
+ if attr_val == attribute_value
133
+ raise TestCaseFailed, 'Attribute Value Matched'
134
+ end
135
+ end
136
+ end
137
+
138
+ # method to get element status - displayed?
139
+ # param 1 : String : Locator type (id, name, class, xpath, css)
140
+ # param 2 : String : Locator value
141
+ def is_element_displayed(access_type, access_name)
142
+ WAIT.until{ find_object(element) }.displayed?
143
+ end
144
+
145
+ # method to check element presence
146
+ # param 1 : String : Locator type (id, name, class, xpath, css)
147
+ # param 2 : String : Locator value
148
+ # param 3 : Boolean : test case [true or flase]
149
+ def check_element_presence(element, test_case)
150
+ if test_case
151
+ if !is_element_displayed(element)
152
+ raise TestCaseFailed, 'Element Not Present'
153
+ end
154
+ else
155
+ begin
156
+ if is_element_displayed(element)
157
+ raise 'Present' # since it is negative test and we found element
158
+ end
159
+ rescue Exception => e
160
+ if e.message == 'Present' # only raise if it present
161
+ raise TestCaseFailed, 'Element Present'
162
+ end
163
+ end
164
+ end
165
+ end
166
+
167
+ # method to assert checkbox check/uncheck
168
+ # param 1 : String : Locator type (id, name, class, xpath, css)
169
+ # param 2 : String : Locator value
170
+ # param 3 : Boolean : test case [true or flase]
171
+ def is_checkbox_checked(element, should_be_checked = true)
172
+ checkbox = WAIT.until{ find_object(element) }
173
+
174
+ if !checkbox.selected? && should_be_checked
175
+ raise TestCaseFailed, 'Checkbox is not checked'
176
+ elsif checkbox.selected? && !should_be_checked
177
+ raise TestCaseFailed, 'Checkbox is checked'
178
+ end
179
+ end
180
+
181
+ # method to assert radio button selected/unselected
182
+ # param 1 : String : Locator type (id, name, class, xpath, css)
183
+ # param 2 : String : Locator value
184
+ # param 3 : Boolean : test case [true or flase]
185
+ def is_radio_button_selected(element, should_be_selected = true)
186
+ radio_button = WAIT.until{ find_object(element) }
187
+
188
+ if !radio_button.selected? && should_be_selected
189
+ raise TestCaseFailed, 'Radio Button not selected'
190
+ elsif radio_button.selected? && !should_be_selected
191
+ raise TestCaseFailed, 'Radio Button is selected'
192
+ end
193
+ end
194
+
195
+ # method to assert option from radio button group is selected/unselected
196
+ def is_option_from_radio_button_group_selected(element, by, option, should_be_selected = true)
197
+ radio_button_group = WAIT.until{ find_object(element) }
198
+
199
+ getter = ->(rb, by) { by == 'value' ? rb.attribute('value') : rb.text }
200
+
201
+ ele = radio_button_group.find { |rb| getter.call(rb, by) == option }
202
+
203
+ if !ele.selected? && should_be_selected
204
+ raise TestCaseFailed, 'Radio button is not selected'
205
+ elsif ele.selected? && !should_be_selected
206
+ raise TestCaseFailed, 'Radio button is selected'
207
+ end
208
+ end
209
+
210
+ # method to get javascript pop-up alert text
211
+ def get_alert_text
212
+ $driver.switch_to.alert.text
213
+ end
214
+
215
+ # method to check javascript pop-up alert text
216
+ def check_alert_text(text)
217
+ if get_alert_text != text
218
+ raise TestCaseFailed, 'Text on alert pop up not matched'
219
+ end
220
+ end
221
+
222
+ def is_option_from_dropdown_selected(element, by, option, should_be_selected=true)
223
+ dropdown = WAIT.until { find_object(element) }
224
+ select_list = Selenium::WebDriver::Support::Select.new(dropdown)
225
+
226
+ if by == 'text'
227
+ actual_value = select_list.first_selected_option.text
228
+ else
229
+ actual_value = select_list.first_selected_option.attribute('value')
230
+ end
231
+
232
+ if !actual_value == option && should_be_selected
233
+ raise TestCaseFailed, 'Option Not Selected From Dropwdown'
234
+ elsif actual_value == option && !should_be_selected
235
+ raise TestCaseFailed, 'Option Selected From Dropwdown'
236
+ end
237
+ end
238
+
239
+ # Method to find difference between images
240
+ def does_images_similar?(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name)
241
+ if !compare_image(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name)
242
+ raise TestCaseFailed, 'Actual image is different from expected image'
243
+ end
244
+ end
245
+
246
+ # Method to compare two images
247
+ # param 1 : String : Locator type (id, name, class, xpath, css, url)
248
+ # param 2 : String : Locator value
249
+ # param 3 : String : Locator type (id, name, class, xpath, css, url, image_name)
250
+ # param 4 : String : Locator value
251
+ def compare_image(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name)
252
+ if actual_img_access_type == 'url'
253
+ actual_img_url = actual_img_access_name
254
+ else
255
+ actual_img_url = get_element_attribute(actual_img_access_type, actual_img_access_name, 'src')
256
+ end
257
+
258
+ if excp_img_access_type == 'url'
259
+ expected_img_url = excp_img_access_name
260
+ elsif excp_img_access_type == 'image_name'
261
+ expected_img_url = './features/expected_images/' + excp_img_access_name
262
+ else
263
+ expected_img_url = get_element_attribute(excp_img_access_type, excp_img_access_name, 'src')
264
+ end
265
+
266
+ # replace 'https' with 'http' from actual image url
267
+ if actual_img_url.include? 'https'
268
+ actual_img_url['https'] = 'http'
269
+ end
270
+
271
+ # replace 'https' with 'http' from expected image url
272
+ if expected_img_url.include? 'https'
273
+ expected_img_url['https'] = 'http'
274
+ end
275
+
276
+ if expected_img_url.include? '.png'
277
+ image_type = 'png'
278
+ else
279
+ image_type = 'jpg'
280
+ end
281
+
282
+ # Storing actual image locally
283
+ open('./features/actual_images/actual_image.' + image_type, 'wb') do |file|
284
+ file << open(actual_img_url).read
285
+ end
286
+
287
+ actual_img_url = './features/actual_images/actual_image.' + image_type
288
+
289
+ # Storing Expected image locally
290
+ if excp_img_access_type != 'image_name'
291
+ open('./features/expected_images/expected_image.' + image_type, 'wb') do |file|
292
+ file << open(expected_img_url).read
293
+ end
294
+ expected_img_url = './features/expected_images/expected_image.' + image_type
295
+ end
296
+
297
+ # Verify image extension and call respective compare function
298
+ if image_type == 'png'
299
+ return compare_png_images(expected_img_url, actual_img_url)
300
+ end
301
+
302
+ compare_jpeg_images(expected_img_url, actual_img_url)
303
+ end
304
+
305
+ # Comparing jpg images
306
+ def compare_jpeg_images(expected_img_url, actual_img_url)
307
+ if open(expected_img_url).read == open(actual_img_url).read
308
+ return true
309
+ else
310
+ puts 'Difference in images'
311
+ return false
312
+ end
313
+ end
314
+
315
+ # Comparing png images
316
+ def compare_png_images(expected_img_url, actual_img_url)
317
+ images = [
318
+ ChunkyPNG::Image.from_file(expected_img_url),
319
+ ChunkyPNG::Image.from_file(actual_img_url)
320
+ ]
321
+
322
+ diff = []
323
+
324
+ images.first.height.times do |y|
325
+ images.first.row(y).each_with_index do |pixel, x|
326
+ diff << [x, y] unless pixel == images.last[x, y]
327
+ end
328
+ end
329
+
330
+ if diff.length != 0
331
+ puts "\npixels (total): #{images.first.pixels.length}"
332
+ puts "pixels changed: #{diff.length}"
333
+ puts "pixels changed (%): #{(diff.length.to_f / images.first.pixels.length) * 100}%"
334
+
335
+ x, y = diff.map { |xy| xy[0] }, diff.map { |xy| xy[1] }
336
+ images.last.rect(x.min, y.min, x.max, y.max, ChunkyPNG::Color.rgb(0, 255, 0))
337
+ cur_time = Time.now.strftime('%Y%m%d%H%M%S%L')
338
+ images.last.save("./features/image_difference/difference_#{cur_time}.png")
339
+
340
+ puts "\nDifference between images saved as : difference_#{cur_time}.png\n"
341
+ return false
342
+ end
343
+ true
344
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'required_files'
2
+
3
+ def click(element)
4
+ WAIT.until { find_object(element) }.click
5
+ end
6
+
7
+ def click_forcefully(element)
8
+ $driver.execute_script('arguments[0].click();', WAIT.until { find_object(element) })
9
+ end
10
+
11
+ def double_click(access_type, access_value)
12
+ element = WAIT.until { find_object(element) }
13
+ $driver.action.double_click(element).perform
14
+ end
15
+
16
+
17
+ def long_press( access_name, duration)
18
+ element = WAIT.until { find_object(access_name) }
19
+ parameters = { "element" => "#{element}", "duration" => "#{duration}" }
20
+ args = parameters.select { |k, v| [:element, :duration].include? k }
21
+ args = args_with_ele_ref(args)
22
+ chain_method(:longPress, args)
23
+ end