Ifd_Automation 1.9.2 → 2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/bin/documentation_generator.rb +1 -1
  3. data/lib/Ifd_Automation/REST_steps.rb +105 -0
  4. data/lib/Ifd_Automation/SOAP_steps.rb +54 -0
  5. data/lib/Ifd_Automation/database_steps.rb +17 -47
  6. data/lib/Ifd_Automation/dynamic_store_vavue_steps.rb +25 -0
  7. data/lib/Ifd_Automation/email_steps.rb +32 -36
  8. data/lib/Ifd_Automation/file_steps.rb +7 -58
  9. data/lib/Ifd_Automation/require_libs.rb +6 -0
  10. data/lib/Ifd_Automation/ssh_steps.rb +14 -23
  11. data/lib/Ifd_Automation/version.rb +1 -1
  12. data/lib/Ifd_Automation/web_steps.rb +58 -293
  13. data/lib/helper/assertion_helpers.rb +100 -0
  14. data/lib/helper/auto_utils.rb +67 -0
  15. data/lib/{Ifd_Automation_support → helper}/connection_helpers.rb +2 -2
  16. data/lib/{Ifd_Automation_support → helper}/core.rb +154 -60
  17. data/lib/{Ifd_Automation_support → helper}/mail_helpers.rb +2 -2
  18. data/lib/helper/web_steps_helpers.rb +123 -0
  19. data/project/Gemfile +1 -2
  20. data/project/features/Screenshot/failed_sample.png +0 -0
  21. data/project/features/TestData/globalData.yml +4 -1
  22. data/project/features/TestSuite/test.feature +1 -4
  23. data/project/features/step_definitions/lib_steps/test.rb +5 -3
  24. data/project/features/step_definitions/repositories/project_object.yml +2 -2
  25. data/project/features/support/env.rb +53 -52
  26. data/project/features/support/hooks.rb +2 -0
  27. data/project/features/support/project_config.yml +6 -6
  28. metadata +36 -148
  29. data/lib/Ifd_Automation/javascript_steps.rb +0 -33
  30. data/lib/Ifd_Automation/required_libs.rb +0 -7
  31. data/lib/Ifd_Automation/response.rb +0 -105
  32. data/lib/Ifd_Automation/webservice_steps.rb +0 -281
  33. data/lib/Ifd_Automation_support/assertion_helpers.rb +0 -205
  34. data/lib/Ifd_Automation_support/javascript_helpers.rb +0 -45
  35. data/lib/Ifd_Automation_support/selenium_sync_issues.rb +0 -62
  36. data/lib/Ifd_Automation_support/web_steps_helpers.rb +0 -296
  37. data/project/Gemfile.lock +0 -203
  38. data/project/Rakefile +0 -46
@@ -0,0 +1,6 @@
1
+ require_relative '../helper/core.rb'
2
+ require_relative '../helper/web_steps_helpers.rb'
3
+ require_relative '../helper/auto_utils.rb'
4
+ require_relative '../helper/mail_helpers.rb'
5
+ require_relative '../helper/assertion_helpers.rb'
6
+ require_relative '../helper/connection_helpers.rb'
@@ -1,5 +1,7 @@
1
1
  require 'net/ssh'
2
- When /^I ssh to "([^\"]*)" with the following credentials:$/ do |hostname, table|
2
+ require_relative 'require_libs'
3
+ When /^I SSH to "([^\"]*)" with the following credentials:$/ do |hostname, table|
4
+ hostname = check_dynamic_value hostname
3
5
  @keys = []
4
6
  @auth_methods ||= %w(password)
5
7
  session = table.hashes.first
@@ -10,38 +12,27 @@ When /^I ssh to "([^\"]*)" with the following credentials:$/ do |hostname, table
10
12
  session_auth_methods << "publickey"
11
13
  end
12
14
 
13
- @connection = Net::SSH.start(hostname, session["username"], :password => session["password"],
15
+ @SSHconnection = Net::SSH.start(hostname, session["username"], :password => session["password"],
14
16
  :auth_methods => session_auth_methods,
15
17
  :keys => session_keys)
16
18
  end
17
19
 
18
- When /^I run "([^\"]*)"$/ do |command|
19
- @output = @connection.exec!(command)
20
+ When /^I run SSH command "([^\"]*)"$/ do |command|
21
+ command = check_dynamic_value command
22
+ @output = @SSHconnection.exec!(command)
20
23
  end
21
24
 
22
25
 
23
- Then /^show me the output$/ do
26
+ Then /^show me the SSH output result$/ do
24
27
  p @output
25
28
  end
26
29
 
27
- Then /^I should see "([^\"]*)" in the output$/ do |string|
28
- IFD_Assertion.assert_string_equal(string, @output.strip)
30
+ Then /^I should see "([^\"]*)" in the SSH output$/ do |string|
31
+ string = check_dynamic_value string
32
+ Assertion.assert_string_equal(string, @output.strip)
29
33
  end
30
34
 
31
- When /^I run ssh command from previous step$/ do
32
- unless @file_data.nil?
33
- begin
34
- @file_data.each_line do |line|
35
- if line.nil? || line =~ /^\s*\n*--/
36
- next
37
- end
38
- line = line.strip();
39
- p line
40
- @output = @connection.exec!(line)
41
- sleep 1
42
- end
43
- rescue Exception => e
44
- raise e.message
45
- end
46
- end
35
+ When /^I store the result of SSH as "(.*?)"$/ do |var_name|
36
+ $context_value = bind_with_dyn_vars(@output)
37
+ set_var(var_name, '$context_value')
47
38
  end
@@ -1,3 +1,3 @@
1
1
  module IfdAutomation
2
- VERSION = "1.9.2"
2
+ VERSION = "2.0"
3
3
  end
@@ -1,293 +1,58 @@
1
- require_relative 'required_libs'
2
- # require_relative 'Ifd_Automation_support/web_service_helpers.rb'
3
- # Navigate to a particular page
4
- Given(/^I am on the "([^"]*)" page$/) do |url|
5
- request_url = check_match_url url
6
- execute_openbrowser(request_url)
7
- end
8
-
9
- #Navigating to the login page
10
- Given /^I am on Login Page$/ do
11
- execute_openbrowser($_CFWEB['Page Address'])
12
- end
13
-
14
- # Wait for the specific time
15
- When /^I wait for (\d+) seconds$/ do |second|
16
- sleep(second.to_i)
17
- end
18
-
19
- # Finds a button or link by id, text or value and clicks it
20
- And /^I click on "([^\"]*)"$/ do |object|
21
- patiently do
22
- execute_click(object)
23
- end
24
- end
25
-
26
- # Finds and clicks it with JS
27
- And /^I move mouse to element "([^\"]*)" then click$/ do |object|
28
- patiently do
29
- execute_mousehoverandclick(object)
30
- end
31
- end
32
-
33
- # Fill in a text box or text area with a value
34
- And /^I set text on "(.*?)" with "(.*?)"$/ do |object, text|
35
- patiently do
36
- request_url = check_match_url text
37
- # text = var_collect(text)
38
- # text = replace_pipe(text)
39
- execute_settext(object, request_url)
40
- end
41
- end
42
-
43
- # set state for check box, combo box
44
- And /^I set state on "(.*?)" with "(.*?)"$/ do |object, state|
45
- patiently do
46
- execute_setstate(object, state)
47
- end
48
- end
49
-
50
- # Input data to text box, this function support in case user want to input data into many text boxes on the same time
51
- When /^I input data to web form with following values:$/ do |value|
52
- patiently do
53
- records = Util.read_table_data_from_steps_with_header(value.raw)
54
- records = JSON.parse(JSON.generate(records))
55
- records.each { |rows|
56
- rows.each { |col, val|
57
- step %{I set text on "#{col}" with "#{val}"}
58
- }
59
- }
60
- end
61
- end
62
-
63
- When /^I run the following steps?:$/ do |steps_table|
64
- patiently do
65
- steps = steps_table.raw.flatten
66
- steps.each do |step|
67
- call_step step
68
- end
69
- end
70
- end
71
-
72
- When /^I click on following elements:$/ do |object|
73
- patiently do
74
- object.raw.each do |lines|
75
- lines.each do |line|
76
- step %{I click on "#{line}"}
77
- end
78
- end
79
- end
80
- end
81
-
82
- Then /^I run following steps in iframe (index|name) (.*):$/ do |frame_type, frame, step_table|
83
- case frame_type.to_sym
84
- when :index
85
- steps = step_table.raw.flatten
86
- browser = page.driver.browser
87
- browser.switch_to.frame(frame.to_i)
88
- steps.each do |step|
89
- call_step step
90
- end
91
- browser.switch_to.default_content
92
- when :name
93
- browser = page.driver.browser
94
- browser.switch_to.frame(frame.to_s)
95
- steps.each do |step|
96
- call_step step
97
- end
98
- browser.switch_to.default_content
99
- end
100
- end
101
-
102
- Given /^I get text on "(.*)" then store it as "(.*)"$/ do |object, place_holder|
103
- if object.nil?
104
- raise 'No text found'
105
- end
106
- @stored = {} if @stored.nil?
107
- @stored[%/#{place_holder}/] = execute_gettext(object)
108
- end
109
-
110
- # get text for object
111
- # And /^I get text on "(.*?)" then store it into file "(.*)"$/ do |object, file_name|
112
- # patiently do
113
- # $text = execute_gettext(object)
114
- # open($test_data_dir+file_name, 'a+') do |f|
115
- # f << $text + "\n"
116
- # end
117
- # end
118
- # end
119
-
120
- # Fill in a text box or text area with a value from $test_data_dir file
121
- # And /^I set text on "(.*?)" with value from file "(.*)"$/ do |object, file_name|
122
- # patiently do
123
- # expected_file= ($test_data_dir + file_name)
124
- # if File.exist?(expected_file)
125
- # # data_file = File.read(expected_file)
126
- # data_file = read_file(expected_file)
127
- # execute_settext(object, data_file)
128
- # # data_file.each_line do |line|
129
- # # execute_settext(object, line)
130
- # # end
131
- # else
132
- # raise "*** ERROR: File #{file_name} is not existed!"
133
- # end
134
- # end
135
- # end
136
-
137
- # Upload new file windows
138
- When /^I click on "(.*?)" to upload file "(.*?)"$/ do |object, file_name|
139
- patiently do
140
- execute_click_to_upload(object, file_name)
141
- end
142
- end
143
-
144
- # Drag mouse hover on element
145
- When /^I move mouse to element "(.*?)"$/ do |element|
146
- patiently do
147
- execute_hover_mouse_on(element)
148
- end
149
- end
150
-
151
- And /^I click on "(.*?)" and wait (\d+) seconds$/ do |object, seconds|
152
- execute_click(object)
153
- sleep(seconds.to_i)
154
- end
155
-
156
- And /^I drag object "(.*?)" to "(.*?)"$/ do |from_object, object|
157
- patiently do
158
- execute_drag_to_new_object(from_object, object)
159
- end
160
- end
161
-
162
- And /^I type to "(.*)" key is "(.*?)"$/ do |object, keys|
163
- patiently do
164
- keys = var_collect(keys)
165
- execute_sendkeys(object, keys)
166
- end
167
- end
168
-
169
- # Click on ID of link or text of link
170
- When /^I click on "([^\"]*)" link$/ do |link|
171
- patiently do
172
- click_link link
173
- end
174
- end
175
-
176
- # Attach a file to a file upload form field
177
- When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
178
- patiently do
179
- attach_file(field, File.expand_path(path))
180
- end
181
- end
182
-
183
- # double click on web element
184
- Then(/^I double click on element "(.*?)"$/) do |element|
185
- patiently do
186
- double_click(element)
187
- end
188
- end
189
-
190
- # step to resize browser
191
- Then(/^I resize browser window size to width (\d+) and height (\d+)$/) do |width, heigth|
192
- resize_browser(width, heigth)
193
- end
194
-
195
- # step to maximize browser
196
- Then(/^I maximize browser window$/) do
197
- maximize_browser
198
- end
199
-
200
- Then(/^I switch to window having title "(.*?)"$/) do |window_title|
201
- switch_to_window_by_title window_title
202
- end
203
-
204
- Then(/^I take screenshot$/) do
205
- take_screenshot
206
- end
207
-
208
- # steps to scroll web page to top or end
209
- Then(/^I scroll to (top|end) of page$/) do |to|
210
- scroll_page(to)
211
- end
212
-
213
- Then /^I should( not)? see page title as (.*)$/ do |present, title|
214
- check_title(title, present.empty?)
215
- end
216
-
217
- Then(/^I should\s*((?:not)?)\s+see page title having partial text as "(.*?)"$/) do |present, partial_text_title|
218
- check_partial_title(partial_text_title, present.empty?)
219
- end
220
-
221
- # check property for object
222
- Then /^I check property "(.*?)" with "(.*?)" has( | not)? value "(.*?)"$/ do |object, property, negate, value|
223
- value = var_collect(value)
224
- execute_checkproperty(object, property, negate, value)
225
- end
226
-
227
- Then /^the following multiline step should (fail|succeed):$/ do |expectation, multiline_step|
228
- multiline_step = multiline_step.gsub(%{'''}, %{"""})
229
- if expectation == 'fail'
230
- expect { steps(multiline_step) }.to raise_error(RSPEC_EXPECTATION_NOT_MET_ERROR)
231
- else # succeed
232
- steps(multiline_step)
233
- end
234
- end
235
-
236
- Then /^I should see a form with the following values:$/ do |table|
237
- expectations = table.raw
238
- expectations.each do |label, expected_value|
239
- step %(I check property "#{label}" with "text" has value "#{expected_value}")
240
- end
241
- end
242
-
243
- Then /^Status of "([^\"]*)" should be "(disabled|enabled)"$/ do |element, status|
244
- puts "status: #{status} => status =='disabled': #{status =='disabled'}"
245
- foundElement = if(status =='disabled')
246
- find_object(element + "{'disabled':'true'}")
247
- elsif (status =='enabled')
248
- find_object(element + "{'disabled':''}")
249
- else
250
- puts "Error >> '#{status }' status is not support."
251
- exit
252
- end
253
-
254
- if foundElement == nil
255
- puts "Error >> Not found object..."
256
- exit
257
- end
258
- end
259
-
260
- And /^I check( not)? exists element is "(.*?)"$/ do |negate, object|
261
- #negate = negate.strip if negate != nil
262
- execute_checkexists(negate, object,2)
263
- end
264
-
265
- # step to assert checkbox is checked or unchecked
266
- Then(/^checkbox "(.*?)" should be (checked|unchecked)$/) do |element, state|
267
- flag = state == 'checked'
268
- is_checkbox_checked(element, flag)
269
- end
270
-
271
- # steps to assert radio button checked or unchecked
272
- Then(/^radio button "(.*?)" should be (selected|unselected)$/) do |element, state|
273
- flag = state == 'selected'
274
- is_radio_button_selected(element, flag)
275
- end
276
-
277
- # step to assert javascript pop-up alert text
278
- Then(/^I should see alert text as "(.*?)"$/) do |actual_value|
279
- check_alert_text(actual_value)
280
- end
281
-
282
- # step to assert difference in images
283
- Then(/^actual image having (.+) "(.*?)" and expected image having (.+) "(.*?)" should be similar$/) do |actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name|
284
- IFD_Assertion.does_images_similar?(actual_img_access_type, actual_img_access_name, excp_img_access_type, excp_img_access_name)
285
- end
286
-
287
- # step to check element enabled or not
288
- Then(/^element "([^\"]*)" should\s*((?:not)?)\s+be (enabled|disabled)$/) do |element, present, state|
289
- flag = state == 'enabled'
290
- flag = !flag unless present.empty?
291
- check_element_enable(element, flag)
292
- end
293
-
1
+ require_relative 'require_libs'
2
+
3
+ # Navigate to a particular page
4
+ Given(/^I am on the "([^"]*)" page$/) do |url|
5
+ url = check_dynamic_value url
6
+ execute_openbrowser(url)
7
+ end
8
+
9
+ # # Wait for the specific time
10
+ When /^I wait for (\d+) seconds$/ do |second|
11
+ sleep(second.to_i)
12
+ end
13
+
14
+ # Finds a button or link by id, text or value and clicks it
15
+ And /^I click on "([^\"]*)"$/ do |object|
16
+ execute_click(object)
17
+ end
18
+
19
+ # double click on web element
20
+ Then /^I double click on element "(.*?)"$/ do |element|
21
+ double_click(element)
22
+ end
23
+
24
+ # Fill in a text box or text area with a value
25
+ And /^I set text on "(.*?)" with "(.*?)"$/ do |object, text|
26
+ text = check_dynamic_value text
27
+ execute_settext(object, text)
28
+ end
29
+
30
+ # step to maximize browser
31
+ Then(/^I maximize browser window$/) do
32
+ maximize_browser
33
+ end
34
+
35
+ Then /^Capture a screenshot as "(.*)"$/ do |name|
36
+ file_path = $test_data_dir + name.downcase
37
+ page.save_screenshot(file_path)
38
+ end
39
+
40
+ Then(/^I switch to window having title "(.*?)"$/) do |window_title|
41
+ switch_to_window_by_title window_title
42
+ end
43
+
44
+ # steps to scroll web page to top or end
45
+ Then(/^I scroll to (top|end) of page$/) do |to|
46
+ scroll_page(to)
47
+ end
48
+
49
+ # check property for object
50
+ Then /^I check property "(.*?)" with "(.*?)" has( | not)? value "(.*?)"$/ do |object, property, negate, value|
51
+ value = bind_with_dyn_vars value
52
+ execute_checkproperty(object, property, negate, value)
53
+ end
54
+
55
+ # step to assert javascript pop-up alert text
56
+ Then(/^I should see alert text as "(.*?)"$/) do |actual_value|
57
+ check_alert_text(actual_value)
58
+ end
@@ -0,0 +1,100 @@
1
+ class Assertion
2
+ #Assert two files, rows not in order and REMOVE 1 COLUMN OF ID
3
+ def self.do_assertion_csv_tab_non_order(expected_obj, actual_obj)
4
+ for i in (1..expected_obj.length - 1)
5
+ expected_row = expected_obj[i].drop(1).to_s.split("\t")
6
+ found = false
7
+ for j in (1..actual_obj.length - 1)
8
+ actual_row = actual_obj[j].drop(1).to_s.split("\t")
9
+ if (expected_row == actual_row)
10
+ found = true
11
+ break
12
+ end
13
+ end
14
+ assert(found, "Expected Record: [#{expected_obj[i].to_s}] is not included in reporting file")
15
+ end
16
+ end
17
+
18
+ # Assert 2 values
19
+ def self.reg_compare sActual, regValue, isSpecialChar=false
20
+ begin
21
+ if !isSpecialChar
22
+ sActual = sActual.strip
23
+ regValue = regValue.strip.gsub("[", "\\[").gsub("]", "\\]").gsub("(", "\\(").gsub(")", "\\)").gsub(">", "\\>")
24
+ end
25
+ rescue StandardError => myStandardError
26
+ put_log "\n>>> Error: #{myStandardError}"
27
+ end
28
+
29
+ # put_log "\nsActual:#{sActual}, regValue:#{regValue}"
30
+ if ((sActual.nil? and regValue.nil?) or (!sActual.nil? and sActual.empty? and !regValue.nil? and regValue.empty?))
31
+ return true
32
+ end
33
+
34
+ if ((sActual.nil? and !regValue.nil?) or (!sActual.nil? and regValue.nil?))
35
+ return false
36
+ end
37
+
38
+ if (!sActual.nil? and !sActual.empty?)
39
+ sCookActual = sActual.gsub(/\n|\r/, " ")
40
+ if (sCookActual == regValue or (isSpecialChar and sCookActual.include? regValue) or (!isSpecialChar and sCookActual =~ /^.*#{regValue}.*$/))
41
+ return true
42
+ end
43
+ end
44
+
45
+ return false
46
+ end
47
+
48
+ def self.do_assertion_json(expected_obj, actual_obj, options = {})
49
+ # puts "\n\n actual_obj.class: #{actual_obj.class}"
50
+ # puts "\n\n expected_obj.class: #{expected_obj.class}"
51
+
52
+ if expected_obj.kind_of? Hash
53
+ # if options['isIncludedAssertion'].nil? or options['isIncludedAssertion'] == false
54
+ # do_assertion(expected_obj.keys.size, actual_obj.keys.size)
55
+ # end
56
+ expected_obj.keys.each do |key|
57
+ # puts "\n\n key: #{key}"
58
+ # puts "\n\n value: #{expected_obj[key]}"
59
+ # puts "\n\n value: #{actual_obj[key]}"
60
+ if actual_obj[key].nil?
61
+ raise "[%s] expected [%s] but actual value was nil." % [key, expected_obj[key].to_s]
62
+ else
63
+ Assertion.do_assertion_json(expected_obj[key], actual_obj[key], options)
64
+ end
65
+ end
66
+ elsif expected_obj.kind_of? Array
67
+ if options['isIncludedAssertion'].nil? or options['isIncludedAssertion'] == false
68
+ Assertion.do_assertion_json(expected_obj.size, actual_obj.size)
69
+ end
70
+ for i in (0..expected_obj.length-1)
71
+ Assertion.do_assertion_json(expected_obj[i], actual_obj[i], options)
72
+ end
73
+ else
74
+ begin
75
+ Assertion.assert_string_equal(expected_obj.to_s, actual_obj.to_s)
76
+ rescue => e
77
+ raise("Assert fail. \n\n Expected: '#{expected_obj}' \n\n Got: '#{actual_obj}'. Detail info: #{e.message}")
78
+ end
79
+ end
80
+ end
81
+
82
+ def self.assert_string_contain(expected, actual)
83
+ unless (actual.to_s).include? (expected.to_s)
84
+ raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
85
+ end
86
+ end
87
+
88
+ def self.assert_string_equal(expected, actual)
89
+ if expected.to_s != actual.to_s
90
+ raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
91
+ end
92
+ end
93
+
94
+ def self.assert_string_not_equal(expected, actual)
95
+ if expected.to_s == actual.to_s
96
+ raise ("*** ASSERTION ERROR: \nExpected: #{expected}. \nGot: #{actual}.")
97
+ end
98
+ end
99
+
100
+ end