itms_automation 2.6.7 → 2.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/doc/installation.md +1 -1
  3. data/features-skeleton/my_first.feature +19 -10
  4. data/features-skeleton/step_definitions/input_steps.rb +3 -3
  5. data/features-skeleton/step_definitions/my_first_steps.rb +14 -0
  6. data/features-skeleton/step_definitions/repositories/project_object.yml +1 -1
  7. data/features-skeleton/support/env.rb +17 -88
  8. data/lib/itms_automation/input_steps.rb +1 -1
  9. data/lib/itms_automation/methods/assertion_methods.rb +159 -174
  10. data/lib/itms_automation/methods/click_elements_methods.rb +13 -6
  11. data/lib/itms_automation/methods/condition_methods.rb +13 -0
  12. data/lib/itms_automation/methods/configuration_methods.rb +14 -7
  13. data/lib/itms_automation/methods/input_methods.rb +58 -15
  14. data/lib/itms_automation/methods/javascript_handling_methods.rb +1 -1
  15. data/lib/itms_automation/methods/misc_methods.rb +1 -2
  16. data/lib/itms_automation/methods/navigate_methods.rb +52 -45
  17. data/lib/itms_automation/methods/progress_methods.rb +73 -6
  18. data/lib/itms_automation/methods/store_methods.rb +36 -0
  19. data/lib/itms_automation/version.rb +1 -1
  20. metadata +40 -40
  21. data/example/android/android_app/android_app_calculator.zip +0 -0
  22. data/example/android/android_app/android_app_calculator/AndroidCalculator.apk +0 -0
  23. data/example/android/android_app/android_app_calculator/features/calculator.feature +0 -36
  24. data/example/android/android_app/android_app_calculator/features/my_first.feature +0 -13
  25. data/example/android/android_app/android_app_calculator/features/screenshots/test.png +0 -0
  26. data/example/android/android_app/android_app_calculator/features/step_definitions/custom_steps.rb +0 -5
  27. data/example/android/android_app/android_app_calculator/features/support/env.rb +0 -52
  28. data/example/android/android_app/android_app_calculator/features/support/hooks.rb +0 -26
  29. data/example/android/android_web/android_web_gmail_login.zip +0 -0
  30. data/example/android/android_web/android_web_gmail_login/features/gmail_login.feature +0 -12
  31. data/example/android/android_web/android_web_gmail_login/features/my_first.feature +0 -1
  32. data/example/android/android_web/android_web_gmail_login/features/screenshots/test.png +0 -0
  33. data/example/android/android_web/android_web_gmail_login/features/step_definitions/custom_steps.rb +0 -5
  34. data/example/android/android_web/android_web_gmail_login/features/support/env.rb +0 -51
  35. data/example/android/android_web/android_web_gmail_login/features/support/hooks.rb +0 -27
  36. data/example/desktop web/desktop_web_gmail_login.zip +0 -0
  37. data/example/desktop web/desktop_web_gmail_login/features/gmail_login.feature +0 -9
  38. data/example/desktop web/desktop_web_gmail_login/features/gmail_multi_login.feature +0 -21
  39. data/example/desktop web/desktop_web_gmail_login/features/my_first.feature +0 -1
  40. data/example/desktop web/desktop_web_gmail_login/features/screenshots/test.png +0 -0
  41. data/example/desktop web/desktop_web_gmail_login/features/step_definitions/custom_steps.rb +0 -5
  42. data/example/desktop web/desktop_web_gmail_login/features/support/env.rb +0 -106
  43. data/example/desktop web/desktop_web_gmail_login/features/support/hooks.rb +0 -38
@@ -1,20 +1,27 @@
1
1
  require_relative 'required_files'
2
2
 
3
3
  def click(element)
4
- WAIT.until { find_object(element) }.click
4
+ found_element = find_object(element)
5
+ found_element.click
5
6
  end
6
7
 
7
- def click_forcefully(element)
8
- $driver.execute_script('arguments[0].click();', WAIT.until { find_object(element) })
8
+ def click_at(element)
9
+ found_element = find_object(element)
10
+ found_element.click
9
11
  end
10
12
 
11
13
  def double_click(element)
12
- found_element = WAIT.until { find_object(element) }
14
+ found_element = find_object(element)
13
15
  $driver.action.double_click(found_element).perform
14
16
  end
15
17
 
16
- def long_press( element, duration)
17
- found_element = WAIT.until { find_object(element) }
18
+ def double_click_at(element, location)
19
+ found_element = find_object(element)
20
+ $driver.action.double_click(found_element).perform
21
+ end
22
+
23
+ def long_press(element, duration)
24
+ found_element = find_object(element)
18
25
  parameters = { "element" => "#{found_element}", "duration" => "#{duration}" }
19
26
  args = parameters.select { |k, v| [:element, :duration].include? k }
20
27
  args = args_with_ele_ref(args)
@@ -0,0 +1,13 @@
1
+ require_relative 'required_files'
2
+
3
+ def if(condition_script)
4
+ return $driver.execute_script(condition_script)
5
+ end
6
+
7
+ def else_if(condition_script)
8
+ return $driver.execute_script(condition_script)
9
+ end
10
+
11
+ def while(condition_script)
12
+ return $driver.execute_script(condition_script)
13
+ end
@@ -7,9 +7,9 @@ def print_congifugartion
7
7
  puts "Time : #{Time.now.strftime("%I:%M:%S:%p")}"
8
8
 
9
9
  if $platform == 'android' or $platform == 'ios'
10
- print_mobile_configuration
10
+ print_mobile_configuration
11
11
  else
12
- print_desktop_configuration
12
+ print_desktop_configuration
13
13
  end
14
14
  end
15
15
 
@@ -22,14 +22,21 @@ end
22
22
 
23
23
  # method to print mobile configuration
24
24
  def print_mobile_configuration
25
- puts "Platform : #{$platform.upcase}"
26
- puts "OS version : #{$os_version}"
27
- puts "Device : #{$device_name}"
25
+ puts "Platform : #{$platform.upcase}"
26
+ puts "OS version : #{$os_version}"
27
+ puts "Device : #{$device_name}"
28
28
 
29
29
  if $app_path.nil?
30
- puts 'Browser : ' + $driver.capabilities.browser_name.to_s.upcase + " " + $driver.capabilities.version.to_s
30
+ puts 'Browser : ' + $driver.capabilities.browser_name.to_s.upcase + " " + $driver.capabilities.version.to_s
31
31
  else
32
- puts "App Tested : #{$app_path}"
32
+ puts "App Tested : #{$app_path}"
33
33
  end
34
34
  puts ''
35
35
  end
36
+
37
+ def echo(message)
38
+ puts(message)
39
+ end
40
+
41
+ def debugger
42
+ end
@@ -1,15 +1,21 @@
1
1
  require_relative 'required_files'
2
2
 
3
3
  # method to enter text into textfield
4
- def enter_text(element, text)
4
+ def type(element, text)
5
5
  foundElement = find_object(element)
6
- WAIT.until { foundElement }.send_keys(text)
6
+ foundElement.send_keys(text)
7
7
  end
8
8
 
9
- # method to clear text from textfield
10
- def clear_text(element)
9
+ # method to send keys
10
+ def send_keys(element, key)
11
+ keys_support = ["KEY_LEFT", "KEY_UP", "KEY_RIGHT", "KEY_DOWN", "KEY_PAGE_UP", "KEY_PAGE_DOWN", "KEY_BACKSPACE", "KEY_DELETE", "KEY_ENTER", "KEY_TAB"]
11
12
  foundElement = find_object(element)
12
- WAIT.until { foundElement }.clear
13
+ if key
14
+ get_key = key.strip[/^\$\{(.*?)\}$/, 1]
15
+ raise TestCaseFailed, "${get_key} key is not supported. Supported keys: KEY_LEFT, KEY_UP, KEY_RIGHT, KEY_DOWN, KEY_PAGE_UP, KEY_PAGE_DOWN, KEY_BACKSPACE, KEY_DELETE, KEY_ENTER, KEY_TAB" unless keys_support.include?(get_key)
16
+ key_convert = get_key[/^KEY_(.*?)$/, 1].downcase.to_sym
17
+ foundElement.send_keys(key_convert)
18
+ end
13
19
  end
14
20
 
15
21
  # method to select option from dropdwon list
@@ -34,23 +40,20 @@ def unselect_all_option_from_multiselect_dropdown(element)
34
40
  end
35
41
 
36
42
  # method to check checkbox
37
- def check_checkbox(element)
38
- checkbox = WAIT.until { find_object(element) }
43
+ def check(element)
44
+ checkbox = find_object(element)
39
45
  checkbox.click unless checkbox.selected?
40
46
  end
41
47
 
42
48
  # method to uncheck checkbox
43
- def uncheck_checkbox(element)
44
- checkbox = WAIT.until { find_object(element) }
45
-
46
- if checkbox.selected?
47
- checkbox.click
48
- end
49
+ def uncheck(element)
50
+ checkbox = find_object(element)
51
+ checkbox.click if checkbox.selected?
49
52
  end
50
53
 
51
- # method to select radio button
54
+ # method to toggle checkbox checked
52
55
  def toggle_checkbox(element)
53
- WAIT.until { find_object(element) }.click
56
+ find_object(element).click
54
57
  end
55
58
 
56
59
  # method to select radio button
@@ -67,3 +70,43 @@ def select_option_from_radio_button_group(element, by, option)
67
70
  ele = radio_button_group.find { |rb| getter.call(rb, by) == option }
68
71
  ele.click unless ele.selected?
69
72
  end
73
+
74
+ def edit_content(element, text)
75
+ found_element = find_object(element)
76
+ $driver.execute_script("if (arguments[0].contentEditable === 'true') {arguments[0].innerText = '#{text}'}", found_element)
77
+ end
78
+
79
+ def add_selection(label)
80
+ found_element = find_object(element)
81
+ found_element.find_element(:xpath, "//option[. = '#{label}']").click
82
+ end
83
+
84
+ def remove_selection
85
+ found_element = find_object(element)
86
+ found_element.find_element(:xpath, "//option[. = '#{label}']").click
87
+ end
88
+
89
+ def select
90
+ found_element = find_object(element)
91
+ found_element.find_element(:xpath, "//option[. = '#{label}']").click
92
+ end
93
+
94
+ def drag_and_drop_to_object(element, drop_element)
95
+ dragged = find_object(element)
96
+ object_value_regex = /^(class=|css=|id=|name=|xpath=|className=|link=|linkText=|partialLinkText=)/
97
+ object_type_regex = /^(class|css|id|name|xpath|className|link|linkText|partialLinkText)/
98
+ if object_value_regex.match?(drop_element)
99
+ object_value = drop_element.gsub(object_value_regex, "")
100
+ object_type = drop_element.split(object_type_regex)[1].underscore
101
+ dropped = $driver.find_element(object_type.to_sym, object_value)
102
+ $driver.action.drag_and_drop(dragged, dropped).perform
103
+ else
104
+ raise TestCaseFailed, "Option locator not supported"
105
+ end
106
+ end
107
+
108
+ def select_window(element)
109
+ end
110
+
111
+ def select_frame(element)
112
+ end
@@ -4,6 +4,6 @@ def handle_alert(decesion)
4
4
  if decesion == 'accept'
5
5
  $driver.switch_to.alert.accept
6
6
  else
7
- $driver.switch_to.alert.dismiss
7
+ $driver.switch_to.alert.dismiss
8
8
  end
9
9
  end
@@ -13,7 +13,6 @@ def valid_locator_type? type
13
13
  end
14
14
 
15
15
  def validate_locator type
16
- puts "validate_locator:::#{type}"
17
16
  raise "Invalid locator type - #{type}" unless valid_locator_type? type
18
17
  end
19
18
 
@@ -60,6 +59,6 @@ def loadYAMLfile(filename)
60
59
  begin
61
60
  return YAML.load_file(filename)
62
61
  rescue Psych::SyntaxError => ex
63
- raise " SyntaxError when reading file: #{ex}"
62
+ raise "Syntax error when reading file: #{ex}"
64
63
  end
65
64
  end
@@ -1,21 +1,25 @@
1
1
  require_relative 'required_files'
2
2
 
3
3
  # method to open link
4
- def navigate_to(link)
4
+ def open(link)
5
5
  $driver.get link
6
6
  end
7
7
 
8
8
  # method to navigate back & forward
9
9
  def navigate(direction)
10
10
  if direction == 'back'
11
- $driver.navigate.back
11
+ $driver.navigate.back
12
12
  else
13
13
  $driver.navigate.forward
14
14
  end
15
15
  end
16
16
 
17
+ def close
18
+ $drive.close
19
+ end
20
+
17
21
  # method to quite webdriver instance
18
- def close_driver
22
+ def quit
19
23
  $driver.quit
20
24
  end
21
25
 
@@ -39,7 +43,7 @@ end
39
43
  # Method to zoom in/out web page until web element dislays
40
44
  def zoom_in_out_till_element_display(element, in_out)
41
45
  while true
42
- if WAIT.until { find_object(element) }.displayed?
46
+ if find_object(element).displayed?
43
47
  break
44
48
  else
45
49
  $driver.action.key_down(:"#{get_key}").send_keys(:"#{in_out}").key_up(:"#{get_key}").perform
@@ -48,8 +52,10 @@ def zoom_in_out_till_element_display(element, in_out)
48
52
  end
49
53
 
50
54
  # Method to resize browser
51
- def resize_browser(width, heigth)
52
- $driver.manage.window.resize_to(width, heigth)
55
+ def set_window_size(resolution)
56
+ raise TestCaseFailed, 'Wrong format of resolution. (e.g., 1280x800)' unless resolution.match(/^\d+x\d+$/)
57
+ width, height = resolution.split("x")
58
+ $driver.manage.resize_to(width, heigth)
53
59
  end
54
60
 
55
61
  # Method to maximize browser
@@ -63,14 +69,50 @@ def refresh_page
63
69
  end
64
70
 
65
71
  # Method to hover on element
66
- def hover_over_element(element)
67
- element = WAIT.until { find_object(element) }
68
- $driver.action.move_to(element).perform
72
+ def mouse_over(element)
73
+ element = find_object(element)
74
+ $driver.action.move_to_element(element).perform
75
+ end
76
+
77
+ # mouse_down
78
+ def mouse_down(element)
79
+ element = find_object(element)
80
+ $driver.action.move_to_element(element).click_and_hold.perform
81
+ end
82
+
83
+ # mouse_down_at
84
+ def mouse_down_at(element, location)
85
+ element = find_object(element)
86
+ $driver.action.move_to_element(element).click_and_hold.perform
87
+ end
88
+
89
+ # mouse_out
90
+ def mouse_out
91
+ element = $driver.find_element(By.CSS_SELECTOR, 'body')
92
+ $driver.action.move_to_element(element, 0, 0).perform
93
+ end
94
+
95
+ #mouse_up
96
+ def mouse_up(element)
97
+ element = find_object(element)
98
+ $driver.action.move_to_element(element).release.perform
99
+ end
100
+
101
+ #mouse_up_at
102
+ def mouse_up_at
103
+ element = find_object(element)
104
+ $driver.action.move_to_element(element).release.perform
105
+ end
106
+
107
+ #mouse_move_at
108
+ def mouse_move_at
109
+ element = find_object(element)
110
+ $driver.action.move_to_element(element).perform
69
111
  end
70
112
 
71
113
  # Method to scroll page to perticular element
72
114
  def scroll_to_element(element)
73
- ele_scroll = WAIT.until { find_object(element) }
115
+ ele_scroll = find_object(element)
74
116
  ele_scroll.location_once_scrolled_into_view
75
117
  end
76
118
 
@@ -84,38 +126,3 @@ def scroll_page(to)
84
126
  raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")"
85
127
  end
86
128
  end
87
-
88
- $old_win = nil
89
-
90
- # Method to switch to new window
91
- def switch_to_new_window
92
- $old_win = $driver.window_handle
93
- $driver.switch_to.window($driver.window_handles[1])
94
- end
95
-
96
- # Method to switch to old window
97
- def switch_to_old_window
98
- $driver.switch_to.window($old_win)
99
- end
100
-
101
- # Method to close new window
102
- def close_new_window
103
- $driver.close
104
- end
105
-
106
- =begin
107
- def switch_to_new_window
108
- win_handles = $driver.window_handles
109
-
110
- puts $driver.title
111
- puts win_handles.length
112
-
113
- $driver.switch_to.window($driver.window_handles[1])
114
- puts $driver.window_handles[1]
115
- puts $driver.title
116
-
117
- $driver.switch_to.window($driver.window_handles[2])
118
- puts $driver.window_handles[2]
119
- puts $driver.title
120
- end
121
- =end
@@ -1,15 +1,82 @@
1
1
  require_relative 'required_files'
2
2
 
3
- def wait(time)
3
+ def pause(time)
4
4
  sleep time.to_i
5
5
  end
6
6
 
7
- def wait_for_element_to_display(element, duration)
8
- wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i) # seconds
7
+ def wait_for_element_editable(element, duration)
8
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
9
+ wait.until { find_object(element).enabled? }
10
+ end
11
+
12
+ def wait_for_element_not_editable(element, duration)
13
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
14
+ wait.until { !find_object(element).enabled? }
15
+ end
16
+
17
+ def wait_for_element_not_present(element, duration)
18
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
19
+ wait.until do
20
+ begin
21
+ !find_object(element)
22
+ rescue Selenium::WebDriver::Error::NoSuchElementError
23
+ true
24
+ end
25
+ end
26
+ end
27
+
28
+ def wait_for_element_not_visible(element, duration)
29
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
30
+ wait.until { !find_object(element).displayed? }
31
+ end
32
+
33
+ def wait_for_text(element, text)
34
+ wait = Selenium::WebDriver::Wait.new(:timeout => 30)
35
+ wait.until { find_object(element).text == text }
36
+ end
37
+
38
+ def wait_for_element_visible(element, duration)
39
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
9
40
  wait.until { find_object(element).displayed? }
10
41
  end
11
42
 
12
- def wait_for_element_to_enable(element, duration)
13
- wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i) # seconds
14
- wait.until { find_object(element).enabled? }
43
+ def wait_for_element_present(element, duration)
44
+ wait = Selenium::WebDriver::Wait.new(:timeout => duration.to_i / 1000)
45
+ wait.until { find_object(element) }
46
+ end
47
+
48
+ def answer_on_next_prompt(answer)
49
+ alert = $driver.switch_to.alert
50
+ alert.send_keys(answer)
51
+ alert.accept()
52
+ end
53
+
54
+ def choose_cancel_on_next_confirmation
55
+ $driver.switch_to.alert.dismiss
56
+ end
57
+
58
+ def choose_cancel_on_next_prompt
59
+ $driver.switch_to.alert.dismiss
60
+ end
61
+
62
+ def choose_ok_on_next_confirmation
63
+ $driver.switch_to.alert.accept
64
+ end
65
+
66
+ def webdriver_answer_on_visible_prompt
67
+ alert = $driver.switch_to.alert
68
+ alert.send_keys(answer)
69
+ alert.accept()
70
+ end
71
+
72
+ def webdriver_choose_cancel_on_visible_confirmation
73
+ $driver.switch_to.alert.dismiss
74
+ end
75
+
76
+ def webdriver_choose_ok_on_visible_confirmation
77
+ $driver.switch_to.alert.accept
78
+ end
79
+
80
+ def webdriver_choose_cancel_on_visible_prompt
81
+ $driver.switch_to.alert.dismiss
15
82
  end