Class: Awetestlib::Regression::Runner
- Inherits:
-
Awetestlib::Runner
- Object
- Awetestlib::Runner
- Awetestlib::Regression::Runner
- Includes:
- Logging, Browser, DragAndDrop, Find, PageData, Tables, UserInput, Utilities, Validations, Waits
- Defined in:
- lib/awetestlib/regression/runner.rb
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 Validations
#arrays_match?, #checkbox_is_disabled?, #checkbox_is_enabled?, #checkbox_not_checked?, #checked?, #checked_by_id?, #date_string_equals?, #disabled?, #does_not_exist?, #element_contains_text?, #enabled?, #exists?, included, #link_disabled?, #link_enabled?, #link_not_exist?, #modal_exists?, #not_checked?, #not_read_only?, #not_set?, #not_visible?, #popup_exists?, #radio_is_set?, #radio_with_value_set?, #read_only?, #ready?, #select_list_does_not_include?, #select_list_includes?, #set?, #span_contains_text?, #string_contains?, #string_does_not_contain?, #string_does_not_equal?, #string_equals?, #text_in_element_equals?, #text_in_span_equals?, #textfield_does_not_equal?, #textfield_empty?, #textfield_equals?, #validate_check_by_class, #validate_div_not_visible_by_id, #validate_div_visible_by_id, #validate_drag_drop, #validate_image, #validate_link_exist, #validate_list, #validate_list_by_id, #validate_list_by_name, #validate_message, #validate_no_list, #validate_no_text, #validate_radio_not_set, #validate_radioset_by_name, #validate_select_list, #validate_select_list_contents, #validate_selected_options, #validate_style_value, #validate_text, #validate_text_in_span_by_id, #validate_textfield_disabled_by_name, #validate_textfield_dollar_value, #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, #validate_url, #verify_text_in_table_with_text, #visible?, #window_does_not_exist?, #window_exists?
Methods included from Utilities
#calc_index, #capture_screen, #close_print, #debug_call_list, #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_prefix, #get_save_file_path, #get_timestamp, #get_trace, #get_variables, #grab_window_list, #nice_array, #parse_cookies, #pdf_to_text, #rescue_me, #save_file, #save_file1, #save_file2, #save_file_orig, #sec2hms, #set_script_variables, #setup, #string_count_in_string, #translate_var_list, #upload_file
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, #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, #verify_column_hidden, #verify_column_hidden_temp_ff, #verify_column_order, #verify_column_sort, #verify_column_sort_temp_ff, #verify_column_visible, #verify_column_visible_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_by_link_text, #wait_until_by_radio_value, #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_checkbox, #clear_checkbox_by_id, #clear_checkbox_by_name, #clear_radio, #clear_textfield, #click, #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_src_and_index, #click_img_by_title, #click_img_by_xpath_and_name, #click_img_no_wait_by_alt, #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_no_wait, #click_popup_button, #click_span_by_text, #click_span_with_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, #fire_event_on_image_by_src, #fire_event_on_link_by_id, #fire_event_on_link_by_text, #select_option, #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, #select_option_from_list, #set, #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, #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_radio_no_wait_by_index, #set_radio_two_attributes, #set_text_field, #set_text_field_and_validate, #set_textfield_by_class, #set_textfield_by_id, #set_textfield_by_name, #set_textfield_by_title
Methods included from Find
#find_all_links_with_exact_href, #find_index_for_object, #find_link_with_exact_href, #get_div, #get_div_by_class, #get_div_by_id, #get_div_by_text, #get_element, #get_form, #get_form_by_id, #get_frame, #get_frame_by_id, #get_frame_by_index, #get_frame_by_name, #get_objects, #get_ole, #get_select_list, #get_select_options, #get_select_options_by_id, #get_select_options_by_name, #get_selected_options, #get_selected_options_by_id, #get_selected_options_by_name, #get_span, #get_span_by_id, #get_table, #get_table_by_id, #get_table_by_index, #get_table_by_text, #get_table_headers
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, #do_taskkill, #filter_bailout_from_rescue, #find_other_browsers, #find_popup, #go_to_url, #handle_popup, #is_browser?, #kill_browser, #login, #logout, #open_browser, #open_chrome, #open_ff, #open_ff_for_version, #open_ie, #open_popup_through_link_title, #run, #token_auth, #translate_popup_title, #validate
Methods included from Logging
#capture_error_reference, #debug_to_log, #debug_to_report, #error_to_log, #failed_to_log, #fatal_to_log, #finish_run, #get_caller, included, #info_to_log, #init_logger, #log_message, #log_sikuli_output, #mark_testlevel, #message_to_report, #parse_error_references, #pass_code_for, #passed_to_log, #start_run, #tally_error_references, #translate_severity
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
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/awetestlib/regression/runner.rb', line 158 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.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def browser @browser end |
#browser_abbrev ⇒ Object
Returns the value of attribute browser_abbrev.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def browser_abbrev @browser_abbrev end |
#browser_sequence ⇒ Object
Returns the value of attribute browser_sequence.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def browser_sequence @browser_sequence end |
#cycle ⇒ Object
Returns the value of attribute cycle.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def cycle @cycle end |
#debug_on_fail ⇒ Object
Returns the value of attribute debug_on_fail.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def debug_on_fail @debug_on_fail end |
#env ⇒ Object
Returns the value of attribute env.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def env @env end |
#environment ⇒ Object
Returns the value of attribute environment.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def environment @environment end |
#environment_name ⇒ Object
Returns the value of attribute environment_name.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def environment_name @environment_name end |
#environment_nodename ⇒ Object
Returns the value of attribute environment_nodename.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def environment_nodename @environment_nodename end |
#environment_url ⇒ Object
Returns the value of attribute environment_url.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def environment_url @environment_url end |
#library ⇒ Object
Returns the value of attribute library.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def library @library end |
#log_class ⇒ Object
Returns the value of attribute log_class.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def log_class @log_class end |
#log_path_subdir ⇒ Object
Returns the value of attribute log_path_subdir.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def log_path_subdir @log_path_subdir end |
#log_properties ⇒ Object
Returns the value of attribute log_properties.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def log_properties @log_properties end |
#log_queue ⇒ Object
Returns the value of attribute log_queue.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def log_queue @log_queue end |
#notify_class ⇒ Object
Returns the value of attribute notify_class.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def notify_class @notify_class end |
#notify_id ⇒ Object
Returns the value of attribute notify_id.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def notify_id @notify_id end |
#notify_queue ⇒ Object
Returns the value of attribute notify_queue.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def notify_queue @notify_queue end |
#output_to_log ⇒ Object
Returns the value of attribute output_to_log.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def output_to_log @output_to_log end |
#report_all_test_refs ⇒ Object
Returns the value of attribute report_all_test_refs.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def report_all_test_refs @report_all_test_refs end |
#root_path ⇒ Object
Returns the value of attribute root_path.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def root_path @root_path end |
#screencap_path ⇒ Object
Returns the value of attribute screencap_path.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def screencap_path @screencap_path end |
#script_file ⇒ Object
Returns the value of attribute script_file.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def script_file @script_file end |
#script_path ⇒ Object
Returns the value of attribute script_path.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def script_path @script_path end |
#script_type ⇒ Object
Returns the value of attribute script_type.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def script_type @script_type end |
#timeout ⇒ Object
Returns the value of attribute timeout.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def timeout @timeout end |
#user_token ⇒ Object
Returns the value of attribute user_token.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def user_token @user_token end |
#version ⇒ Object
Returns the value of attribute version.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def version @version end |
#xls_path ⇒ Object
Returns the value of attribute xls_path.
47 48 49 |
# File 'lib/awetestlib/regression/runner.rb', line 47 def xls_path @xls_path end |
Instance Method Details
#after_run ⇒ Object
277 278 279 280 281 282 283 |
# File 'lib/awetestlib/regression/runner.rb', line 277 def after_run finish_run @report_class.finish_report(@html_report_file) open_report_file #finish_run @myLog.close if @myLog end |
#before_run ⇒ Object
263 264 265 266 |
# File 'lib/awetestlib/regression/runner.rb', line 263 def before_run initiate_html_report start_run end |
#browser_to_use(browser, browser_version = nil) ⇒ Object
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/awetestlib/regression/runner.rb', line 183 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
285 286 287 288 289 290 291 |
# File 'lib/awetestlib/regression/runner.rb', line 285 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
259 260 261 |
# File 'lib/awetestlib/regression/runner.rb', line 259 def module_for(script_file) File.read(script_file).match(/^module\s+(\w+)/)[1].constantize end |
#open_report_file ⇒ Object
293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/awetestlib/regression/runner.rb', line 293 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
210 211 212 213 214 215 216 217 218 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 |
# File 'lib/awetestlib/regression/runner.rb', line 210 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' if @targetBrowser.version.to_f < 4.0 require 'firewatir' require 'patches/firewatir' else require 'watir-webdriver' end when 'S' require 'safariwatir' 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
71 72 73 74 75 76 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 |
# File 'lib/awetestlib/regression/runner.rb', line 71 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] @myName = File.basename([:script_file]).sub(/\.rb$/, '') if [:output_to_log] log_path = "#{@myRoot}/" log_path << "#{[:log_path_subdir]}/" if [:log_path_subdir] log_spec = File.join log_path, "#{@myName}_#{Time.now.strftime("%Y%m%d%H%M%S")}.log" @myLog = init_logger(log_spec, @myName) #@start_timestamp = Time.now #start_to_log(@start_timestamp) 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
268 269 270 271 272 273 274 275 |
# File 'lib/awetestlib/regression/runner.rb', line 268 def start before_run run rescue Exception => e failed_to_log(e.to_s) ensure after_run end |