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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39bbb21f99550c1f66c9a0b67e1bd3edd5494687
4
- data.tar.gz: 6431a2284f02b2daab474919c3385ba73bf8acf6
3
+ metadata.gz: 07035f6dc992f2ed0a6d8a62dbddb59e0238235a
4
+ data.tar.gz: 680ee673fcb2f33552acec0e63b545b542a75b19
5
5
  SHA512:
6
- metadata.gz: 8e87cce3aba51ee4e3eac685d1f13e1b3cd2e1011a3a933e70174d298d2399aa2f640565a3f7b25bb335a209233affcb9a53bbf70d71897c5b7e612e61be8be3
7
- data.tar.gz: 347a14a0e29f95442f96ebfb5ce3d567d68d2354fa8da48630b0828ee21b901872bdad3b96157e7b8b1bf0f95434808564ce4f52995f9556ac7bd9a06186d073
6
+ metadata.gz: 91ac9d93f1060929b25b249e5b08da59b914b344f6b0aa3776e55661a6f4d03dea1fbe0e7fbe6b49d4914455a358ca58eac3aeaa9ebd9aa79944a225a0a26a19
7
+ data.tar.gz: e2871d1d54f1888b16ac6e61b9ead46b98bc468c5b058de037e2bd3e252845f535cbef8b4afde369e93fa039ef16fd7add82a50b0148ae230e6509ee3b511ae6
@@ -54,7 +54,7 @@ module DocumentationGenerator
54
54
  end
55
55
 
56
56
  class StepDefinitionFile
57
-
57
+
58
58
  FILE_COMMENT_END = 'FILE_COMMENT_END'
59
59
 
60
60
  include CommentExtractor
@@ -0,0 +1,105 @@
1
+ require_relative 'require_libs'
2
+ require 'httparty'
3
+ When /^I send a REST GET request to "([^\"]*)"$/ do |url|
4
+ url = check_dynamic_value(url)
5
+ puts "\n REST url: #{url}"
6
+ $RESTresult = HTTParty.get url, timeout: 180_000
7
+ end
8
+
9
+ When /^I send a REST POST request to "([^"]*)"$/ do |url|
10
+ url = check_dynamic_value(url)
11
+ puts "\n url: #{url}"
12
+ $RESTresult = HTTParty.post url, timeout: 180_000
13
+ end
14
+
15
+ When /^I send a REST POST request to "(.*?)" with file "(.*?)"$/ do |url, file|
16
+ url = check_dynamic_value(url)
17
+ file = bind_with_dyn_vars(file)
18
+ puts "\n POST url: #{url}"
19
+ data = File.read($test_data_dir + file)
20
+ $RESTresult = HTTParty.post url, {:body => data, :timeout => 180000}
21
+ # puts $result.response.body.to_s
22
+ end
23
+
24
+ When /^I send a REST PUT request to "([^\"]*)"$/ do |url|
25
+ url = check_dynamic_value(url)
26
+ puts "\n PUT url: #{url}"
27
+ $RESTresult = HTTParty.put url, timeout: 180_000
28
+ # puts $result.response.body.to_s
29
+ end
30
+
31
+ When /^I send a REST PUT request to "(.*?)" with file "(.*?)"$/ do |url, file|
32
+ url = check_dynamic_value(url)
33
+ file = bind_with_dyn_vars(file)
34
+ puts "\n url: #{url}"
35
+ data = File.read($test_data_dir + file)
36
+ $RESTresult = HTTParty.put url, body: data, timeout: 180_000
37
+ # puts $result.response.body.to_s
38
+ end
39
+
40
+ When /^I print the result of REST request$/ do
41
+ puts "\n PUT Rest result: #{$RESTresult}"
42
+ end
43
+
44
+ # """
45
+ # {
46
+ # "test" : "anh pham"
47
+ # }
48
+ # """
49
+ When /^I send a REST PUT request to "(.*?)" with json:$/ do |url, data|
50
+ url = check_dynamic_value(url)
51
+ data = data.raw[0][0]
52
+ data = JSON.parse(data) unless data.is_a? Hash
53
+
54
+ data.each_pair do |k, v|
55
+ data[k] = bind_with_dyn_vars(v)
56
+ end
57
+
58
+ $RESTresult = HTTParty.put url, body: data, timeout: 180_000
59
+ end
60
+
61
+ When /^I send a REST DELETE request to "([^\"]*)"$/ do |url|
62
+ url = check_dynamic_value(url)
63
+ # puts "\n\nurl: #{url}"
64
+ $RESTresult = HTTParty.delete url, timeout: 180_000
65
+ # puts $result.response.body.to_s
66
+ end
67
+
68
+ Then /^I should see the REST error message "([^"]*)"$/ do |message|
69
+ $RESTresult.response.body.to_s.should include message
70
+ end
71
+
72
+ Then /^I should see REST response code "([^"]*)"$/ do |code|
73
+ $RESTresult.code.to_s.should == code
74
+ end
75
+
76
+ # Example
77
+ # Then the JSON response should be:
78
+ # """
79
+ # {
80
+ # "test" : "anh pham"
81
+ # }
82
+ # """
83
+ Then /^the JSON response should be:$/ do |json|
84
+ expected = JSON.parse(json)
85
+ actual = JSON.parse($RESTresult.body.to_s)
86
+
87
+ if self.respond_to?(:expect)
88
+ # expect(actual).to eq(expected)
89
+ Assertion.assert_string_equal(actual, expected)
90
+ else
91
+ Assertion.assert_string_contain(actual, expected)
92
+ # assert_equal actual, response
93
+ end
94
+ end
95
+
96
+
97
+ # Example
98
+ # Then the JSON response should have "$..id"
99
+ Then /^the JSON response should have "(.*)"$/ do |json_path|
100
+ json = JSON.parse($RESTresult.body)
101
+ results = JsonPath.new(json_path).on(json).to_a.map(&:to_s)
102
+ if self.respond_to?(:expect)
103
+ expect(results).not_to be_empty
104
+ end
105
+ end
@@ -0,0 +1,54 @@
1
+ require 'savon'
2
+ require_relative 'require_libs'
3
+ require 'jsonpath'
4
+
5
+ # Example
6
+ # When I get SOAP operations list from 'http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx?wsdl'
7
+ When /^I get SOAP operations list from '(.*?)'$/ do |url|
8
+ request_url = URI.encode check_dynamic_value url
9
+ @SOAPclient = Savon.client(ssl_verify_mode: :none,
10
+ wsdl: "#{request_url}",
11
+ :open_timeout => 10,
12
+ :read_timeout => 10,
13
+ :log => false)
14
+ p "Operations List: #{@SOAPclient.operations}"
15
+ end
16
+
17
+ # Example
18
+ # When I send SOAP request with operation name "verify_email" and XML file "soap.xml"
19
+ When /^I send SOAP request with operation name "(.*)" and XML file "(.*)"$/ do |operation_name,file_name|
20
+ xml = File.read($test_data_dir + file_name)
21
+ @response = call_and_fail_gracefully(@SOAPclient, operation_name.downcase.to_sym, xml: xml )
22
+ end
23
+
24
+ # Example
25
+ # I send SOAP request with operation name "xr" and following data:
26
+ # """
27
+ # Sample XML
28
+ # """
29
+ When /^I send SOAP request with operation name "(.*)" and following data:$/ do |operation_name,raw_data|
30
+ @response = call_and_fail_gracefully(@SOAPclient, operation_name.downcase.to_sym, xml: raw_data )
31
+ end
32
+
33
+ Then /^the status code should be "(.*)"$/ do |status|
34
+ Assertion.assert_string_equal(@response.http.code, status.to_i)
35
+ end
36
+
37
+
38
+ # Example
39
+ # Then the SOAP response node should have "$..response_text" with text "Email Domain Not Found"
40
+ Then /^the SOAP response node should have "(.*?)" with text "(.*?)"$/ do |json_path, text|
41
+ json = @response.body.to_json
42
+ results = JsonPath.new(json_path).on(json).to_a.map(&:to_s)
43
+ Assertion.assert_string_equal(text, results[0])
44
+ end
45
+
46
+ Then /^I print the SOAP response$/ do
47
+ p "SOAP RESPONSE: #{@response}"
48
+ end
49
+
50
+ def call_and_fail_gracefully(client, *args, &block)
51
+ client.call(*args, &block)
52
+ rescue Savon::SOAPFault => e
53
+ puts e.message
54
+ end
@@ -1,8 +1,13 @@
1
- require_relative 'required_libs'
1
+ require_relative 'require_libs'
2
+ Given /^I create connection to database with:$/ do |data|
3
+ unless data.hashes.empty?
4
+ data = data.hashes[0]
5
+ data = JSON.parse(data) unless data.is_a? Hash
2
6
 
3
- Given /^I create connection to database with:$/ do |params|
4
- unless params.hashes.empty?
5
- @connection = Connection.new(params.hashes[0])
7
+ data.each_pair do |k, v|
8
+ data[k] = check_dynamic_value(v)
9
+ end
10
+ @connection = Connection.new(data)
6
11
  p "Connect to database successfully!" if @connection
7
12
  end
8
13
  end
@@ -26,31 +31,10 @@ And /^I run multiple sql script:$/ do |raw_data|
26
31
  end
27
32
  end
28
33
 
29
- When /^I run sql script from previous step$/ do
30
- unless @file_data.nil?
31
- begin
32
- @file_data.each_line do |line|
33
- if line.nil? || line =~ /^\s*\n*--/
34
- puts "\nSQL: " + line;
35
- next
36
- end
37
- line = line.strip();
38
- # line = line[0..-2];
39
- p line
40
- @result = @connection.connection().execute(line)
41
- sleep 1
42
- end
43
-
44
- rescue Exception => e
45
- raise e.message
46
- end
47
- end
48
- end
49
-
50
34
  # Example
51
- # When I run sql script "select * from users where email=stored='id'"
35
+ # When I run sql script "select * from users where email=#{id}"
52
36
  And /^I run sql script "(.*)"$/ do |sql|
53
- script = check_match_url sql
37
+ script = check_dynamic_value sql
54
38
  begin
55
39
  @result = @connection.connection().execute(script)
56
40
  rescue Exception => e
@@ -58,7 +42,7 @@ And /^I run sql script "(.*)"$/ do |sql|
58
42
  end
59
43
  end
60
44
 
61
- Then /^Show me the result of SQL statement$/ do
45
+ Then /^show me the result of SQL statement$/ do
62
46
  unless @result.nil?
63
47
  @result.each(:as => :hash) do |row|
64
48
  puts row
@@ -74,7 +58,7 @@ end
74
58
  Then /^the result of SQL statement should be:$/ do |json|
75
59
  expected = JSON.parse(json)
76
60
  @result.each(:as => :hash) do |row|
77
- IFD_Assertion.assert_string_equal(row, expected)
61
+ Assertion.assert_string_equal(expected,row)
78
62
  end
79
63
  end
80
64
 
@@ -83,24 +67,10 @@ end
83
67
  Then /^the result of SQL statement should have "(.*)" with value "(.*)"$/ do |json_path, value|
84
68
  @result.each(:as => :hash) do |row|
85
69
  results = JsonPath.new(json_path).on(row).to_a.map(&:to_s)
86
- IFD_Assertion.assert_string_equal(results[0], value)
87
- end
88
- end
89
-
90
- When /^I store "(.*)" as "(.*)"$/ do |json_path, place_holder|
91
- if @result.nil?
92
- raise 'No record found, a request need to be made first before you can store data'
93
- end
94
- @stored = {} if @stored.nil?
95
- @result.each(:as => :hash) do |row|
96
- @stored[%/#{place_holder}/] = row[%/#{json_path}/]
97
-
70
+ Assertion.assert_string_equal(results[0], value)
98
71
  end
99
72
  end
100
73
 
101
- # def resolve_script script
102
- # unless @stored.nil?
103
- # @stored.each { |key, value| script = script.gsub /\{#{key}\}/, %/'#{value}'/ }
104
- # end
105
- # script
106
- # end
74
+ When /^I store the result of SQL script as "(.*?)"$/ do |var_name|
75
+ set_var(var_name, @result)
76
+ end
@@ -0,0 +1,25 @@
1
+ $result = nil
2
+ $context_value = nil
3
+
4
+ Given /^I get text on "(.*)" then store it as "(.*)"$/ do |object, temp|
5
+ text = execute_gettext(object)
6
+ txt = "'" + text + "'"
7
+ set_var(temp, txt)
8
+ end
9
+
10
+ When /^I store string "(.*?)" as "(.*?)"$/ do |str, var_name|
11
+ $context_value = bind_with_dyn_vars(str)
12
+ set_var(var_name, '$context_value')
13
+ end
14
+
15
+ Given /^I print the value of "(.*)"$/ do |temp|
16
+ puts eval_with_dyn_vars(temp)
17
+ end
18
+
19
+ # get text for object
20
+ And /^I get text on "(.*?)" then store it into file "(.*)"$/ do |object, file_name|
21
+ $text = execute_gettext(object)
22
+ open($test_data_dir+file_name, 'a+') do |f|
23
+ f << $text + "\n"
24
+ end
25
+ end
@@ -1,5 +1,5 @@
1
1
  require 'action_mailer'
2
- require_relative 'required_libs'
2
+ require_relative 'require_libs'
3
3
  # Example:
4
4
  #
5
5
  # Then I send an email with:
@@ -14,21 +14,19 @@ require_relative 'required_libs'
14
14
  # """
15
15
  #
16
16
  Then /^I send an e?mail with:$/ do |raw_data|
17
- patiently do
18
- raw_data.strip!
19
- header, body = raw_data.split(/\n\n/, 2) # 2: maximum number of fields
20
- conditions = {}
21
- header.split("\n").each do |row|
22
- if row.lstrip.chop.match(/^[a-z\-]+:/i)
23
- key, value = row.split(":", 2)
24
- conditions[key.gsub(' ','').underscore.to_sym] = value.gsub(' ','')
17
+ raw_data.strip!
18
+ header, body = raw_data.split(/\n\n/, 2) # 2: maximum number of fields
19
+ conditions = {}
20
+ header.split("\n").each do |row|
21
+ if row.lstrip.chop.match(/^[a-z\-]+:/i)
22
+ key, value = row.split(":", 2)
23
+ conditions[key.gsub(' ','').underscore.to_sym] = value.gsub(' ','')
25
24
 
26
- end
27
25
  end
28
- conditions[:body] = body if body
29
- filepath = ($test_data_dir + conditions[:attachments] if conditions[:attachments])
30
- IFD_Email.send_email(conditions[:to], conditions[:subject], conditions[:body],filepath)
31
26
  end
27
+ conditions[:body] = body if body
28
+ filepath = ($test_data_dir + conditions[:attachments] if conditions[:attachments])
29
+ Email.send_email(conditions[:to], conditions[:subject], conditions[:body],filepath)
32
30
  end
33
31
 
34
32
  # Example:
@@ -46,31 +44,29 @@ end
46
44
  #
47
45
 
48
46
  Then /^I should receive an e?mail with:$/ do |raw_data|
49
- patiently do
50
- raw_data.strip!
51
- header, body = raw_data.split(/\n\n/, 2) # 2: maximum number of fields
52
- conditions = {}
53
- header.split("\n").each do |row|
54
- if row.lstrip.chop.match(/^[a-z\-]+:/i)
55
- key, value = row.split(":", 2)
56
- conditions[key.gsub(' ','').underscore.to_sym] = value.gsub(' ','')
47
+ raw_data.strip!
48
+ header, body = raw_data.split(/\n\n/, 2) # 2: maximum number of fields
49
+ conditions = {}
50
+ header.split("\n").each do |row|
51
+ if row.lstrip.chop.match(/^[a-z\-]+:/i)
52
+ key, value = row.split(":", 2)
53
+ conditions[key.gsub(' ','').underscore.to_sym] = value.gsub(' ','')
57
54
 
58
- end
59
- end
60
- conditions[:body] = body.squeeze(' ').strip if body
61
- sleep 5
62
- emails = Mail.find(:what => :last, :count => 1)
63
-
64
- if emails.instance_of? Mail::Message
65
- IFD_Assertion.assert_string_equal(conditions[:from], emails.from[0].to_s)
66
- IFD_Assertion.assert_string_equal(conditions[:subject], emails.subject)
67
- IFD_Assertion.assert_string_contain(conditions[:body], emails.body)
68
- emails.attachments.each do |attachment|
69
- IFD_Assertion.assert_string_equal(conditions[:attachments], attachment.filename)
70
- end if conditions[:attachments]
71
- else
72
- raise "WARNING: *** No new Email is found"
73
55
  end
74
56
  end
57
+ conditions[:body] = body.squeeze(' ').strip if body
58
+ sleep 5
59
+ emails = Mail.find(:what => :last, :count => 1)
60
+
61
+ if emails.instance_of? Mail::Message
62
+ Assertion.assert_string_equal(conditions[:from], emails.from[0].to_s)
63
+ Assertion.assert_string_equal(conditions[:subject], emails.subject)
64
+ Assertion.assert_string_contain(conditions[:body], emails.body)
65
+ emails.attachments.each do |attachment|
66
+ Assertion.assert_string_equal(conditions[:attachments], attachment.filename)
67
+ end if conditions[:attachments]
68
+ else
69
+ raise "WARNING: *** No new Email is found"
70
+ end
75
71
  end
76
72
 
@@ -1,18 +1,7 @@
1
- Given /^I read data from file "(.*)"$/ do |file_name|
2
- @file_data = ""
3
- file_path = $test_data_dir + file_name.downcase
4
- if File.exist?(file_path)
5
- file = File.open(file_path)
6
- @file_data += file.read
7
- file.close
8
- else
9
- puts "*** WARNING: File #{file_name} does not exist."
10
- end
11
- p @file_data
12
- end
1
+ require_relative 'require_libs'
13
2
 
14
- Then /^I delete file "(.*)"$/ do |file_name|
15
- file_path = ($test_data_dir + file_name)
3
+ Then /^I delete test file "(.*)"$/ do |file_name|
4
+ file_path = ($test_data_dir + file_name.gsub(" ", "_"))
16
5
  if File.exists?(file_path)
17
6
  File.delete(file_path)
18
7
  puts "#{file_name} is deleted successfully"
@@ -21,55 +10,15 @@ Then /^I delete file "(.*)"$/ do |file_name|
21
10
  end
22
11
  end
23
12
 
24
- When /^show me the params of "(.*)"$/ do |params_name|
25
- if $PARAMS["#{params_name.downcase}"]
26
- params_value = $PARAMS["#{params_name.downcase}"]
27
- p params_value
28
- else
29
- p "WARNING: *** Value of parameter #{params_name} not found"
30
- end
31
- end
32
-
33
- Then /^I run exe file "(.*)" on windows$/ do |filename|
34
- if File.exist?(filename)
35
- system("'"+filename+"'")
36
- else
37
- raise "*** ERROR: File #{filename} is not existed."
38
- end
39
- end
40
-
41
- Then /^I run exe file from test data location "(.*)" on windows$/ do |filename|
42
- executable_file = $test_data_dir+filename
43
- if File.exist?(executable_file)
44
- system("'"+executable_file+"'")
45
- else
46
- raise "*** ERROR: File #{filename} is not existed"
47
- end
48
- end
49
-
50
- When /^I store "(.*)" into file "(.*)"$/ do |data,filename|
51
- data = check_match_url data
52
- if File.exist?(filename)
53
- raise "*** WARNING: File #{filename} is already existed. Please delete or change the file name"
54
- else
55
- File.open($test_data_dir+filename, 'w'){|file|
56
- file.write(data)
57
- file.close
58
- }
59
- end
60
- end
61
-
62
- Given /^I read data file "(.*)" and store it as "(.*)"$/ do |file_name, place_holder|
13
+ Given /^I read data from file "(.*)"$/ do |file_name|
63
14
  @file_data = ""
64
- @stored = {}
65
15
  file_path = $test_data_dir + file_name.downcase
66
16
  if File.exist?(file_path)
67
17
  file = File.open(file_path)
68
18
  @file_data += file.read
69
19
  file.close
70
20
  else
71
- puts "*** WARNING: File #{file_name} does not exist."
21
+ raise "*** WARNING: File #{file_name} does not exist."
72
22
  end
73
- @stored[%/#{place_holder}/] = @file_data
74
- p @stored
75
- end
23
+ p @file_data
24
+ end