Ifd_Automation 2.8.2 → 2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/bin/documentation_generator.rb +0 -0
  3. data/bin/generate.rb +0 -6
  4. data/bin/helper.rb +0 -0
  5. data/lib/Ifd_Automation.rb +1 -0
  6. data/{project/features/step_definitions/IFD_Libraries → lib/Ifd_Automation}/REST_steps.rb +0 -0
  7. data/{project/features/step_definitions/IFD_Libraries → lib/Ifd_Automation}/SOAP_steps.rb +0 -0
  8. data/lib/Ifd_Automation/all_steps.rb +0 -0
  9. data/{project/features/step_definitions/IFD_Libraries → lib/Ifd_Automation}/database_steps.rb +1 -1
  10. data/{project/features/step_definitions/IFD_Libraries → lib/Ifd_Automation}/dynamic_store_value_steps.rb +0 -0
  11. data/{project/features/step_definitions/IFD_Libraries → lib/Ifd_Automation}/email_steps.rb +0 -0
  12. data/{project/features/step_definitions/IFD_Libraries → lib/Ifd_Automation}/file_steps.rb +0 -0
  13. data/lib/Ifd_Automation/require_libs.rb +0 -0
  14. data/{project/features/step_definitions/IFD_Libraries → lib/Ifd_Automation}/ssh_steps.rb +0 -0
  15. data/lib/Ifd_Automation/version.rb +1 -1
  16. data/lib/Ifd_Automation/web_steps.rb +109 -0
  17. data/lib/helper/assertion_helper.rb +0 -0
  18. data/lib/helper/auto_util.rb +0 -0
  19. data/lib/helper/database_helper.rb +0 -0
  20. data/lib/helper/file_helper.rb +0 -0
  21. data/lib/helper/mail_helper.rb +0 -0
  22. data/lib/helper/rest_helper.rb +0 -0
  23. data/lib/helper/soap_helper.rb +0 -0
  24. data/lib/helper/ssh_helper.rb +1 -1
  25. data/lib/helper/step_fallback.rb +13 -0
  26. data/lib/helper/tolerance_for_selenium_sync_issues.rb +72 -0
  27. data/lib/helper/web_steps_helper.rb +539 -325
  28. data/project/Gemfile +0 -0
  29. data/project/README.md +5 -21
  30. data/project/cucumber.yml +3 -3
  31. data/project/features/TestData/globalData.yml +0 -0
  32. data/project/features/TestSuite/WebGUI.feature +3 -4
  33. data/project/features/step_definitions/lib_steps/steps_definition.rb +3 -0
  34. data/project/features/step_definitions/repositories/project_object.yml +1 -2
  35. data/project/features/support/env.rb +30 -100
  36. data/project/features/support/hooks.rb +4 -4
  37. data/project/features/support/project_config.rb +13 -0
  38. metadata +30 -23
  39. data/project/Dockerfile +0 -20
  40. data/project/docker-compose.yml +0 -7
  41. data/project/features/Screenshot/sample.jpg +0 -0
  42. data/project/features/step_definitions/IFD_Libraries/web_steps.rb +0 -98
  43. data/project/features/step_definitions/lib_steps/actionwords.rb +0 -9
  44. data/project/features/step_definitions/lib_steps/steps.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79bab1248d7f5d0a920e0f5c6dd7140b0435ae944e5a58f0855594a0db554a8f
4
- data.tar.gz: 05b42b97b11906af46735ff15c1b44e6242aff4770f90794f00251c536216fcb
3
+ metadata.gz: ead647aae45a7dabb8912d9a7be482be5460da9cf7d2274daa47bfa3b55f4c85
4
+ data.tar.gz: 5735834456929b033aa6ddfc677e85c02f9aa3fad5a35ee000cc45fe5abf7e14
5
5
  SHA512:
6
- metadata.gz: 0506005ae122bb0b7a75c21b7654e410d7bde7af442708b40694c4168043e4da51a9ea299d3605b59e51558603a3cb733a6675f887988185d10d7aef2684bb94
7
- data.tar.gz: 728d540e016a22977d5b3e9addbec00aba4b2f31dabf22f68199f3b160bd1e11d9d203294d982d67866153a72b3f9cfa5358dd42d7ed4c3756267eb8a594fd0b
6
+ metadata.gz: d336664be9b300d03336f4f1d5e15df44f6d92d00adb7b749559ea85e4e6e09c8b2799dba66b1f8fec7ffb318e2f97e685eb3c095ff5ec0c69aa66baa94a3f86
7
+ data.tar.gz: 16bcdf590ac0676206de8f09f6314bdea030a979b3259e25386887667c568e5e1cc7b6dc8c1184f332cf1ffca4243870d3c3205271beba7a264d006cf78eb5ba
File without changes
data/bin/generate.rb CHANGED
@@ -25,12 +25,6 @@ def ifd_automation_scaffold
25
25
  msg('README.md') do
26
26
  puts "INFOdation Automation created README.md file with template usage\n"
27
27
  end
28
- msg('Dockerfile') do
29
- puts "INFOdation Automation created Dockerfile\n"
30
- end
31
- msg('docker-compose.yml') do
32
- puts "INFOdation Automation created Dockerfile\n"
33
- end
34
28
  msg('Info') do
35
29
  puts "All Config files created. \n"
36
30
  end
data/bin/helper.rb CHANGED
File without changes
@@ -1,2 +1,3 @@
1
+ require 'cucumber_priority'
1
2
  require "Ifd_Automation/version"
2
3
  Dir[File.dirname(__FILE__) + '/Ifd_Automation/*.rb'].each { |file| require file }
File without changes
@@ -41,4 +41,4 @@ end
41
41
 
42
42
  When /^I store the result of SQL script as "(.*?)"$/ do |var_name|
43
43
  IFD_DBConnection.store_sql_result_into_string(var_name)
44
- end
44
+ end
File without changes
@@ -1,3 +1,3 @@
1
1
  module IfdAutomation
2
- VERSION = "2.8.2"
2
+ VERSION = "2.9"
3
3
  end
@@ -0,0 +1,109 @@
1
+ # require 'cucumber_priority'
2
+ # require 'spreewald_support/tolerance_for_selenium_sync_issues'
3
+ # require 'spreewald_support/step_fallback'
4
+ # require_relative '../helper/web_steps_helper'
5
+
6
+ # Given /I am on the "(.*?)" page/ do |url|
7
+ # patiently do
8
+ # execute_openbrowser(url)
9
+ # end
10
+ # end.overridable
11
+
12
+ # When /I wait for (\d+) seconds/ do |second|
13
+ # sleep(second.to_i)
14
+ # end.overridable
15
+
16
+ # And /I click on "(.*?)"/ do |object|
17
+ # patiently do
18
+ # execute_click(object)
19
+ # end
20
+ # end.overridable
21
+
22
+ # Then /I double click on "(.*?)"/ do |element|
23
+ # patiently do
24
+ # double_click(element)
25
+ # end
26
+ # end.overridable
27
+
28
+ # And /I set text on "(.*?)" with "(.*?)"/ do |object, text|
29
+ # patiently do
30
+ # execute_settext(object, text)
31
+ # end
32
+ # end.overridable
33
+
34
+ # And /I select option on "(.*?)" with "(.*?)"/ do |object, text|
35
+ # patiently do
36
+ # execute_select(object, text)
37
+ # end
38
+ # end.overridable
39
+
40
+ # Then /I maximize browser window/ do
41
+ # maximize_browser
42
+ # end.overridable
43
+
44
+ # Then /I capture a screenshot as "(.*)"/ do |name|
45
+ # file_path = $test_data_dir + name.downcase
46
+ # page.save_screenshot(file_path)
47
+ # end.overridable
48
+
49
+ # Then /I switch to window having title "(.*?)"/ do |window_title|
50
+ # switch_to_window_by_title window_title
51
+ # end.overridable
52
+
53
+ # Then /I scroll to (top|end) of page/ do |to|
54
+ # scroll_page(to)
55
+ # end.overridable
56
+
57
+ # Then /I check property "(.*?)" with "(.*?)" has( | not)? value "(.*?)"/ do |object, property, negate, value|
58
+ # value = Utils.bind_with_dyn_vars value
59
+ # patiently do
60
+ # execute_checkproperty(object, property, negate, value)
61
+ # end
62
+ # end.overridable
63
+
64
+ # Then /I should see text alert "(.*?)"/ do |actual_value|
65
+ # verify_alert_text(actual_value)
66
+ # end.overridable
67
+
68
+ # Given /I move mouse to element "(.*)" and click/ do |object|
69
+ # patiently do
70
+ # execute_mousehoverandclick(object)
71
+ # end
72
+ # end.overridable
73
+
74
+ # And /I remove attribute "(.*)" on object "(.*)"/ do |attr, object|
75
+ # patiently do
76
+ # remove_element_attribute object, attr
77
+ # end
78
+ # end.overridable
79
+
80
+ # And /I set state on "(.*?)" with "(.*?)"/ do |object, state|
81
+ # patiently do
82
+ # execute_setstate(object, state)
83
+ # end
84
+ # end.overridable
85
+
86
+ # And /browser window is re-sized to width "(.*)" and height "(.*)"/ do |x,y|
87
+ # resize_window_screen(x,y)
88
+ # end.overridable
89
+
90
+ # And /I verify object "(.*)" with "(.*)" has value "(.*)"/ do |object,style,expected_value|
91
+ # actual_value = get_computed_style(object,style)
92
+ # patiently do
93
+ # IFD_Assertion.assert_string_equal(expected_value,actual_value)
94
+ # end
95
+ # end.overridable
96
+
97
+ # Then /I should( not)? see page title "(.*)"/ do |present, title|
98
+ # check_title(title, present.empty?)
99
+ # end.overridable
100
+
101
+ # And /I move mouse to element "(.*)" and choose item "(.*)" then click/ do |var, element|
102
+ # patiently do
103
+ # movemouseandclick(var, element)
104
+ # end
105
+ # end.overridable
106
+
107
+ # And /I hold element "(.*)" and move from location x "(.*)" to y "(.*)"$/ do |el, x, y|
108
+ # drag_drop el, x, y
109
+ # end.overridable
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -36,4 +36,4 @@ class IFD_Ssh
36
36
  $context_value = Utils.bind_with_dyn_vars(@output)
37
37
  Utils.set_var(name, '$context_value')
38
38
  end
39
- end
39
+ end
@@ -0,0 +1,13 @@
1
+ # coding: UTF-8
2
+
3
+ module StepFallback
4
+ def step(*args)
5
+ if defined?(super)
6
+ super
7
+ else
8
+ When(*args)
9
+ end
10
+ end
11
+ end
12
+
13
+ World(StepFallback)
@@ -0,0 +1,72 @@
1
+ module ToleranceForSeleniumSyncIssues
2
+ RETRY_ERRORS = %w[
3
+ Capybara::ElementNotFound
4
+ Spec::Expectations::ExpectationNotMetError
5
+ RSpec::Expectations::ExpectationNotMetError
6
+ Minitest::Assertion
7
+ Capybara::Poltergeist::ClickFailed
8
+ Capybara::ExpectationNotMet
9
+ Selenium::WebDriver::Error::StaleElementReferenceError
10
+ Selenium::WebDriver::Error::NoAlertPresentError
11
+ Selenium::WebDriver::Error::ElementNotVisibleError
12
+ Selenium::WebDriver::Error::NoSuchFrameError
13
+ Selenium::WebDriver::Error::NoAlertPresentError
14
+ Selenium::WebDriver::Error::JavascriptError
15
+ Selenium::WebDriver::Error::UnknownError
16
+ Selenium::WebDriver::Error::NoSuchAlertError
17
+ ]
18
+
19
+ class CapybaraWrapper
20
+ def self.default_max_wait_time
21
+ if Capybara.respond_to?(:default_max_wait_time)
22
+ Capybara.default_max_wait_time
23
+ else
24
+ Capybara.default_wait_time
25
+ end
26
+ end
27
+
28
+ def self.default_max_wait_time=(value)
29
+ if Capybara.respond_to?(:default_max_wait_time=)
30
+ Capybara.default_max_wait_time = value
31
+ else
32
+ Capybara.default_wait_time = value
33
+ end
34
+ end
35
+ end
36
+
37
+ class Patiently
38
+ WAIT_PERIOD = 0.05
39
+
40
+ def patiently(seconds, &block)
41
+ started = Time.now
42
+ tries = 0
43
+ begin
44
+ tries += 1
45
+ block.call
46
+ rescue Exception => e
47
+ raise e unless retryable_error?(e)
48
+ raise e if (Time.now - started > seconds && tries >= 2)
49
+ sleep(WAIT_PERIOD)
50
+ raise Capybara::FrozenInTime, "time appears to be frozen, Capybara does not work with libraries which freeze time, consider using time travelling instead" if Time.now == started
51
+ retry
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def retryable_error?(e)
58
+ RETRY_ERRORS.include?(e.class.name)
59
+ end
60
+ end
61
+
62
+
63
+ def patiently(seconds = CapybaraWrapper.default_max_wait_time, &block)
64
+ if page.driver.wait?
65
+ Patiently.new.patiently(seconds, &block)
66
+ else
67
+ block.call
68
+ end
69
+ end
70
+ end
71
+
72
+ World(ToleranceForSeleniumSyncIssues)
@@ -1,436 +1,616 @@
1
1
  require 'net/https'
2
- # Open Browser with config-able maximize browser option
3
- def execute_openbrowser(url_site)
4
- begin
5
- if $_CFWEB['Maximize Browser'] == true
6
- page.driver.browser.manage.window.maximize
7
- end
8
- rescue StandardError => myStandardError
9
- raise "\n>>> Error: #{myStandardError}"
2
+ require 'rspec'
3
+ def execute_openbrowser(url_site)
4
+ begin
5
+ if $_CFWEB['Maximize Browser'] == true
6
+ page.driver.browser.manage.window.maximize
10
7
  end
8
+ rescue StandardError => e
9
+ raise "\n>>> Error: #{e}"
10
+ exit
11
+ end
11
12
 
12
- if url_site == ""
13
- raise "\n>>> Error: Null web page URL."
14
- else
15
- visit(url_site)
16
- end
13
+ if url_site == ""
14
+ raise "\n>>> Error: Null web page URL."
15
+ exit
16
+ else
17
+ visit(url_site)
17
18
  end
19
+ end
18
20
 
19
- def execute_click(element)
20
- foundElement = find_object(element)
21
- if foundElement != nil
22
- page.driver.execute_script('window.focus();')
23
- startTime = Time.new.to_i
24
- begin
25
- sleep(0.5)
26
- currentTime = Time.new.to_i
27
- end while (foundElement.native.enabled? == false and (currentTime - startTime) < $_CFWEB['Wait Time'])
28
- page.driver.browser.execute_script("arguments[0].scrollIntoView(true);", foundElement.native)
29
- page.driver.browser.action.move_to(foundElement.native, element).click.perform
30
- # page.driver.browser.action.click(foundElement.native)
31
- # foundElement.native.send_keys(:return)
32
- else
33
- raise "\nError >> Not found object: #{element}"
21
+ def execute_click(element)
22
+ foundElement = find_object(element)
23
+ if foundElement != nil
24
+ begin
25
+ foundElement.click
26
+ rescue StandardError => e
27
+ raise "\n>>> Error: #{e}"
28
+ exit
34
29
  end
30
+ else
31
+ raise "\nError >> Not found object: #{element}"
32
+ exit
35
33
  end
34
+ end
36
35
 
37
- def double_click(element)
38
- foundElement = find_object(element)
39
- if foundElement != nil
40
- begin
41
- page.driver.browser.action.double_click(foundElement.native)
42
- rescue StandardError => myStandardError
43
- raise "\n>>> Error: #{myStandardError}"
44
- end
45
- else
46
- raise "\nError >> Not found object: #{element}"
36
+ def execute_click_offset(element, x, y)
37
+ foundElement = find_object(element)
38
+ if foundElement != nil
39
+ begin
40
+ page.driver.browser.mouse.move_to(foundElement.native,x.to_i,y.to_i)
41
+ page.driver.browser.mouse.click()
42
+ rescue Exception => e
43
+ raise "\n>>> Error: #{e}"
47
44
  exit
48
45
  end
46
+ else
47
+ raise "\nError >> Not found object: #{element}"
48
+ exit
49
49
  end
50
+ end
50
51
 
51
- def execute_settext(element, text)
52
- foundElement = find_object(element)
53
- if foundElement != nil
54
- begin
55
- foundElement.set(text)
56
- rescue StandardError => myStandardError
57
- raise "\n>>> Error: #{myStandardError}"
58
- end
59
- else
60
- raise "\nError >> Not found object: #{element}"
52
+ def double_click(element)
53
+ foundElement = find_object(element)
54
+ if foundElement != nil
55
+ begin
56
+ foundElement.double_click
57
+ rescue StandardError => e
58
+ raise "\n>>> Error: #{e}"
61
59
  exit
62
60
  end
61
+ else
62
+ raise "\nError >> Not found object: #{element}"
63
+ exit
63
64
  end
65
+ end
64
66
 
65
- def maximize_browser
66
- page.driver.browser.manage.window.maximize
67
+ def execute_settext(element, text)
68
+ foundElement = find_object(element)
69
+ if foundElement != nil
70
+ begin
71
+ foundElement.set(text)
72
+ rescue StandardError => e
73
+ raise "\n>>> Error: #{e}"
74
+ end
75
+ else
76
+ raise "\nError >> Not found object: #{element}"
77
+ exit
67
78
  end
79
+ end
68
80
 
69
- def switch_to_window_by_title(window_title)
70
- $previous_window = page.driver.browser.window_handle
71
- window_found = false
72
- page.driver.browser.window_handles.each { |handle|
73
- page.driver.browser.switch_to.window handle
74
- if page.title == window_title
75
- window_found = true
76
- break
77
- end
78
- }
79
- raise "Window having title \"#{window_title}\" not found" if not window_found
81
+ def maximize_browser
82
+ begin
83
+ page.driver.browser.manage.window.maximize
84
+ rescue StandardError => e
85
+ raise "\n>>> Error: #{e}"
86
+ exit
80
87
  end
88
+ end
81
89
 
82
- def scroll_page(to)
83
- if to == 'end'
84
- page.driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));')
85
- elsif to == 'top'
86
- page.driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);')
87
- else
88
- raise "Exception : Invalid Direction (only scroll \"top\" or \"end\")"
90
+ def switch_to_window_by_title(window_title)
91
+ $previous_window = page.driver.browser.window_handle
92
+ @window_found = false
93
+ page.driver.browser.window_handles.each { |handle|
94
+ page.driver.browser.switch_to.window handle
95
+ if page.title == window_title
96
+ @window_found = true
97
+ break
89
98
  end
99
+ }
100
+ if @window_found == false
101
+ raise "Window having title \"#{window_title}\" not found"
102
+ exit
103
+ end
104
+ end
105
+
106
+ def scroll_to_end_page
107
+ begin
108
+ page.driver.execute_script('window.scrollTo(0,Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight));')
109
+ rescue StandardError => e
110
+ raise "\n>>> Error: #{e}"
111
+ exit
90
112
  end
113
+ end
91
114
 
92
- # Method to verify title
93
- # param 1 : String : expected title
94
- # param 2 : Boolean : test case [true or flase]
95
- def check_title(title, test_case)
115
+ def scroll_to_top_page
116
+ begin
117
+ page.driver.execute_script('window.scrollTo(Math.max(document.documentElement.scrollHeight,document.body.scrollHeight,document.documentElement.clientHeight),0);')
118
+ rescue StandardError => e
119
+ raise "\n>>> Error: #{e}"
120
+ exit
121
+ end
122
+ end
123
+
124
+ def verify_title(expected_title)
125
+ begin
96
126
  page_title = page.title
97
- if test_case
98
- if page_title != "#{title}"
99
- raise "Page Title Not Matched, Actual Page Title : #{page_title}, Expected Page Title : #{title}"
100
- end
101
- else
102
- if page_title == "#{title}"
103
- raise "Page Title Matched, Actual Page Title: #{page_title}"
104
- end
105
- end
127
+ puts "Actual Page Title : #{page_title}, Expected Page Title : #{expected_title}"
128
+ expect(page_title).to eq expected_title
129
+ rescue StandardError => e
130
+ raise "\n>>> Error: #{e}"
131
+ exit
106
132
  end
133
+ end
107
134
 
108
- def check_alert_text(text)
135
+ def verify_alert_text(text)
136
+ begin
109
137
  alert = page.driver.browser.switch_to.alert.text
110
- if alert != text
111
- raise "Text on alert pop up not matched, Actual Text : #{alert}, Expected Text : #{text}"
138
+ puts "Actual Page alert text : #{alert}, Expected value : #{text}"
139
+ expect(alert).to eq text
140
+ rescue StandardError => e
141
+ raise "\n>>> Error: #{e}"
142
+ exit
143
+ end
144
+ end
145
+
146
+ def accept_alert
147
+ begin
148
+ page.driver.browser.switch_to.alert.accept
149
+ rescue Exception => e
150
+ raise "\n>>> ERROR: #{e}"
151
+ exit
152
+ end
153
+ end
154
+
155
+ def back
156
+ begin
157
+ page.execute_script('window.history.back()')
158
+ rescue Exception => e
159
+ raise "\n>>> ERROR: #{e}"
160
+ exit
161
+ end
162
+ end
163
+
164
+ def refresh
165
+ begin
166
+ page.execute_script('window.location.reload()')
167
+ rescue Exception => e
168
+ raise "\n>>> ERROR: #{e}"
169
+ exit
170
+ end
171
+ end
172
+
173
+ def clear_text(element)
174
+ foundElement = find_object(element)
175
+ if foundElement != nil?
176
+ begin
177
+ foundElement.native.clear
178
+ rescue Exception => e
179
+ raise "\n>>> ERROR: #{e}"
180
+ exit
112
181
  end
182
+ else
183
+ raise "\nError >> Not found object: #{element}"
184
+ exit
113
185
  end
186
+ end
114
187
 
115
- def execute_select(element, text)
116
- #select(text, :xpath => element)
117
- foundElement = find_object(element)
188
+ def execute_javascript(script)
189
+ begin
190
+ page.execute_script(script)
191
+ rescue Exception => e
192
+ raise "\nError >> Not found object: #{element}"
193
+ exit
194
+ end
195
+ end
118
196
 
119
- if foundElement != nil
197
+ def execute_select(element, text)
198
+ #select(text, :xpath => element)
199
+ foundElement = find_object(element)
200
+ if foundElement != nil
201
+ begin
120
202
  option_value = page.evaluate_script("$(\"##{foundElement[:id]} option:contains('#{text}')\").val()")
121
203
  page.execute_script("$('##{foundElement[:id]}').val('#{option_value}')")
122
204
  page.execute_script("$('##{foundElement[:id]}').trigger('liszt:updated').trigger('change')")
123
- else
124
- put_log "\nError >> Not found object: #{element}"
205
+ rescue Exception => e
206
+ raise "\n>>> ERROR: #{e}"
125
207
  exit
126
208
  end
209
+ else
210
+ raise "\nError >> Not found object: #{element}"
211
+ exit
127
212
  end
213
+ end
128
214
 
129
- def execute_mousehoverandclick(element)
130
- foundElement = find_object(element)
131
- if foundElement != nil
215
+ def execute_mouse_over(element)
216
+ foundElement = find_object(element)
217
+ if foundElement != nil
218
+ begin
132
219
  page.driver.browser.action.move_to(foundElement.native, element).click.perform
133
220
  sleep(1)
134
- else
135
- put_log "\nError >> Not found object: #{element}"
221
+ rescue StandardError => e
222
+ raise "\n>>> Error: #{e}"
223
+ exit
136
224
  end
225
+ else
226
+ raise "\nError >> Not found object: #{element}"
227
+ exit
137
228
  end
229
+ end
138
230
 
139
- def remove_element_attribute(element, attr)
140
- foundElement = find_object(element)
141
- if foundElement != nil
231
+ def remove_element_attribute(element, attr)
232
+ foundElement = find_object(element)
233
+ if foundElement != nil
234
+ begin
142
235
  page.driver.browser.execute_script("arguments[0].removeAttribute('#{attr}');", foundElement.native)
143
- else
144
- put_log "\nError >> Not found object: #{element}"
236
+ sleep(1)
237
+ rescue StandardError => e
238
+ raise "\n>>> Error: #{e}"
239
+ exit
145
240
  end
241
+ else
242
+ raise "\nError >> Not found object: #{element}"
243
+ exit
146
244
  end
245
+ end
147
246
 
148
247
  # Set state
149
- def execute_setstate(element, state)
150
- foundElement = find_object(element)
151
- if foundElement != nil
152
- if state.upcase == "TRUE"
153
- foundElement.select_option
154
- else
155
- foundElement.unselect_option
156
- end
248
+ def execute_setstate(element, state)
249
+ foundElement = find_object(element)
250
+ if foundElement != nil
251
+ if state
252
+ foundElement.select_option
157
253
  else
158
- put_log "\nError >> Not found object: #{element}"
159
- exit
254
+ foundElement.unselect_option
160
255
  end
256
+ else
257
+ raise "\nError >> Not found object: #{element}"
258
+ exit
161
259
  end
260
+ end
261
+
262
+ def close_windows
263
+ begin
264
+ page.execute_script "window.close();"
265
+ rescue StandardError => e
266
+ raise "\n>>> Error: #{e}"
267
+ exit
268
+ end
269
+ end
162
270
 
163
- def resize_window_screen(x, y)
271
+ def resize_window_screen(x, y)
272
+ begin
164
273
  page.driver.browser.manage.window.resize_to(x, y)
165
274
  puts page.driver.browser.manage.window.size
275
+ rescue StandardError => e
276
+ raise "\n>>> Error: #{e}"
277
+ exit
166
278
  end
279
+ end
167
280
 
168
- def get_computed_style(element, style)
169
- foundElement = get_object_value(element)
170
- computedStyle = ""
171
- if foundElement != nil
172
- computedStyle = page.evaluate_script(
173
- "window.getComputedStyle(document.querySelector('#{foundElement}')).#{style}"
174
- )
175
- else
176
- puts "\nError >> Not found object: #{element}"
177
- end
178
- puts "\nActual object style value is: #{computedStyle}"
179
- computedStyle
281
+ def switch_to_frame(element)
282
+ begin
283
+ page.driver.browser.switch_to.frame 'element'
284
+ rescue Exception => e
285
+ raise "\n>>> Error: #{e}"
286
+ exit
180
287
  end
288
+ end
181
289
 
182
- require 'rspec'
290
+ def get_computed_style(element, style)
291
+ foundElement = get_object_value(element)
292
+ computedStyle = ""
293
+ if foundElement != nil
294
+ computedStyle = page.evaluate_script("window.getComputedStyle(document.querySelector('#{foundElement}')).#{style}")
295
+ else
296
+ raise "\nError >> Not found object: #{element}"
297
+ exit
298
+ end
299
+ puts "\nActual object style value is: #{computedStyle}"
300
+ computedStyle
301
+ end
183
302
 
184
- def put_log str
185
- p str if $_CFWEB['Print Log'] == true
303
+ def put_log str
304
+ p str if $_CFWEB['Print Log'] == true
305
+ end
306
+
307
+ def get_object_value(str_obj)
308
+ string_object = str_obj.gsub(/"/, "'")
309
+ hash_object = $OBJECT[string_object]
310
+ if hash_object == nil
311
+ raise ">>> OBJECT: #{str_obj} NAME MAYBE NOT FOUND!!!"
312
+ exit
186
313
  end
314
+ if hash_object.keys[0].to_s.upcase != "CSS_SELECTOR"
315
+ raise ">>> OBJECT: #{str_obj} should be formatted as Css Selector."
316
+ exit
317
+ end
318
+ hash_object[hash_object.keys[0]]
319
+ end
187
320
 
188
- def get_object_value(str_obj)
189
- string_object = str_obj.gsub(/"/, "'")
190
- hash_object = $OBJECT[string_object]
191
- if hash_object == nil
192
- raise ">>> OBJECT: #{str_obj} NAME MAYBE NOT FOUND!!!"
193
- end
194
- if hash_object.keys[0].to_s.upcase != "CSS_SELECTOR"
195
- raise ">>> OBJECT: #{str_obj} should be formatted as Css Selector."
321
+ def get_element_text(element)
322
+ foundElement = find_object(element)
323
+ if foundElement != nil
324
+ begin
325
+ result = foundElement.text()
326
+ puts "Text of #{element}: #{result}"
327
+ rescue StandardError => e
328
+ raise "\n>>> Error: #{e}"
329
+ exit
196
330
  end
197
- hash_object[hash_object.keys[0]]
331
+ else
332
+ raise "\nError >> Not found object: #{element}"
333
+ exit
198
334
  end
335
+ end
199
336
 
200
- def execute_checkproperty(element, property, negate, value, isSpecialChar=false)
201
- Capybara.configure do |config|
202
- config.ignore_hidden_elements = false
337
+ def get_element_attribute(element,value)
338
+ foundElement = find_object(element)
339
+ if foundElement != nil
340
+ begin
341
+ result = foundElement.value()
342
+ puts "Attribute of #{element}: #{result}"
343
+ rescue StandardError => e
344
+ raise "\n>>> Error: #{e}"
345
+ exit
203
346
  end
204
- foundElement = find_object(element)
347
+ else
348
+ raise "\nError >> Not found object: #{element}"
349
+ exit
350
+ end
351
+ end
205
352
 
206
- check = false
207
- if foundElement == nil and value == ""
208
- check = true
209
- # check.should eq true
210
- expect(check).to eq true
211
- else
212
- # put_log "\n\n\t>>> execute_checkproperty: finish to found element"
213
- if foundElement != nil
214
- if property.upcase == 'VALUE'
215
- actual_value = foundElement.value()
353
+ def verify_element_text(element,value)
354
+ foundElement = find_object(element)
355
+ if foundElement != nil
356
+ begin
357
+ actual_value = foundElement.text()
358
+ put_log "Actual result is: '#{actual_value}' -- Expected result is: '#{value}'"
359
+ expect(actual_value).to eq value
360
+ rescue Exception => e
361
+ raise "\n>>> ERROR: #{e} "
362
+ exit
363
+ end
364
+ else
365
+ raise "\nError >> Not found object: #{element}"
366
+ exit
367
+ end
368
+ end
216
369
 
217
- elsif property.upcase == 'TEXT'
218
- actual_value = foundElement.text()
370
+ def verify_element_not_has_text(element,value)
371
+ foundElement = find_object(element)
372
+ if foundElement != nil
373
+ begin
374
+ actual_value = foundElement.text()
375
+ put_log "Actual result is: '#{actual_value}' -- Expected result is: '#{value}'"
376
+ expect(actual_value).not_to eql value
377
+ rescue Exception => e
378
+ raise "\n>>> ERROR: #{e}"
379
+ exit
380
+ end
219
381
 
220
- elsif property.upcase == 'SPECIAL CHAR'
221
- actual_value = foundElement.text()
222
- isSpecialChar = true
382
+ else
383
+ raise "\nError >> Not found object: #{element}"
384
+ exit
385
+ end
386
+ end
223
387
 
224
- elsif property.upcase == 'TAGNAME'
225
- actual_value = foundElement.tag_name()
388
+ def verify_element_value(element,value)
389
+ foundElement = find_object(element)
390
+ if foundElement != nil
391
+ begin
392
+ actual_value = foundElement.value()
393
+ put_log "Actual result is: '#{actual_value}' -- Expected result is: '#{value}'"
394
+ expect(actual_value).to eq value
395
+ rescue Exception => e
396
+ raise "\n>>> ERROR: #{e}"
397
+ exit
398
+ end
399
+ else
400
+ raise "\nError >> Not found object: #{element}"
401
+ exit
402
+ end
403
+ end
226
404
 
227
- elsif property.upcase == 'STYLE'
228
- actual_value = foundElement[:style]
405
+ def verify_element_not_has_value(element,value)
406
+ foundElement = find_object(element)
407
+ if foundElement != nil
408
+ begin
409
+ actual_value = foundElement.value()
410
+ put_log "Actual result is: '#{actual_value}' -- Expected result is: '#{value}'"
411
+ expect(actual_value).not_to eql value
412
+ rescue Exception => e
413
+ raise "\n>>> ERROR: #{e}"
414
+ exit
415
+ end
416
+ else
417
+ raise "\nError >> Not found object: #{element}"
418
+ exit
419
+ end
420
+ end
229
421
 
230
- elsif property.upcase == 'DISABLED'
231
- actual_value = foundElement[:disabled]
422
+ def execute_checkproperty(element, property, negate, value, isSpecialChar=false)
423
+ validate_option_by(property)
424
+ Capybara.configure do |config|
425
+ config.ignore_hidden_elements = false
426
+ end
427
+ foundElement = find_object(element)
428
+
429
+ check = false
430
+ if foundElement == nil and value == ""
431
+ check = true
432
+ # check.should eq true
433
+ expect(check).to eq true
434
+ else
435
+ # put_log "\n\n\t>>> execute_checkproperty: finish to found element"
436
+ if foundElement != nil
232
437
 
233
- elsif property.upcase == 'WIDTH'
234
- actual_value = foundElement[:width]
438
+ if property.upcase == 'VALUE'
439
+ actual_value = foundElement.value()
235
440
 
236
- elsif property.upcase == 'HEIGHT'
237
- actual_value = foundElement[:height]
441
+ elsif property.upcase == 'TEXT'
442
+ actual_value = foundElement.text()
238
443
 
239
- elsif property.upcase == 'ID'
240
- actual_value = foundElement[:id]
444
+ else
445
+ actual_value = foundElement["#{property}"]
446
+ end
241
447
 
242
- elsif property.upcase == 'NAME'
243
- actual_value = foundElement[:name]
448
+ if actual_value == nil
449
+ actual_value = ''
450
+ end
451
+ else
452
+ put_log "\nError >> Not found object: #{element}"
453
+ end
244
454
 
245
- elsif property.upcase == 'CLASS'
246
- actual_value = foundElement[:class]
455
+ Capybara.configure do |config|
456
+ config.ignore_hidden_elements = true
457
+ end
247
458
 
248
- elsif property.upcase == 'HREF'
249
- actual_value = foundElement[:href]
459
+ # if IFD_Assertion.reg_compare(actual_value, value, isSpecialChar)
460
+ # check = true
461
+ # end
250
462
 
251
- elsif property.upcase == 'TITLE'
252
- actual_value = foundElement[:title]
463
+ put_log "\n#{property} :: Actual result is: '#{actual_value}' -- Expected result is: '#{value}'"
253
464
 
254
- elsif property.upcase == 'TYPE'
255
- actual_value = foundElement[:type]
465
+ if negate == " not"
466
+ actual_value.should_not eq value
467
+ expect(actual_value).not_to eql value
468
+ elsif actual_value.should eq value
469
+ expect(actual_value).to eq value
470
+ end
471
+ end
472
+ end
256
473
 
257
- elsif property.upcase == 'CHECKED'
258
- actual_value = "true" if foundElement.checked? == true
259
- actual_value = "false" if foundElement.checked? == false
260
- else
261
- actual_value = foundElement["#{property}"]
262
- end
474
+ def check_valid_option_by?(option_by)
475
+ %w(text value).include? option_by
476
+ end
263
477
 
264
- if actual_value == nil
265
- actual_value = ''
266
- end
267
- else
268
- put_log "\nError >> Not found object: #{element}"
269
- end
478
+ def validate_option_by(option_by)
479
+ raise "Please select valid option, invalid option - #{option_by}" unless check_valid_option_by? option_by
480
+ end
270
481
 
271
- Capybara.configure do |config|
272
- config.ignore_hidden_elements = true
273
- end
482
+ def check_valid_keys?(key)
483
+ %w(:cancel :help :backspace :tab :clear :return :enter :shift :control :alt :pause :escape :space :page_up :page_down :end :home :left :up :right :down :insert :delete :semicolon :equals).include? key
484
+ end
274
485
 
275
- # if IFD_Assertion.reg_compare(actual_value, value, isSpecialChar)
276
- # check = true
277
- # end
486
+ def validate_supported_keys(key)
487
+ raise "Please select valid keys, invalid key - #{key}" unless check_valid_option_by? key
488
+ end
278
489
 
279
- put_log "\n#{property} :: Actual result is: '#{actual_value}' -- Expected result is: '#{value}'"
280
490
 
281
- if negate == " not"
282
- actual_value.should_not eq value
283
- expect(actual_value).not_to eql value
284
- elsif actual_value.should eq value
285
- expect(actual_value).to eq value
286
- end
287
- end
491
+ def find_object(string_object)
492
+ startTime = Time.new.to_i
493
+ string_object = string_object.gsub(/"/, "'")
494
+ locator_matching = /(.*?)(\{.*?\})/.match(string_object)
495
+ dyn_pros = {}
496
+ if locator_matching != nil
497
+ string_object = locator_matching[1]
498
+ eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
499
+ dyn_pros[k.to_s.upcase] = v
500
+ }
288
501
  end
289
502
 
290
- def execute_gettext(element)
291
- foundElement = find_object(element)
292
- if foundElement != nil
293
- tagname = foundElement.tag_name()
503
+ hash_object = $OBJECT[string_object]
504
+ if hash_object == nil
505
+ raise "ERROR: >>> Object: #{string_object} is not found in Object Repository."
506
+ end
507
+ upcase_attrb = {}
508
+ if hash_object != nil
509
+ hash_object.each { |k, v|
510
+ k = k.to_s.upcase
511
+ if k =~ /ph_/i
512
+ if dyn_pros[k] != nil
513
+ if v =~ /<ph_value>/i
514
+ upcase_attrb[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k])
515
+ else
516
+ upcase_attrb[k[3..k.size-1]] = dyn_pros[k]
517
+ end
294
518
 
295
- if tagname.upcase == 'SELECT'
296
- else
297
- actual_text = foundElement.text()
298
- if (actual_text == nil or actual_text.length == 0) and (tagname.upcase == 'INPUT' or tagname.upcase == 'TEXTAREA')
299
- actual_text = foundElement.value()
519
+ dyn_pros.delete(k)
300
520
  end
521
+ else
522
+ upcase_attrb[k.to_s.upcase] = v
301
523
  end
302
524
 
303
- put_log "\nText is '" + actual_text + "' of object '" + element + "'"
304
- $context_value = actual_text
525
+ }
526
+ end
527
+ ph_attrs = {}
528
+ dyn_pros.each { |k, v|
529
+ if k =~ /ph_/i
530
+ ph_attrs[k] = v
305
531
  else
306
- put_log "\nError >> Not found object: #{element}"
307
- exit
532
+ upcase_attrb[k.to_s.upcase] = v
308
533
  end
309
- end
534
+ }
310
535
 
311
- def find_object(string_object)
312
- startTime = Time.new.to_i
313
- string_object = string_object.gsub(/"/, "'")
314
- locator_matching = /(.*?)(\{.*?\})/.match(string_object)
315
- dyn_pros = {}
316
- if locator_matching != nil
317
- string_object = locator_matching[1]
318
- eval(locator_matching[2].gsub(/['][\s,\t]*?:[\s,\t]*?[']?/, "'=>'")).each { |k, v|
319
- dyn_pros[k.to_s.upcase] = v
320
- }
321
- end
536
+ if upcase_attrb.size > 0
537
+ strCssSelector = ""
538
+ strXpathSelector = ""
322
539
 
323
- hash_object = $OBJECT[string_object]
324
- if hash_object == nil
325
- raise "ERROR: >>> Object: #{string_object} is not found in Object Repository."
326
- end
327
- upcase_attrb = {}
328
- if hash_object != nil
329
- hash_object.each { |k, v|
330
- k = k.to_s.upcase
331
- if k =~ /ph_/i
332
- if dyn_pros[k] != nil
333
- if v =~ /<ph_value>/i
334
- upcase_attrb[k[3..k.size-1]] = v.gsub(/<ph_value>/i, dyn_pros[k])
335
- else
336
- upcase_attrb[k[3..k.size-1]] = dyn_pros[k]
337
- end
338
-
339
- dyn_pros.delete(k)
340
- end
341
- else
342
- upcase_attrb[k.to_s.upcase] = v
343
- end
344
540
 
345
- }
346
- end
347
- ph_attrs = {}
348
- dyn_pros.each { |k, v|
349
- if k =~ /ph_/i
350
- ph_attrs[k] = v
541
+ upcase_attrb.each { |key, value|
542
+ upcase_key = key.to_s.upcase
543
+ case upcase_key
544
+ when "XPATH_SELECTOR"
545
+ strXpathSelector = value
546
+ when "CSS_SELECTOR"
547
+ strCssSelector = value
351
548
  else
352
- upcase_attrb[k.to_s.upcase] = v
549
+ raise "ERROR: >>> Wrong format type: #{key.to_s} of object: #{string_object}. Available supported format are: XPATH_SELECTOR and CSS_SELECTOR"
353
550
  end
354
551
  }
355
552
 
356
- if upcase_attrb.size > 0
357
- strCssSelector = ""
358
- strXpathSelector = ""
359
-
360
-
361
- upcase_attrb.each { |key, value|
362
- upcase_key = key.to_s.upcase
363
- case upcase_key
364
- when "XPATH_SELECTOR"
365
- strXpathSelector = value
366
- when "CSS_SELECTOR"
367
- strCssSelector = value
368
- else
369
- raise "ERROR: >>> Wrong format type: #{key.to_s} of object: #{string_object}. Available supported format are: XPATH_SELECTOR and CSS_SELECTOR"
370
- end
371
- }
372
-
373
- begin
374
- if strCssSelector != nil and strCssSelector.length > 0
375
- foundElements = get_objects_by_css_selector(strCssSelector)
376
- else
377
- foundElements = get_objects_by_xpath_selector(strXpathSelector)
378
- end
379
- if foundElements == nil or foundElements.length == 0
380
- currentTime = Time.new.to_i
381
- else
382
- put_log "\nBREAK!!!"
553
+ begin
554
+ if strCssSelector != nil and strCssSelector.length > 0
555
+ foundElements = get_objects_by_css_selector(strCssSelector)
556
+ else
557
+ foundElements = get_objects_by_xpath_selector(strXpathSelector)
558
+ end
559
+ if foundElements == nil or foundElements.length == 0
560
+ currentTime = Time.new.to_i
561
+ else
562
+ # put_log "\nBREAK!!!"
563
+ break
564
+ end
565
+ test = currentTime - startTime
566
+ # put_log "\n#TIMEOUNT:#{test} < #{$_CFWEB['Wait Time']}"
567
+ sleep(0.5)
568
+ end while (currentTime - startTime) < $_CFWEB['Wait Time']
569
+
570
+ if foundElements != nil or foundElements.length != 0
571
+ return_element = nil
572
+ foundElements.each { |cur_element|
573
+ passCheck = find_object_check_object(cur_element)
574
+ if passCheck
575
+ return_element = cur_element
383
576
  break
384
577
  end
385
- test = currentTime - startTime
386
- put_log "\n#TIMEOUNT:#{test} < #{$_CFWEB['Wait Time']}"
387
- sleep(0.5)
388
- end while (currentTime - startTime) < $_CFWEB['Wait Time']
389
-
390
- if foundElements != nil or foundElements.length != 0
391
- return_element = nil
392
- foundElements.each { |cur_element|
393
- passCheck = find_object_check_object(cur_element)
394
- if passCheck
395
- return_element = cur_element
396
- break
397
- end
398
- }
399
- return return_element
400
- end
578
+ }
579
+ return return_element
401
580
  end
402
-
403
- nil
404
581
  end
405
582
 
406
- def get_objects_by_css_selector(strCssSelector)
407
- foundElements = nil
408
- begin
409
- foundElements = page.all(:css, strCssSelector)
410
- rescue StandardError => myStandardError
411
- raise "\n>>> Error: #{myStandardError}"
412
- end
583
+ nil
584
+ end
413
585
 
414
- foundElements
586
+ def get_objects_by_css_selector(strCssSelector)
587
+ foundElements = nil
588
+ begin
589
+ foundElements = page.all(:css, strCssSelector)
590
+ rescue StandardError => e
591
+ raise "\n>>> Error: #{e}"
415
592
  end
593
+ foundElements
594
+ end
416
595
 
417
- def get_objects_by_xpath_selector(strXpathSelector)
418
- foundElements = nil
419
- begin
420
- foundElements = page.all(:xpath, strXpathSelector)
421
- rescue StandardError => myStandardError
422
- put_log "\n>>> Error: #{myStandardError}"
423
- end
424
- foundElements
596
+ def get_objects_by_xpath_selector(strXpathSelector)
597
+ foundElements = nil
598
+ begin
599
+ foundElements = page.all(:xpath, strXpathSelector)
600
+ rescue StandardError => e
601
+ raise "\n>>> Error: #{e}"
602
+ exit
425
603
  end
604
+ foundElements
605
+ end
426
606
 
427
- def find_object_check_object(cur_element)
428
- passCheck = true
429
- if cur_element != nil
430
- return passCheck
431
- end
432
- false
607
+ def find_object_check_object(cur_element)
608
+ passCheck = true
609
+ if cur_element != nil
610
+ return passCheck
433
611
  end
612
+ false
613
+ end
434
614
 
435
615
  def get_object_and_store_as_string(object,string)
436
616
  text = execute_gettext(object)
@@ -446,9 +626,43 @@ def get_object_and_store_to_file(object,file_name)
446
626
  end
447
627
  end
448
628
 
449
- def drag_drop el, x, y
450
- foundElement = page.driver.browser.find_element(css: "#{el}")
451
- page.driver.browser.action.drag_and_drop_by(foundElement, x, y).perform
629
+ def drag_and_drop_by_offset(element, x, y)
630
+ foundElement = find_object(element)
631
+ if foundElement != nil
632
+ begin
633
+ page.driver.browser.action.drag_and_drop_by(foundElement, x, y).perform
634
+ rescue Exception => e
635
+ raise "\n>>> ERROR: #{e}"
636
+ exit
637
+ end
638
+ else
639
+ raise "\nError >> Not found object: #{element}"
640
+ exit
641
+ end
642
+ end
643
+
644
+ def drag_and_drop_to_object(from_element, element)
645
+ found_from_element = find_object(from_element)
646
+ foundElement = find_object(element)
647
+ if foundElement != nil and found_from_element != nil
648
+ found_from_element.drag_to(foundElement)
649
+ end
650
+ end
651
+
652
+ def execute_sendkeys(element, key)
653
+ validate_supported_keys(key)
654
+ foundElement = find_object(element)
655
+ if foundElement != nil
656
+ begin
657
+ foundElement.native.send_keys(key)
658
+ rescue Exception => e
659
+ raise "\n>>> ERROR: #{e}"
660
+ exit
661
+ end
662
+ else
663
+ raise "\nError >> Not found object: #{element}"
664
+ exit
665
+ end
452
666
  end
453
667
 
454
668
  def movemouseandclick var, element