Class: Awetestlib::Regression::Runner
- Inherits:
-
Awetestlib::Runner
- Object
- Awetestlib::Runner
- Awetestlib::Regression::Runner
- Includes:
- ActiveSupport::Inflector, Logging, Browser, DragAndDrop, Find, Legacy, PageData, Tables, UserInput, Utilities, Validations, Waits, Sys
- Defined in:
- lib/awetestlib/regression/runner.rb
Overview
Collects all the components needed to run the script and executes it.
Instance Attribute Summary collapse
-
#browser ⇒ Object
Returns the value of attribute browser.
-
#browser_abbrev ⇒ Object
Returns the value of attribute browser_abbrev.
-
#browser_sequence ⇒ Object
Returns the value of attribute browser_sequence.
-
#cycle ⇒ Object
Returns the value of attribute cycle.
-
#debug_on_fail ⇒ Object
Returns the value of attribute debug_on_fail.
-
#env ⇒ Object
Returns the value of attribute env.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#environment_name ⇒ Object
Returns the value of attribute environment_name.
-
#environment_nodename ⇒ Object
Returns the value of attribute environment_nodename.
-
#environment_url ⇒ Object
Returns the value of attribute environment_url.
-
#library ⇒ Object
Returns the value of attribute library.
-
#log_class ⇒ Object
Returns the value of attribute log_class.
-
#log_path_subdir ⇒ Object
Returns the value of attribute log_path_subdir.
-
#log_properties ⇒ Object
Returns the value of attribute log_properties.
-
#log_queue ⇒ Object
Returns the value of attribute log_queue.
-
#notify_class ⇒ Object
Returns the value of attribute notify_class.
-
#notify_id ⇒ Object
Returns the value of attribute notify_id.
-
#notify_queue ⇒ Object
Returns the value of attribute notify_queue.
-
#output_to_log ⇒ Object
Returns the value of attribute output_to_log.
-
#report_all_test_refs ⇒ Object
Returns the value of attribute report_all_test_refs.
-
#root_path ⇒ Object
Returns the value of attribute root_path.
-
#screencap_path ⇒ Object
Returns the value of attribute screencap_path.
-
#script_file ⇒ Object
Returns the value of attribute script_file.
-
#script_path ⇒ Object
Returns the value of attribute script_path.
-
#script_type ⇒ Object
Returns the value of attribute script_type.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#user_token ⇒ Object
Returns the value of attribute user_token.
-
#version ⇒ Object
Returns the value of attribute version.
-
#xls_path ⇒ Object
Returns the value of attribute xls_path.
Instance Method Summary collapse
- #after_run ⇒ Object
- #before_run ⇒ Object
- #browser_to_use(browser, browser_version = nil) ⇒ Object
-
#initialize(options) ⇒ Runner
constructor
def self.runner_class(options) script_file = options load script_file # force a load.
- #initiate_html_report ⇒ Object
- #module_for(script_file) ⇒ Object
- #open_report_file ⇒ Object
- #require_gems ⇒ Object
-
#setup_global_test_vars(options) ⇒ Object
TODO: Encapsulate in some kind of config.
- #start ⇒ Object
Methods included from Legacy
#check_element_is_disabled, #checkbox_is_disabled?, #checkbox_is_enabled?, #checkbox_not_checked?, #checked_by_id?, #clear_checkbox, #clear_checkbox_by_id, #clear_checkbox_by_name, #clear_radio, #click_button_by_class, #click_button_by_id, #click_button_by_index, #click_button_by_name, #click_button_by_text, #click_button_by_title, #click_button_by_value, #click_button_by_xpath_and_id, #click_button_no_wait_by_class, #click_button_no_wait_by_id, #click_button_no_wait_by_name, #click_button_no_wait_by_text, #click_button_no_wait_by_value, #click_file_field_by_id, #click_img_by_alt, #click_img_by_src, #click_img_by_title, #click_img_by_xpath_and_name, #click_img_no_wait_by_alt, #click_js, #click_link_by_class, #click_link_by_href, #click_link_by_id, #click_link_by_index, #click_link_by_name, #click_link_by_name_no_wait, #click_link_by_text, #click_link_by_text_no_wait, #click_link_by_title, #click_link_by_value, #click_link_by_xpath_and_id, #click_link_no_wait_by_href, #click_link_no_wait_by_id, #click_span_by_text, #click_table_row_with_text_by_id, #click_table_row_with_text_by_index, #click_title_no_wait, #double_click_table_row_with_text_by_id, #double_click_table_row_with_text_by_index, #fire_event_on_image_by_src, #fire_event_on_link_by_id, #fire_event_on_link_by_text, #get_div_by_class, #get_div_by_id, #get_div_by_text, #get_form_by_id, #get_frame_by_id, #get_frame_by_index, #get_frame_by_name, #get_select_options_by_id, #get_select_options_by_name, #get_selected_options_by_id, #get_selected_options_by_name, #get_span_by_id, #get_table, #get_table_by_id, #get_table_by_index, #get_table_by_text, #link_disabled?, #link_enabled?, #link_not_exist?, #radio_is_set?, #select_option_by_class_and_option_text, #select_option_by_id_and_index, #select_option_by_id_and_option_text, #select_option_by_id_and_option_value, #select_option_by_name_and_index, #select_option_by_name_and_option_text, #select_option_by_name_and_option_value, #select_option_by_title_and_option_text, #select_option_by_xpath_and_index, #set_checkbox, #set_checkbox_by_class, #set_checkbox_by_id, #set_checkbox_by_name, #set_checkbox_by_title, #set_checkbox_by_value, #set_file_field_by_id, #set_file_field_by_name, #set_radio, #set_radio_by_class, #set_radio_by_id, #set_radio_by_index, #set_radio_by_name, #set_radio_by_name_and_index, #set_radio_by_name_and_text, #set_radio_by_name_and_value, #set_radio_by_title, #set_radio_by_value, #set_radio_by_value_and_index, #set_textfield_by_class, #set_textfield_by_id, #set_textfield_by_name, #set_textfield_by_title, #span_contains_text?, #text_in_span_equals?, #validate_check_by_class, #validate_div_not_visible_by_id, #validate_div_visible_by_id, #validate_image, #validate_link_exist, #validate_list, #validate_no_list, #validate_radio_not_set, #validate_radioset_by_name, #validate_text_in_span_by_id, #validate_textfield_disabled_by_name, #validate_textfield_empty_by_id, #validate_textfield_empty_by_name, #validate_textfield_empty_by_title, #validate_textfield_enabled_by_name, #validate_textfield_not_value_by_id, #validate_textfield_not_value_by_name, #validate_textfield_not_visible_by_name, #validate_textfield_value_by_id, #validate_textfield_value_by_name, #validate_textfield_visible_by_name, #wait_for_exists, #wait_until_by_link_text, #wait_until_by_radio_value
Methods included from Validations
#arrays_match?, #checked?, #date_string_equals?, #disabled?, #does_not_exist?, #element_contains_text?, #enabled?, #exists?, included, #not_checked?, #not_read_only?, #not_set?, #not_visible?, #popup_is_browser?, #radio_with_value_set?, #read_only?, #ready?, #select_list_does_not_include?, #select_list_includes?, #set?, #string_contains?, #string_does_not_contain?, #string_does_not_equal?, #string_equals?, #text_in_element_equals?, #textfield_contains?, #textfield_does_not_equal?, #textfield_empty?, #textfield_equals?, #validate_list_by_id, #validate_list_by_name, #validate_message, #validate_no_text, #validate_select_list, #validate_select_list_contents, #validate_selected_options, #validate_style_greater_than_value, #validate_style_less_than_value, #validate_style_value, #validate_text, #validate_textfield_dollar_value, #validate_url, #visible?, #window_does_not_exist?, #window_exists?
Methods included from DragAndDrop
#adjust_dimensions_by_percent, #drag_and_drop, #drag_and_drop_element, #get_browser_coord, #get_element_coordinates, #get_resize_handle_by_class, #get_resize_handle_by_id, #hover, #left_click, #move_element_with_handle, #overlay?, #resize_element_with_handle, #right_click, #screen_center, #screen_lower_right, #screen_offset, #validate_drag_drop, #verify_element_inside, #verify_no_element_overlap, #verify_resize
Methods included from PageData
#capture_page_data, #compare_page_data, #fetch_page_data, #get_element_text, #get_textfield_value, #get_textfield_value_by_id, #get_textfield_value_by_name, #parse_elements
Methods included from Tables
#count_data_rows, #count_rows_with_string, #exercise_sorting, #fetch_array_for_table_column, #fetch_hash_for_table_column, #get_cell_count, #get_cell_text_from_row_with_string, #get_column_index, #get_index_for_column_head, #get_index_for_table_containing_text, #get_index_of_last_row, #get_index_of_last_row_with_text, #get_index_of_row_with_text, #get_index_of_row_with_textfield_value, #get_row_cells_text_as_array, #get_table_containing_text, #get_table_headers, #text_in_table?, #text_in_table_row_with_text?, #verify_column_order, #verify_column_sort, #verify_column_sort_temp_ff
Methods included from Waits
#hold_for_text, #sleep_for, #wait_for, #wait_for_element_to_reappear, #wait_for_exists, #wait_the_hard_way, #wait_until, #wait_until_enabled, #wait_until_exists, #wait_until_ready, #wait_until_ready_quiet, #wait_until_text, #wait_until_visible, #wait_while
Methods included from UserInput
#clear, #clear_textfield, #click, #click_img_by_src_and_index, #click_no_wait, #click_popup_button, #click_table_row_with_text, #double_click_table_row_with_text, #fire_event, #select_option, #select_option_from_list, #set, #set_file_field, #set_radio_two_attributes, #set_text_field, #set_text_field_and_validate
Methods included from Find
#find_all_links_with_exact_href, #find_index_for_element, #find_link_with_exact_href, #get_attribute_value, #get_div, #get_element, #get_element_collection, #get_form, #get_frame, #get_ole, #get_select_list, #get_select_options, #get_selected_options, #get_span
Methods included from Browser
#attach_browser, #attach_browser_by_url, #attach_popup, #attach_popup_by_title, #attach_popup_by_url, #bail_out, #basic_auth, #check_for_and_clear_other_browsers, #check_for_other_browsers, #close_modal, #close_modal_c, #close_modal_ff, #close_modal_ie, #close_modal_s, #close_new_window_popup, #close_panel_by_text, #close_popup, #close_popup_by_button_title, #close_popup_by_text, #close_window_by_title, #find_other_browsers, #find_popup, #go_to_url, #go_to_wd_url, #handle_popup, #is_browser?, #kill_browser, #login, #logout, #modal_exists?, #open_browser, #open_chrome, #open_ff, #open_ff_for_version, #open_ie, #open_popup_through_link_title, #token_auth, #translate_popup_title, #validate
Methods included from Utilities
#build_message, #calc_index, #capture_screen, #close_print, #debug_call_list, #do_taskkill, #dump_all_tables, #dump_array, #dump_ole_get_methods, #dump_ole_help, #dump_ole_methods, #dump_row_cells, #dump_select_list_options, #dump_table_and_rows, #dump_table_rows_and_cells, #file_download, #file_upload, #find_sheet_with_name, #flash, #flash_id, #flash_text, #focus_on_textfield_by_id, #get_call_array, #get_call_list, #get_call_list_new, #get_caller_line, #get_debug_list, #get_mdyy, #get_os, #get_prefix, #get_save_file_path, #get_test_level, #get_timestamp, #get_trace, #get_variables, #grab_window_list, #method_to_title, #nice_array, #parse_caller, #parse_cookies, #pdf_to_text, #rescue_me, #rescue_me_command, #save_file, #save_file1, #save_file2, #save_file_orig, #sec2hms, #set_script_variables, #setup, #string_count_in_string, #translate_var_list, #unable_to, #upload_file
Methods included from Logging
#debug_to_log, #debug_to_report, #error_to_log, #failed_to_log, #fatal_to_log, included, #info_to_log, #mark_test_level, #message_to_report, #passed_to_log
Methods inherited from Awetestlib::Runner
Constructor Details
#initialize(options) ⇒ Runner
def self.runner_class(options)
script_file = [:script_file]
load script_file # force a load
runner_module = self.module_for script_file
klass_name = "#{runner_module.to_s}::Runner"
# Define a Runner class in the test script's module inheriting from AwetestLegacy::Runner
runner_module.module_eval do
eval <<-RUBY
class #{klass_name} < Awetestlib::Runner
def initialize(options)
#super(options)
setup_global_test_vars(options)
end
end
RUBY
end
runner = runner_module::Runner.new()
if [:library]
lib_file = [:library]
load lib_file
lib_module = self.module_for lib_file
runner.extend(lib_module)
end
# Add in the methods defined in the script's module
runner.extend(runner_module)
runner
end
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/awetestlib/regression/runner.rb', line 167 def initialize() .each_pair do |k, v| self.send("#{k}=", v) end script_file = [:script_file] load script_file setup_global_test_vars() # load and extend with library module if it exists if [:library] lib_file = [:library] load lib_file # force a fresh load lib_module = module_for lib_file self.extend(lib_module) end # load and extend with script script_file = [:script_file] load script_file # force a fresh load runner_module = module_for script_file self.extend(runner_module) end |
Instance Attribute Details
#browser ⇒ Object
Returns the value of attribute browser.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def browser @browser end |
#browser_abbrev ⇒ Object
Returns the value of attribute browser_abbrev.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def browser_abbrev @browser_abbrev end |
#browser_sequence ⇒ Object
Returns the value of attribute browser_sequence.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def browser_sequence @browser_sequence end |
#cycle ⇒ Object
Returns the value of attribute cycle.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def cycle @cycle end |
#debug_on_fail ⇒ Object
Returns the value of attribute debug_on_fail.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def debug_on_fail @debug_on_fail end |
#env ⇒ Object
Returns the value of attribute env.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def env @env end |
#environment ⇒ Object
Returns the value of attribute environment.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def environment @environment end |
#environment_name ⇒ Object
Returns the value of attribute environment_name.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def environment_name @environment_name end |
#environment_nodename ⇒ Object
Returns the value of attribute environment_nodename.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def environment_nodename @environment_nodename end |
#environment_url ⇒ Object
Returns the value of attribute environment_url.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def environment_url @environment_url end |
#library ⇒ Object
Returns the value of attribute library.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def library @library end |
#log_class ⇒ Object
Returns the value of attribute log_class.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def log_class @log_class end |
#log_path_subdir ⇒ Object
Returns the value of attribute log_path_subdir.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def log_path_subdir @log_path_subdir end |
#log_properties ⇒ Object
Returns the value of attribute log_properties.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def log_properties @log_properties end |
#log_queue ⇒ Object
Returns the value of attribute log_queue.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def log_queue @log_queue end |
#notify_class ⇒ Object
Returns the value of attribute notify_class.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def notify_class @notify_class end |
#notify_id ⇒ Object
Returns the value of attribute notify_id.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def notify_id @notify_id end |
#notify_queue ⇒ Object
Returns the value of attribute notify_queue.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def notify_queue @notify_queue end |
#output_to_log ⇒ Object
Returns the value of attribute output_to_log.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def output_to_log @output_to_log end |
#report_all_test_refs ⇒ Object
Returns the value of attribute report_all_test_refs.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def report_all_test_refs @report_all_test_refs end |
#root_path ⇒ Object
Returns the value of attribute root_path.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def root_path @root_path end |
#screencap_path ⇒ Object
Returns the value of attribute screencap_path.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def screencap_path @screencap_path end |
#script_file ⇒ Object
Returns the value of attribute script_file.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def script_file @script_file end |
#script_path ⇒ Object
Returns the value of attribute script_path.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def script_path @script_path end |
#script_type ⇒ Object
Returns the value of attribute script_type.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def script_type @script_type end |
#timeout ⇒ Object
Returns the value of attribute timeout.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def timeout @timeout end |
#user_token ⇒ Object
Returns the value of attribute user_token.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def user_token @user_token end |
#version ⇒ Object
Returns the value of attribute version.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def version @version end |
#xls_path ⇒ Object
Returns the value of attribute xls_path.
53 54 55 |
# File 'lib/awetestlib/regression/runner.rb', line 53 def xls_path @xls_path end |
Instance Method Details
#after_run ⇒ Object
281 282 283 284 285 286 |
# File 'lib/awetestlib/regression/runner.rb', line 281 def after_run finish_run @report_class.finish_report(@html_report_file) open_report_file @myLog.close if @myLog end |
#before_run ⇒ Object
266 267 268 269 |
# File 'lib/awetestlib/regression/runner.rb', line 266 def before_run initiate_html_report start_run end |
#browser_to_use(browser, browser_version = nil) ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/awetestlib/regression/runner.rb', line 192 def browser_to_use(browser, browser_version = nil) platform = '' platform = 'Windows' if !!((RUBY_PLATFORM =~ /(win|w)(32|64)$/) || (RUBY_PLATFORM =~ /mswin|mingw/)) platform = 'OSX' if RUBY_PLATFORM =~ /darwin/ browser_abbrev = Awetestlib::BROWSER_ALTERNATES[platform][browser] ? Awetestlib::BROWSER_ALTERNATES[platform][browser] : browser if not browser_version case browser_abbrev when 'IE' browser_version = 8 when 'FF' browser_version = 11 when 'C', 'GC' browser_version = 10 when 'S' browser_version = 10 end end return OpenStruct.new( :name => (Awetestlib::BROWSER_MAP[browser_abbrev]), :abbrev => browser_abbrev, :version => browser_version ) end |
#initiate_html_report ⇒ Object
288 289 290 291 292 293 294 |
# File 'lib/awetestlib/regression/runner.rb', line 288 def initiate_html_report @html_report_name = File.join(FileUtils.pwd, 'awetest_reports', @myName) @html_report_dir = File.dirname(@html_report_name) FileUtils.mkdir @html_report_dir unless File.directory? @html_report_dir @report_class = Awetestlib::HtmlReport.new(@myName) @html_report_file = @report_class.create_report(@html_report_name) end |
#module_for(script_file) ⇒ Object
262 263 264 |
# File 'lib/awetestlib/regression/runner.rb', line 262 def module_for(script_file) File.read(script_file).match(/^module\s+(\w+)/)[1].constantize end |
#open_report_file ⇒ Object
296 297 298 299 300 301 302 303 304 305 306 |
# File 'lib/awetestlib/regression/runner.rb', line 296 def open_report_file full_report_file = File.(@html_report_file) if USING_WINDOWS system("explorer file:///#{full_report_file}") elsif USING_OSX system("open #{full_report_file}") else puts "Can find report in #{full_report_file}" end end |
#require_gems ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/awetestlib/regression/runner.rb', line 219 def require_gems case @targetBrowser.abbrev when 'IE' if $watir_script require 'watir/ie' require 'watir' require 'watir/process' require 'watirloo' require 'patches/watir' Watir::IE.visible = true else require 'watir-webdriver' end when 'FF' require 'watir-webdriver' when 'S' require 'watir-webdriver' when 'C', 'GC' require 'watir-webdriver' # when 'CL' # require 'celerity' # require 'watir-webdriver' end if USING_WINDOWS require 'watir/win32ole' @ai = ::WIN32OLE.new('AutoItX3.Control') else # TODO: Need alternative for Mac? @ai = '' end if @xls_path require 'roo' end end |
#setup_global_test_vars(options) ⇒ Object
TODO: Encapsulate in some kind of config
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/awetestlib/regression/runner.rb', line 77 def setup_global_test_vars() @my_failed_count = 0 @my_passed_count = 0 @my_error_references = Hash.new @my_error_hits = Hash.new @report_all_refs = [:report_all_test_refs] if [:environment] @myAppEnv = OpenStruct.new( :name => [:environment]['name'], :url => [:environment]['url'], :nodename => [:environment]['nodename'] ) @runenv = [:environment]['nodename'] || [:environment]['name'] @myURL = [:environment]['url'] else @runenv = [:environment_name] end @targetBrowser = browser_to_use([:browser], [:version]) @targetVersion = @targetBrowser.version @browserAbbrev = @targetBrowser.abbrev @myRoot = [:root_path] || Dir.pwd # NOTE: bug fix pmn 05dec2012 @myName = File.basename([:script_file]).sub(/\.rb$/, '') if [:output_to_log] log_name = "#{@myName}_#{Time.now.strftime("%Y%m%d%H%M%S")}.log" if [:log_path_subdir] FileUtils.mkdir [:log_path_subdir] unless File.directory? [:log_path_subdir] log_path = [:log_path_subdir] log_spec = File.join(log_path, log_name) else log_spec = log_name end @myLog = init_logger(log_spec, @myName) end if [:xls_path] @xls_path = [:xls_path] end #TODO need to find way to calculate these on the fly # window top border 30 # IE toolbars 86 @vertical_hack_ie = 117 # FF toolbars 114 @vertical_hack_ff = 144 # window left border 4 @horizontal_hack_ie = 5 @horizontal_hack_ff = 4 # # @x_tolerance = 12 # @y_tolerance = 12 require_gems end |
#start ⇒ Object
271 272 273 274 275 276 277 278 279 |
# File 'lib/awetestlib/regression/runner.rb', line 271 def start get_os before_run run rescue Exception => e failed_to_log(e.to_s) ensure after_run end |