itms_automation 2.7.0 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dba9f35006766cde92ddcbe9b77d9943b86fbdbbdfdf13f2a8f59b73589aa5da
4
- data.tar.gz: 87c8d32302284a4505a2e56eed6dfe74b863e308aceea85b6bdf1faf5374ca22
3
+ metadata.gz: '090afc5cfe29b875d3816ad9ca3e64c140c8b73a5fe2a7129d02b1641baa8d4f'
4
+ data.tar.gz: 9f36d46924317a25e1474668a4b22b19d487a155f2c24508310ee81230548196
5
5
  SHA512:
6
- metadata.gz: 77f8c58293b04d7547413a99b7872822d3d0966cf9f42925431e4eeec87fd9415e2e2cb073102a8d52d12c89ad67030229ec1857b23c6cad4a5f65bc0b82bb99
7
- data.tar.gz: d3decc37bd0b053305208cb5cffc559fb37048717d4e978995bd8033bf251cf094e341e32c90742c6d18f6b92dbc9f55082c6adbb7f0f628864fdbfb5763985a
6
+ metadata.gz: cf5d23c33daedaaa38c3e56cd689a8bb99ef720f8efe8ddfbdf6c0a686bf8749e208503b00e3ea1990608fd83d2c86f1159446d07314c02f159dcad892086989
7
+ data.tar.gz: 6b2052bc442d517c26186e412dacb3fb94f3b23c0aa21c24937686e1263ee9c3a07ecd21b139b49a5498a4787ea0ae8e12579e908acc86da530c2a1a5e5eca6a
@@ -7,28 +7,29 @@ require "webdrivers"
7
7
  $browser_type = ENV["BROWSER"] || "firefox"
8
8
 
9
9
  begin
10
+ $vars = {}
10
11
  $driver = case $browser_type
11
- when "chrome"
12
- Selenium::WebDriver.for(:chrome)
13
- when "safari"
14
- Selenium::WebDriver.for(:safari)
15
- when "internet_explorer"
16
- Selenium::WebDriver.for(:internet_explorer)
17
- when "chrome_headless"
18
- Selenium::WebDriver.for(:chrome, :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w(headless) }))
19
- when "remote"
20
- if ENV['SERVER_URL'].nil? || ENV['REMOTE_BROWSER'].nil?
21
- puts "\nMissing SERVER_URL : SERVER_URL=http//SERVER_URL:4444/wd/hub"
22
- puts "\nMissing REMOTE_BROWSER: REMOTE_BROWSER=browser_name"
23
- Process.exit(0)
24
- else
25
- caps = Selenium::WebDriver::Remote::Capabilities.new
26
- caps["browserName"] = ENV["REMOTE_BROWSER"]
27
- caps["enableVNC"] = true
28
- caps["enableVideo"] = ENV["ENABLE_VIDEO"] == "true"
29
- caps["resolution"] = ENV["resolution"] unless ENV["resolution"]
30
- Selenium::WebDriver.for(:remote, :url => ENV["SERVER_URL"], :desired_capabilities => caps)
31
- end
12
+ when "chrome"
13
+ Selenium::WebDriver.for(:chrome)
14
+ when "safari"
15
+ Selenium::WebDriver.for(:safari)
16
+ when "internet_explorer"
17
+ Selenium::WebDriver.for(:internet_explorer)
18
+ when "chrome_headless"
19
+ Selenium::WebDriver.for(:chrome, :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w(headless) }))
20
+ when "remote"
21
+ if ENV['SERVER_URL'].nil? || ENV['REMOTE_BROWSER'].nil?
22
+ puts "\nMissing SERVER_URL : SERVER_URL=http//SERVER_URL:4444/wd/hub"
23
+ puts "\nMissing REMOTE_BROWSER: REMOTE_BROWSER=browser_name"
24
+ Process.exit(0)
25
+ else
26
+ caps = Selenium::WebDriver::Remote::Capabilities.new
27
+ caps["browserName"] = ENV["REMOTE_BROWSER"]
28
+ caps["enableVNC"] = false
29
+ caps["enableVideo"] = false
30
+ caps["resolution"] = ENV["resolution"] unless ENV["resolution"]
31
+ Selenium::WebDriver.for(:remote, :url => ENV["SERVER_URL"], :desired_capabilities => caps)
32
+ end
32
33
  else
33
34
  Selenium::WebDriver.for(:firefox)
34
35
  end
@@ -1,5 +1,6 @@
1
1
  require 'net/https'
2
2
  require_relative 'required_files'
3
+ require 'rspec'
3
4
 
4
5
  # This file contains assertion methods which are called from assertion_steps.rb
5
6
 
@@ -9,59 +10,23 @@ def get_page_title
9
10
  end
10
11
 
11
12
  # 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
13
+ # param 1: String : expected title
14
+ def assert_title(title)
15
+ expect(get_page_title).to eq(title)
41
16
  end
42
17
 
43
18
  # Method to get element text
44
19
  # param : String
45
20
  def get_element_text(element)
46
- WAIT.until { find_object(element) }.text
21
+ find_object(element).text
47
22
  end
48
23
 
49
24
  # Method to check element text
50
25
  # param 1 : String : Element
51
26
  # param 2 : String : Expected element text
52
- # param 3 : Boolean : test case [true or flase]
53
- def check_element_text(element, expected_value, test_case)
27
+ def assert_text(element, expected_value)
54
28
  element_text = get_element_text(element)
55
-
56
- if test_case
57
- if element_text != expected_value
58
- raise TestCaseFailed, "Text Not Matched. Actual Value :#{expected_value}"
59
- end
60
- else
61
- if element_text == expected_value
62
- raise TestCaseFailed, "Text Matched. Actual Value :#{expected_value}"
63
- end
64
- end
29
+ expect(element_text).to eq(expected_value)
65
30
  end
66
31
 
67
32
  # Method to check partial element text
@@ -101,13 +66,6 @@ def check_element_enable(element, test_case)
101
66
  end
102
67
  end
103
68
 
104
- # method to get attribute value
105
- # param 1 : String : Element
106
- # param 2 : String : atrribute name
107
- def get_element_attribute(element, attribute_name)
108
- WAIT.until{ find_object(element) }.attribute("#{attribute_name}")
109
- end
110
-
111
69
  # method to check attribute value
112
70
  # param 1 : String : Element
113
71
  # param 2 : String : atrribute name
@@ -137,34 +95,26 @@ end
137
95
  # method to check element presence
138
96
  # param 1 : String : Element
139
97
  # param 2 : Boolean : test case [true or flase]
140
- def check_element_presence(element, test_case)
141
- if test_case
142
- if !is_element_displayed(element)
143
- raise TestCaseFailed, 'Element Not Present'
144
- end
145
- else
146
- begin
147
- if is_element_displayed(element)
148
- raise 'Present' # since it is negative test and we found element
149
- end
150
- rescue Exception => e
151
- if e.message == 'Present' # only raise if it present
152
- raise TestCaseFailed, 'Element Present'
153
- end
154
- end
155
- end
98
+ def assert_element_present(element)
99
+ found_element = find_object(element)
100
+ raise TestCaseFailed, 'Element Not Present' unless found_element.length > 0
156
101
  end
157
102
 
158
- # method to assert checkbox check/uncheck
103
+ # method to assert checkbox check
159
104
  # param 1 : String : Element
160
- # param 2 : Boolean : test case [true or flase]
161
- def is_checkbox_checked(element, should_be_checked = true)
162
- checkbox = WAIT.until{ find_object(element) }
105
+ def assert_checked(element)
106
+ checkbox = find_object(element)
163
107
 
164
- if !checkbox.selected? && should_be_checked
165
- raise TestCaseFailed, 'Checkbox is not checked'
166
- elsif checkbox.selected? && !should_be_checked
167
- raise TestCaseFailed, 'Checkbox is checked'
108
+ if !checkbox.selected?
109
+ raise TestCaseFailed, "Checkbox is not checked"
110
+ end
111
+ end
112
+
113
+ def assert_not_checked(element)
114
+ checkbox = find_object(element)
115
+
116
+ if checkbox.selected?
117
+ raise TestCaseFailed, "Checkbox is checked"
168
118
  end
169
119
  end
170
120
 
@@ -202,10 +152,9 @@ def get_alert_text
202
152
  end
203
153
 
204
154
  # method to check javascript pop-up alert text
205
- def check_alert_text(text)
206
- if get_alert_text != text
207
- raise TestCaseFailed, "Text on alert pop up not matched. Actual Value :#{get_alert_text}"
208
- end
155
+ def assert_alert(text)
156
+ alert_text = $driver.switch_to.alert.text
157
+ expect(alert_text).to eq(text)
209
158
  end
210
159
 
211
160
  def is_option_from_dropdown_selected(element, by, option, should_be_selected=true)
@@ -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
@@ -22,14 +22,18 @@ 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
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
@@ -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,21 +40,18 @@ 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
56
  WAIT.until { find_object(element) }.click
54
57
  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
@@ -59,6 +59,6 @@ def loadYAMLfile(filename)
59
59
  begin
60
60
  return YAML.load_file(filename)
61
61
  rescue Psych::SyntaxError => ex
62
- raise " SyntaxError when reading file: #{ex}"
62
+ raise "Syntax error when reading file: #{ex}"
63
63
  end
64
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,6 +1,6 @@
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
 
@@ -1,5 +1,5 @@
1
1
  module ITMS
2
2
  module Automation
3
- VERSION = '2.7.0'
3
+ VERSION = '2.7.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itms_automation
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - INFOdation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-29 00:00:00.000000000 Z
11
+ date: 2021-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -110,6 +110,26 @@ dependencies:
110
110
  - - "~>"
111
111
  - !ruby/object:Gem::Version
112
112
  version: '1.8'
113
+ - !ruby/object:Gem::Dependency
114
+ name: rspec
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '3.5'
120
+ - - "~>"
121
+ - !ruby/object:Gem::Version
122
+ version: '3.5'
123
+ type: :runtime
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '3.5'
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '3.5'
113
133
  description: Behavior driven development (BDD) approach to write automation test script
114
134
  to test Web and Android applications.
115
135
  email: anh.pham@infodation.vn
@@ -149,6 +169,7 @@ files:
149
169
  - lib/itms_automation/javascript_handling_steps.rb
150
170
  - lib/itms_automation/methods/assertion_methods.rb
151
171
  - lib/itms_automation/methods/click_elements_methods.rb
172
+ - lib/itms_automation/methods/condition_methods.rb
152
173
  - lib/itms_automation/methods/configuration_methods.rb
153
174
  - lib/itms_automation/methods/error_handling_methods.rb
154
175
  - lib/itms_automation/methods/input_methods.rb