Ifd_Automation 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/bin/Ifd_Automation +34 -15
  3. data/bin/console +14 -0
  4. data/bin/documentation_generator.rb +119 -0
  5. data/bin/helper.rb +24 -19
  6. data/bin/setup +8 -0
  7. data/lib/Ifd_Automation.rb +2 -1
  8. data/lib/Ifd_Automation/all_steps.rb +8 -0
  9. data/lib/Ifd_Automation/database_steps.rb +106 -0
  10. data/lib/Ifd_Automation/email_steps.rb +67 -82
  11. data/lib/Ifd_Automation/file_steps.rb +30 -0
  12. data/lib/Ifd_Automation/{javascript_handling_steps.rb → javascript_steps.rb} +1 -2
  13. data/lib/Ifd_Automation/required_libs.rb +7 -0
  14. data/lib/Ifd_Automation/response.rb +105 -0
  15. data/lib/Ifd_Automation/ssh_steps.rb +47 -0
  16. data/lib/Ifd_Automation/version.rb +3 -5
  17. data/lib/Ifd_Automation/web_steps.rb +293 -0
  18. data/lib/Ifd_Automation/webservice_steps.rb +261 -0
  19. data/lib/{Ifd_Automation/methods/IFD_Assertion_methods.rb → Ifd_Automation_support/assertion_helpers.rb} +0 -1
  20. data/lib/Ifd_Automation_support/connection_helpers.rb +14 -0
  21. data/lib/{Ifd_Automation/methods → Ifd_Automation_support}/core.rb +103 -34
  22. data/lib/{Ifd_Automation/methods/javascript_handling_methods.rb → Ifd_Automation_support/javascript_helpers.rb} +0 -1
  23. data/lib/Ifd_Automation_support/mail_helpers.rb +17 -0
  24. data/lib/Ifd_Automation_support/selenium_sync_issues.rb +62 -0
  25. data/lib/{Ifd_Automation/methods/web_methods.rb → Ifd_Automation_support/web_steps_helpers.rb} +6 -1
  26. data/project/Gemfile +1 -19
  27. data/project/Gemfile.lock +203 -0
  28. data/project/features/TestData/globalData.yml +3 -11
  29. data/project/features/TestData/sshtest.txt +2 -0
  30. data/project/features/TestData/testfile.sql +2 -0
  31. data/project/features/{TestData/DownloadFolder/test.txt → TestSuite/test} +0 -0
  32. data/project/features/step_definitions/lib_steps/test.rb +16 -0
  33. data/project/features/step_definitions/repositories/project_object.yml +6 -6
  34. data/project/features/support/env.rb +46 -68
  35. data/project/features/support/project_config.yml +6 -37
  36. metadata +231 -51
  37. data/lib/Ifd_Automation/assertion_steps.rb +0 -96
  38. data/lib/Ifd_Automation/lib_file_steps.rb +0 -54
  39. data/lib/Ifd_Automation/lib_schema_data_steps.rb +0 -115
  40. data/lib/Ifd_Automation/lib_web_steps.rb +0 -184
  41. data/lib/Ifd_Automation/lib_webservice_steps.rb +0 -44
  42. data/lib/Ifd_Automation/methods/IFD_Connection.rb +0 -28
  43. data/lib/Ifd_Automation/methods/IFD_email_methods.rb +0 -16
  44. data/lib/Ifd_Automation/methods/IFD_webservice.rb +0 -17
  45. data/lib/Ifd_Automation/methods/database_methods.rb +0 -25
  46. data/lib/Ifd_Automation/methods/db_utils.rb +0 -37
  47. data/lib/Ifd_Automation/methods/error_handling_methods.rb +0 -87
  48. data/lib/Ifd_Automation/methods/lib_var.rb +0 -59
  49. data/lib/Ifd_Automation/methods/misc_methods.rb +0 -33
  50. data/lib/Ifd_Automation/methods/required_files.rb +0 -33
  51. data/lib/Ifd_Automation/methods/util.rb +0 -168
  52. data/lib/Ifd_Automation/methods/web_service_methods.rb +0 -63
  53. data/project/config/cucumber.yml +0 -3
  54. data/project/features/TestData/ExpectedDataFile/test.txt +0 -0
  55. data/project/features/TestData/SqlScript/test.sql +0 -0
  56. data/project/features/TestData/actual_images/infodation.jpg +0 -0
  57. data/project/features/TestData/expected_images/infodation.jpg +0 -0
  58. data/project/features/TestData/image_difference/infodation.jpg +0 -0
  59. data/project/features/TestData/screenshots/infodation.jpg +0 -0
  60. data/project/features/TestSuite/Login/login.feature +0 -11
  61. data/project/features/step_definitions/lib_steps/login_steps.rb +0 -16
@@ -1,54 +0,0 @@
1
- require_relative 'methods/required_files'
2
- Then /^All records in download file "(.*)" must be included in expected file "(.*)"$/ do |dl_file, expected_file|
3
- # Read downloaded file and expected file
4
- actual_file_path = ($_CFWEB['Download Dir'] + dl_file)
5
- expected_file_path= ($_CFWEB['Expected Data Dir'] + expected_file)
6
- if File.exist?(actual_file_path) && File.exist?(expected_file_path)
7
- actual_lines = CSV.read(actual_file_path)
8
- expected_lines = CSV.read(expected_file_path)
9
- # Assert 2 CSV files
10
- IFD_Assertion.do_assertion_csv_tab_non_order(expected_lines, actual_lines)
11
- else
12
- raise "*** ERROR: Please check #{expected_file} or #{expected_file_path} exists."
13
- end
14
-
15
- end
16
-
17
- Then /^I run exe file "(.*)" on windows$/ do |filename|
18
- if File.exist?(filename)
19
- system("'"+filename+"'")
20
- else
21
- raise "*** ERROR: File #{filename} is not existed."
22
- end
23
- end
24
-
25
- Then /^I run exe file from test data location "(.*)" on windows$/ do |filename|
26
- executable_file = $test_data_dir+filename
27
- if File.exist?(executable_file)
28
- system("'"+executable_file+"'")
29
- else
30
- raise "*** ERROR: File #{filename} is not existed"
31
- end
32
- end
33
-
34
- # Delete downloaded file
35
- Then /^I delete previous downloaded (tab|csv) files of "(.*)"$/ do |extension, file_prefix|
36
- #Check file whose name include file_prefix in downloaded folder
37
- Dir.open($_CFWEB['Download Dir']).each do |filename|
38
- #Delete if file exists
39
- if filename.include? file_prefix then
40
- File.delete($_CFWEB['Download Dir']+filename)
41
- end
42
- end
43
- end
44
-
45
- #Delete file from $test_data_dir folder
46
- Then /^I delete file "(.*)" on Data folder/ do |file_name|
47
- file = ($test_data_dir + file_name)
48
- if File.exists?(file)
49
- File.delete(file)
50
- puts "#{file_name} is deleted successfully"
51
- else
52
- puts "#{file_name} does not exists"
53
- end
54
- end
@@ -1,115 +0,0 @@
1
- require_relative 'methods/required_files'
2
- #====================================
3
- # INTERACTION STEPS
4
- #====================================
5
- # Step used to execute a SQL script on a specific schema
6
- And /^I run sql script "([^\"]*)" on "([^\"]*)" schema$/ do |script, schema|
7
- begin
8
- sql = "#{script}"
9
- DatabaseMethods.execute_select(schema, sql)
10
- DatabaseMethods.close_connection(schema)
11
- ensure
12
- end
13
- end
14
- # Step used to execute SQL script from SQL file on specific schema
15
- Given /^I run sql script from file "([^\"]*)" on "([^\"]*)" schema$/ do |sql_script, schema|
16
- expected_data = ($sql_dir + sql_script)
17
- if File.exist?(expected_data)
18
- begin
19
- File.readlines($sql_dir + sql_script).each do |line|
20
- if line.nil? || line =~ /^\s*\n*--/
21
- # puts "\nSQL: " + line;
22
- next;
23
- end
24
- line = line.strip();
25
- line = line[0..-2];
26
- #puts "\nSQL: " + line;
27
- DatabaseMethods.execute_select(schema, line)
28
- sleep(1);
29
- end
30
- puts "*** INFORMATION: #{sql_script} is executed successfully."
31
- DatabaseMethods.close_connection(schema)
32
- ensure
33
- end
34
- else
35
- puts "*** WARNING: #{sql_script} does not exist."
36
- end
37
- end
38
- #====================================
39
- # VERIFICATION STEPS
40
- #====================================
41
- # Step used to check if data exists in database or not
42
- Then /^I should ( not)? see data in table "([^\"]*)" on "([^\"]*)" schema in database as following record:$/ do |negative, table, schema, table_data|
43
- records = Util.read_table_data_from_steps_with_header(table_data.raw)
44
- records = JSON.parse(JSON.generate(records))
45
- puts records
46
- records.each { |values|
47
- table_type_obj = Util.generate_condition_statement(values)
48
- # puts table_type_obj
49
- begin
50
- sql= "select count(*) from #{schema}.#{table} where #{table_type_obj}"
51
- rs = DatabaseMethods.execute_select(schema, sql)
52
- # puts sql
53
- obj_array = Array.new
54
- rs.each { |row|
55
- row.each_pair { |col, value|
56
- assert(false) if negative.nil? && value == 0 || !negative.nil? && value == 1
57
- }
58
- }
59
- ensure
60
- DatabaseMethods.close_connection(schema)
61
- end
62
- }
63
- end
64
- # Step used to check if data exists in database or not with condition in file
65
- Then /^I should ( not)? see data in schema "(.*)" database with SQL query in file "(.*)"$/ do |negative, schema, file|
66
- sql = File.read($sql_dir + file)
67
- filepath = ($sql_dir + file)
68
- if File.exist?(filepath)
69
- begin
70
- rs = DatabaseMethods.execute_select(schema, sql)
71
- obj_array = Array.new
72
- rs.each { |row|
73
- row.each_pair { |col, value|
74
- assert(false) if negative.nil? && value == 0 || !negative.nil? && value == 1
75
- }
76
- }
77
- ensure
78
- DatabaseMethods.close_connection(schema)
79
- end
80
- else
81
- raise "*** ERROR: Please check #{filepath} exists."
82
- end
83
- end
84
-
85
- # Step used to get data from database
86
- Then /^I get "(.*)" data from table "([^\"]*)" on "([^\"]*)" schema in database as following record:$/ do |value, table, schema, table_data|
87
- records = Util.read_table_data_from_steps_with_header(table_data.raw)
88
- records = JSON.parse(JSON.generate(records))
89
- records.each { |values|
90
- table_type_obj = Util.generate_condition_statement(values)
91
- begin
92
- sql= "select #{value} from #{table} where #{table_type_obj}"
93
- sql_count= "select count(*) from #{table} where #{table_type_obj}"
94
- rs = DatabaseMethods.execute_select(schema, sql)
95
- record_result= DatabaseMethods.execute_select(schema, sql_count)
96
- record_result.each { |rows|
97
- rows.each_pair { |cols, values|
98
- @@value_count= values
99
- }
100
- }
101
- if @@value_count == 0
102
- puts ("***WARNING: NOT FOUND #{table_type_obj} in #{schema}")
103
-
104
- else
105
- rs.each { |row|
106
- row.each_pair { |cols, values|
107
- $result=values
108
- }
109
- }
110
- end
111
- ensure
112
- DatabaseMethods.close_connection(schema)
113
- end
114
- }
115
- end
@@ -1,184 +0,0 @@
1
- require_relative 'methods/required_files'
2
- # Navigate to a particular page
3
- Given(/^I am on the "([^"]*)" page$/) do |page|
4
- execute_openbrowser(page)
5
- end
6
-
7
- #Navigating to the login page
8
- Given (/^I am on Login Page$/) do
9
- execute_openbrowser($_CFWEB['Page Address'])
10
- end
11
-
12
- # Wait for the specific time
13
- When /^I wait for (\d+) seconds$/ do |second|
14
- sleep(second.to_i)
15
- end
16
-
17
- # Finds a button or link by id, text or value and clicks it
18
- And /^I click on "([^\"]*)"$/ do |object|
19
- execute_click(object)
20
- end
21
-
22
- # Finds and clicks it with JS
23
- And /^I move mouse to element "([^\"]*)" then click$/ do |object|
24
- execute_mousehoverandclick(object)
25
- end
26
-
27
- # Fill in a text box or text area with a value
28
- And /^I set text on "(.*?)" with "(.*?)"$/ do |object, text|
29
- text = var_collect(text)
30
- text = replace_pipe(text)
31
- execute_settext(object, text)
32
- end
33
-
34
- # set state for check box, combo box
35
- And /^I set state on "(.*?)" with "(.*?)"$/ do |object, state|
36
- execute_setstate(object, state)
37
- end
38
-
39
- # Input data to text box, this function support in case user want to input data into many text boxes on the same time
40
- When /^I input data to web form with following values:$/ do |value|
41
- records = Util.read_table_data_from_steps_with_header(value.raw)
42
- records = JSON.parse(JSON.generate(records))
43
- records.each { |rows|
44
- rows.each { |col, val|
45
- step %{I set text on "#{col}" with "#{val}"}
46
- }
47
- }
48
- end
49
-
50
- When /^I run the following steps?:$/ do |steps_table|
51
- steps = steps_table.raw.flatten
52
- steps.each do |step|
53
- call_step step
54
- end
55
- end
56
-
57
- When /^I click on following elements:$/ do |object|
58
- object.raw.each do |lines|
59
- lines.each do |line|
60
- step %{I click on "#{line}"}
61
- end
62
- end
63
- end
64
-
65
- Then /^I run following steps in iframe (index|name) (.*):$/ do |frame_type, frame, step_table|
66
- case frame_type.to_sym
67
- when :index
68
- steps = step_table.raw.flatten
69
- browser = page.driver.browser
70
- browser.switch_to.frame(frame.to_i)
71
- steps.each do |step|
72
- call_step step
73
- end
74
- browser.switch_to.default_content
75
- when :name
76
- browser = page.driver.browser
77
- browser.switch_to.frame(frame.to_s)
78
- steps.each do |step|
79
- call_step step
80
- end
81
- browser.switch_to.default_content
82
- end
83
- end
84
-
85
- # get text for object
86
- And /^I get text on "(.*?)" then store it into file "(.*)"$/ do |object, file_name|
87
- $text = execute_gettext(object)
88
- open($test_data_dir+file_name, 'a+') do |f|
89
- f << $text + "\n"
90
- end
91
- end
92
-
93
- # Fill in a text box or text area with a value from $test_data_dir file
94
- And /^I set text on "(.*?)" with value from file "(.*)"$/ do |object, file_name|
95
- expected_file= ($test_data_dir + file_name)
96
- if File.exist?(expected_file)
97
- # data_file = File.read(expected_file)
98
- data_file = read_file(expected_file)
99
- execute_settext(object, data_file)
100
- # data_file.each_line do |line|
101
- # execute_settext(object, line)
102
- # end
103
- else
104
- raise "*** ERROR: File #{file_name} is not existed!"
105
- end
106
- end
107
-
108
- # Upload new file windows
109
- When /^I click on "(.*?)" to upload file "(.*?)"$/ do |object, file_name|
110
- execute_click_to_upload(object, file_name)
111
- end
112
-
113
- # Drag mouse hover on element
114
- When /^I move mouse to element "(.*?)"$/ do |element|
115
- execute_hover_mouse_on(element)
116
- end
117
-
118
- And /^I click on "(.*?)" and wait (\d+) seconds$/ do |object, seconds|
119
- execute_click(object)
120
- sleep(seconds.to_i)
121
- end
122
-
123
- And /^I drag object "(.*?)" to "(.*?)"$/ do |from_object, object|
124
- execute_drag_to_new_object(from_object, object)
125
- end
126
-
127
- # And /^I test$/ do
128
- # es_data = File.read("C:/Users/Anh Pham/Desktop/testdata_ES_ruby.txt")
129
- # data = JSON.parse(es_data)
130
- # data['hits']['hits'].each do |child|
131
- # replaced_value = child['_source']['timestamp'].gsub("Oct", "2015-10-").gsub!(/\s+/, "").insert(10, 'T')+ ".112Z"
132
- # new_value = child.to_s.gsub(child['_source']['@timestamp'], "\""+replaced_value+"\"")
133
- # open("D:/IFD Project Automation/Master Branch/features/MYM/Data/test.txt", 'a+') do |f|
134
- # f << new_value + "\n"
135
- # end
136
- # end
137
- # end
138
-
139
- And /^I type to "(.*)" key is "(.*?)"$/ do |object, keys|
140
- keys = var_collect(keys)
141
- execute_sendkeys(object, keys)
142
- end
143
-
144
- # Click on ID of link or text of link
145
- When /^I click on "([^\"]*)" link$/ do |link|
146
- click_link link
147
- end
148
-
149
- # Upload file
150
- When /^I attach the file from location "(.*)" to "(.*)"$/ do |file, field|
151
- filepath = File.join(file)
152
- # if filepath.match(/^C:\//)
153
- # filepath.gsub!(/\//, '\\')
154
- # end
155
- attach_file(field, filepath)
156
- end
157
-
158
- # double click on web element
159
- Then(/^I double click on element "(.*?)"$/) do |element|
160
- double_click(element)
161
- end
162
-
163
- # step to resize browser
164
- Then(/^I resize browser window size to width (\d+) and height (\d+)$/) do |width, heigth|
165
- resize_browser(width, heigth)
166
- end
167
-
168
- # step to maximize browser
169
- Then(/^I maximize browser window$/) do
170
- maximize_browser
171
- end
172
-
173
- Then(/^I switch to window having title "(.*?)"$/) do |window_title|
174
- switch_to_window_by_title window_title
175
- end
176
-
177
- Then(/^I take screenshot$/) do
178
- take_screenshot
179
- end
180
-
181
- # steps to scroll web page to top or end
182
- Then(/^I scroll to (top|end) of page$/) do |to|
183
- scroll_page(to)
184
- end
@@ -1,44 +0,0 @@
1
- require 'nokogiri'
2
- require_relative 'methods/required_files'
3
- # Send POST XML request with data in $test_data_dir
4
- When /^I send a POST XML request to "(.*?)" with the following file "(.*?)"$/ do |type, file|
5
- file = Util.bind_with_dyn_vars(file)
6
- url = Util.bind_with_dyn_vars($WS_URL)
7
- # url=$WS_URL
8
- data = File.read($test_data_dir + file)
9
- $result=IFD_WS.send_XML_post_webservice(url,type,data)
10
- end
11
- # Verify XML response with data is table format
12
- Then /^The XML response of "(.*)" should be the following:$/ do |xpath,table|
13
- data = table.raw
14
- expected_result=data[0][0]
15
- data = Nokogiri::XML.parse($result).remove_namespaces!
16
- actual_result= data.xpath(xpath).to_s
17
- # puts expected_result.to_s
18
- puts actual_result.to_s
19
- # Do assert with the different size of xml
20
- IFD_Assertion.assert_string_equal(expected_result,actual_result)
21
- end
22
- # Send POST XML request with template in $test_data_dir and condition is table format
23
- When /^I send a POST XML request to "(.*?)" with file template "(.*?)" and following conditions:$/ do |type, file, data_table|
24
- file = Util.bind_with_dyn_vars(file)
25
- url = Util.bind_with_dyn_vars($WS_URL)
26
- data = File.read($test_data_dir + file)
27
- raw_data = JSON.parse(JSON.generate(data_table))
28
- header = raw_data[0]
29
- value = raw_data[1]
30
- i = 0
31
- header.zip(value).each do |headers, values|
32
- value_condition = Nokogiri::XML.parse(data).xpath("//"+headers).to_s
33
- tag_value= value_condition[/.*\>(.*?)</, 1]
34
- $new_value = value_condition.gsub(tag_value, values)
35
- if i>0 then
36
- $data_new= $data_new.gsub(value_condition, $new_value)
37
- else
38
- $data_new=data.gsub(value_condition, $new_value)
39
- end
40
- i = i+1
41
- end
42
- $result=IFD_WS.send_XML_post_webservice(url, type, $data_new)
43
- end
44
-
@@ -1,28 +0,0 @@
1
- require 'mysql2'
2
- require 'tiny_tds'
3
-
4
- class IFD_Connections
5
- # Open the MYSQL connection to specific schema
6
- def self.get_mysql_db_connection(schema)
7
- begin
8
- # puts ("Connecting to database...");
9
- data_source_schema = schema.downcase
10
- return Mysql2::Client.new(host: $data_source_url, username: $data_source_username, password: $data_source_password,database:data_source_schema);
11
- rescue Exception => e
12
- raise "Cannot connect to database [username: %s; password: %s, dbUrl: %s, dbName: %s] with error %s" %
13
- [$data_source_username, $data_source_password, $data_source_url,data_source_schema, e.message]
14
- end
15
- end
16
-
17
- # Open the SQL Server connection to specific schema
18
- def self.get_sql_server_db_connection(schema)
19
- begin
20
- # puts ("Connecting to database...");
21
- data_source_schema = schema.downcase
22
- return TinyTds::Client.new(dataserver: $data_source_url, username: $data_source_username, password: $data_source_password, database:data_source_schema);
23
- rescue Exception => e
24
- raise "Cannot connect to database [username: %s; password: %s, dbUrl: %s, dbName: %s] with error %s" %
25
- [$data_source_username, $data_source_password, $data_source_url,data_source_schema, e.message]
26
- end
27
- end
28
- end
@@ -1,16 +0,0 @@
1
- require 'mail'
2
- require 'email_spec'
3
- # include EmailSpec::Helpers
4
- # include EmailSpec::Matcher
5
- class IFD_Email < ActionMailer::Base
6
- def self.send_email(to_address, subject, body_email)
7
- include Mail::Matchers
8
- # Mail::TestMailer.deliveries.clear
9
- Mail.deliver do
10
- from $SEND_EMAIL_USERNAME
11
- to to_address
12
- subject subject
13
- body body_email
14
- end
15
- end
16
- end