Module: Awetestlib::Regression::Browser
- Included in:
- Runner
- Defined in:
- lib/awetestlib/regression/browser.rb
Instance Method Summary collapse
-
#attach_browser(browser, how, what, desc = '') ⇒ Object
:category: A_rdoc_test.
-
#attach_browser_by_url(browser, pattern, desc = '') ⇒ Object
(also: #attach_browser_with_url)
:category: A_rdoc_test Returns a reference to a browser window using the window’s url.
-
#attach_popup(browser, how, what, desc = '') ⇒ Object
:category: A_rdoc_test Returns a reference to a new browser window.
- #attach_popup_by_title(browser, strg, desc = '') ⇒ Object
- #attach_popup_by_url(browser, pattern, desc = '') ⇒ Object (also: #get_popup_with_url, #attach_popup_with_url, #attach_iepopup)
- #bail_out(browser, lnbr, msg) ⇒ Object
-
#basic_auth(browser, user, pswd, url, bypass_validate = false) ⇒ Object
category: Logon :tags:logon, login, user, password, url, basic authorization.
- #check_for_and_clear_other_browsers ⇒ Object
- #check_for_other_browsers ⇒ Object
-
#close_modal(browser, title = "", button = "OK", text = '', side = 'primary', wait = WAIT) ⇒ Object
#close a modal dialog.
-
#close_modal_c(browser, title) ⇒ Object
TODO: Logging.
-
#close_modal_ff(browser, title = "", button = nil, text = "", side = '') ⇒ Object
private :close_modal_ie.
- #close_modal_ie(browser, title = "", button = "OK", text = '', side = 'primary', wait = WAIT, desc = '', quiet = false) ⇒ Object
-
#close_modal_s ⇒ Object
TODO: Logging.
-
#close_new_window_popup(popup) ⇒ Object
close popup in new window.
- #close_panel_by_text(browser, panel, strg = 'Close') ⇒ Object
-
#close_popup(title, button = "OK", text = '', side = 'primary', wait = WAIT, desc = '', quiet = false) ⇒ Object
(also: #close_popup_validate_text)
def close_modal_ie(title=“”, button=“OK”, text=”, side = ‘primary’, wait = WAIT).
- #close_popup_by_button_title(popup, strg, desc = '') ⇒ Object
- #close_popup_by_text(popup, strg = 'Close', desc = '') ⇒ Object
- #close_window_by_title(browser, title, desc = '', text = '') ⇒ Object
- #do_taskkill(severity, pid) ⇒ Object
- #filter_bailout_from_rescue(err, msg) ⇒ Object
- #find_other_browsers ⇒ Object
- #find_popup(browser, how, what, desc = '') ⇒ Object
- #go_to_url(browser, url = nil, redirect = nil) ⇒ Object
- #handle_popup(title, text = '', button = 'OK', side = 'primary', wait = WAIT, desc = '') ⇒ Object
- #is_browser?(browser) ⇒ Boolean (also: #is_browser)
- #kill_browser(hwnd, lnbr, browser = nil, doflag = false) ⇒ Object
-
#login(browser, user, password) ⇒ Object
:category: Basic :tags:logon, login, user, password, url TODO: Needs to be more flexible about finding login id and password textfields TODO: Parameterize url and remove references to environment.
- #logout(browser, where = @myName, lnbr = __LINE__) ⇒ Object
-
#open_browser(url = nil) ⇒ Object
:category: A_rdoc_test Opens a browser and returns a reference to it.
- #open_chrome ⇒ Object
- #open_ff ⇒ Object
- #open_ff_for_version(version = @targetVersion) ⇒ Object
- #open_ie ⇒ Object
- #open_popup_through_link_title(browser, title, pattern, name) ⇒ Object
-
#run ⇒ Object
DO WE NEED? Use this method to tell user they need to create a run method?.
- #token_auth(browser, role, token, id = 'token_pass') ⇒ Object
- #translate_popup_title(title) ⇒ Object
-
#validate(browser, fileName = '', lnbr = __LINE__, dbg = false) ⇒ Object
(also: #validate_browser)
Verifies health of the browser.
Instance Method Details
#attach_browser(browser, how, what, desc = '') ⇒ Object
:category: A_rdoc_test
Returns a reference to a browser window. Used to attach a browser window to a variable which can then be passed to methods that require a browser parameter.
- Parameters
-
browser - a reference to the browser window to be tested
how - the browser attribute used to identify the window: either :url or :title
what - a string or a regular expression in the url or title
desc - a string containing a message or description intended to appear in the log and/or report output
Example
mainwindow = open_browser('www.myapp.com') # open a browser to www.google.com click(mainwindow, :button, :id, 'an id string') # click a button that opens another browser window popup = attach_browser(mainwindow, :url, '[url of new window]') #*or* popup = attach_browser(mainwindow, :title, '[title of new window]')
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/awetestlib/regression/browser.rb', line 239 def attach_browser(browser, how, what, desc = '') debug_to_log("Attaching browser window :#{how}=>'#{what}' #{desc}") uri_decoded_pattern = URI.encode(what.to_s.gsub('(?-mix:', '').gsub(')', '')) case @browserAbbrev when 'IE' tmpbrowser = Watir::IE.attach(how, what) browser.visible = true if tmpbrowser tmpbrowser.visible = true tmpbrowser.speed = :fast else raise "Browser window :#{how}=>'#{what}' has at least one doc not in completed ready state." end when 'FF' #TODO: This may be dependent on Firefox version if webdriver doesn't support 3.6.17 and below browser.driver.switch_to.window(browser.driver.window_handles[0]) browser.window(how, /#{uri_decoded_pattern}/).use tmpbrowser = browser when 'S' Watir::Safari.attach(how, what) tmpbrowser = browser when 'C' browser.window(how, /#{uri_decoded_pattern}/).use tmpbrowser = browser end debug_to_log("#{__method__}: tmpbrowser:#{tmpbrowser.inspect}") tmpbrowser end |
#attach_browser_by_url(browser, pattern, desc = '') ⇒ Object Also known as: attach_browser_with_url
:category: A_rdoc_test Returns a reference to a browser window using the window’s url. Calls attach_browser().
- Parameters
-
browser - a reference to the browser window to be tested
pattern - a string with the complete url or a regular expression containing part of the url that uniquely identifies it in the context of the test.
desc - a string containing a message or description intended to appear in the log and/or report output
Example
mainwindow = open_browser('www.myapp.com') # open a browser to www.google.com click(mainwindow, :button, :id, 'an id string') # click a button that opens another browser window popup = attach_browser_by_url(mainwindow, '[url of new window]')
290 291 292 |
# File 'lib/awetestlib/regression/browser.rb', line 290 def attach_browser_by_url(browser, pattern, desc = '') attach_browser(browser, :url, pattern, desc) end |
#attach_popup(browser, how, what, desc = '') ⇒ Object
:category: A_rdoc_test Returns a reference to a new browser window. Used to attach a new browser window to a variable which can then be passed to methods that require a browser parameter. Calls attach_browser().
- Parameters
-
browser - a reference to the browser window to be tested
how - the browser attribute used to identify the window: either :url or :title
what - a string or a regular expression in the url or title
desc - a string containing a message or description intended to appear in the log and/or report output
Example
mainwindow = open_browser('www.myapp.com') # open a browser to www.google.com click(mainwindow, :button, :id, 'an id string') # click a button that opens another browser window popup = attach_popup(mainwindow, :url, '[url of new window]') *or* popup = attach_popup(mainwindow, :title, '[title of new window]')
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
# File 'lib/awetestlib/regression/browser.rb', line 320 def attach_popup(browser, how, what, desc = '') msg = "Attach popup :#{how}=>'#{what}'. #{desc}" popup = attach_browser(browser, how, what, desc) sleep_for(1) debug_to_log("#{popup.inspect}") if is_browser?(popup) title = popup.title passed_to_log("#{msg} title='#{title}'") return popup else failed_to_log(msg) end rescue failed_to_log("Unable to attach popup :#{how}=>'#{what}'. #{desc} '#{$!}' (#{__LINE__})") end |
#attach_popup_by_title(browser, strg, desc = '') ⇒ Object
336 337 338 |
# File 'lib/awetestlib/regression/browser.rb', line 336 def attach_popup_by_title(browser, strg, desc = '') attach_popup(browser, :title, strg, desc) end |
#attach_popup_by_url(browser, pattern, desc = '') ⇒ Object Also known as: get_popup_with_url, attach_popup_with_url, attach_iepopup
340 341 342 |
# File 'lib/awetestlib/regression/browser.rb', line 340 def attach_popup_by_url(browser, pattern, desc = '') attach_popup(browser, :url, pattern, desc) end |
#bail_out(browser, lnbr, msg) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/awetestlib/regression/browser.rb', line 100 def bail_out(browser, lnbr, msg) ts = Time.new msg = "Bailing out at util line #{lnbr} #{ts} " + msg puts "#{msg}" fatal_to_log(msg, nil, 1, lnbr) debug_to_log(dump_caller(lnbr)) if is_browser?(browser) if @browserAbbrev == 'IE' hwnd = browser.hwnd kill_browser(hwnd, lnbr, browser) raise(RuntimeError, msg, caller) elsif @browserAbbrev == 'FF' debug_to_log("#{browser.inspect}") debug_to_log("#{browser.to_s}") raise(RuntimeError, msg, caller) end end @status = 'bailout' raise(RuntimeError, msg, caller) end |
#basic_auth(browser, user, pswd, url, bypass_validate = false) ⇒ Object
category: Logon :tags:logon, login, user, password, url, basic authorization
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/awetestlib/regression/browser.rb', line 417 def basic_auth(browser, user, pswd, url, bypass_validate = false) mark_testlevel("Basic Authorization Login", 0) ("Login: #{user}") ("URL: #{url}") ("Password: #{pswd}") @login_title = "Connect to" a = Thread.new { browser.goto(url) } sleep_for(2) ("#{@login_title}...") if (@ai.WinWait(@login_title, "", 90) > 0) win_title = @ai.WinGetTitle(@login_title) debug_to_log("Basic Auth Login window appeared: '#{win_title}'") @ai.WinActivate(@login_title) @ai.ControlSend(@login_title, '', "[CLASS:Edit; INSTANCE:2]", '!u') @ai.ControlSend(@login_title, '', "[CLASS:Edit; INSTANCE:2]", user, 1) @ai.ControlSend(@login_title, '', "[CLASS:Edit; INSTANCE:3]", pswd.gsub(/!/, '{!}'), 1) @ai.ControlClick(@login_title, "", '[CLASS:Button; INSTANCE:1]') else debug_to_log("Basic Auth Login window did not appear.") end a.join validate(browser, @myName) unless bypass_validate ("URL: [#{browser.url}] User: [#{user}]") end |
#check_for_and_clear_other_browsers ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/awetestlib/regression/browser.rb', line 138 def check_for_and_clear_other_browsers if @targetBrowser.abbrev == 'IE' debug_to_log("#{__method__}:") cnt1 = find_other_browsers cnt2 = Watir::IE.process_count debug_to_log("#{__method__}: cnt1: #{cnt1} cnt2: #{cnt2}") begin Watir::IE.each do |ie| pid = Watir::IE::Process.process_id_from_hwnd(ie.hwnd) debug_to_log("#{__method__}: Killing browser process: hwnd #{ie.hwnd} pid #{pid} title '#{ie.title}' (#{__LINE__})") do_taskkill(INFO, pid) sleep_for(10) end #Watir::IE.close_all() rescue debug_to_log("#{__method__}: #{$!} (#{__LINE__})") end sleep(3) cnt1 = find_other_browsers cnt2 = Watir::IE.process_count if cnt1 > 0 or cnt2 > 0 debug_to_log("#{__method__}:cnt1: #{cnt1} cnt2: #{cnt2}") begin Watir::IE.each do |ie| pid = Watir::IE::Process.process_id_from_hwnd(ie.hwnd) debug_to_log("#{__method__}: Killing browser process: hwnd #{ie.hwnd} pid #{pid} title '#{ie.title}' (#{__LINE__})") do_taskkill(INFO, pid) sleep_for(10) end #Watir::IE.close_all() rescue debug_to_log("#{__method__}:#{$!} (#{__LINE__})") end end end rescue error_to_log("#{__method__}: #{$!} (#{__LINE__})\n#{Kernel.caller.to_yaml}") end |
#check_for_other_browsers ⇒ Object
130 131 132 133 134 135 136 |
# File 'lib/awetestlib/regression/browser.rb', line 130 def check_for_other_browsers cnt1 = find_other_browsers cnt2 = Watir::Process.count 'iexplore.exe' debug_to_log("check_for_other_browsers: cnt1: #{cnt1} cnt2: #{cnt2}") rescue error_to_log("#{$!} (#{__LINE__})\n#{Kernel.caller.to_yaml}") end |
#close_modal(browser, title = "", button = "OK", text = '', side = 'primary', wait = WAIT) ⇒ Object
#close a modal dialog
656 657 658 659 660 661 662 663 664 665 666 667 |
# File 'lib/awetestlib/regression/browser.rb', line 656 def close_modal(browser, title="", ="OK", text='', side = 'primary', wait = WAIT) case @targetBrowser.abbrev when 'IE' close_modal_ie(browser, title, , text, side, wait) when 'FF' close_modal_ff(browser, title, , text, side) when 'S' close_modal_s when 'C', 'GC' close_modal_c(browser, title) end end |
#close_modal_c(browser, title) ⇒ Object
TODO: Logging
670 671 672 |
# File 'lib/awetestlib/regression/browser.rb', line 670 def close_modal_c(browser, title) browser.window(:url, title).close end |
#close_modal_ff(browser, title = "", button = nil, text = "", side = '') ⇒ Object
private :close_modal_ie
739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 |
# File 'lib/awetestlib/regression/browser.rb', line 739 def close_modal_ff(browser, title="", =nil, text="", side='') title = translate_popup_title(title) msg = "Modal dialog (popup): title=#{title} button='#{}' text='#{text}' side='#{side}':" modal = browser.modal_dialog(:timeout => WAIT) if modal.exists? modal_text = modal.text if text.length > 0 if modal_text =~ /#{text}/ passed_to_log("#{msg} appeared with match on '#{text}'.") else failed_to_log("#{msg} appeared but did not match '#{text}' ('#{modal_text}).") end else passed_to_log("#{msg} appeared.") end if modal.() else modal.close end if modal.exists? failed_to_log("#{msg} close failed. (#{__LINE__})") else passed_to_log("#{msg} closed successfully.") end else failed_to_log("#{msg} did not appear after #{WAIT} seconds. (#{__LINE__})") end rescue failed_to_log("#{msg} Unable to validate modal popup: '#{$!}'. (#{__LINE__})") end |
#close_modal_ie(browser, title = "", button = "OK", text = '', side = 'primary', wait = WAIT, desc = '', quiet = false) ⇒ Object
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 |
# File 'lib/awetestlib/regression/browser.rb', line 680 def close_modal_ie(browser, title="", ="OK", text='', side = 'primary', wait = WAIT, desc = '', quiet = false) #TODO needs simplifying, incorporating text verification, and debug code cleaned up title = translate_popup_title(title) msg = "Modal window (popup) '#{title}'" if @ai.WinWait(title, text, wait) myHandle = @ai.WinGetHandle(title, text) if myHandle.length > 0 debug_to_log("hwnd: #{myHandle.inspect}") passed_to_log("#{msg} appeared.") unless quiet window_handle = "[HANDLE:#{myHandle}]" sleep_for(0.5) @ai.WinActivate(window_handle) if @ai.WinActive(window_handle) debug_to_log("#{msg} activated.") controlHandle = @ai.ControlGetHandle(title, '', "[CLASS:Button; TEXT:#{}]") if not controlHandle.length > 0 = "&#{}" controlHandle = @ai.ControlGetHandle(title, '', "[CLASS:Button; TEXT:#{}]") end debug_to_log("Handle for button '#{}': [#{controlHandle}]") debug_to_log("#{msg} focus gained.") if @ai.ControlClick(title, '', "[CLASS:Button; TEXT:#{}]") passed_to_log("#{msg} #{side} click on '[CLASS:Button; TEXT:#{}]' successful.") sleep_for(0.5) if @ai.WinExists(window_handle) debug_to_log("#{msg} close popup failed on click '#{}'. Trying WinClose. (#{__LINE__})") @ai.WinClose(title, text) if @ai.WinExists(window_handle) debug_to_log("#{msg} close popup failed with WinClose(#{window_handle}). (#{__LINE__})") @ai.WinKill(window_handle) if @ai.WinExists(window_handle) debug_to_log("#{msg} close popup failed with WinKill(#{window_handle}). (#{__LINE__})") else debug_to_log("#{msg} closed successfully with WinKill(#{window_handle}).") end else debug_to_log("#{msg} closed successfully with WinClose(#{window_handle}).") end else passed_to_log("#{msg} closed successfully.") end else failed_to_log("#{msg} #{side} click on '[CLASS:Button; TEXT:#{}]' failed. (#{window_handle}) (#{__LINE__})") end else failed_to_log("#{msg} Unable to activate (#{window_handle}) (#{__LINE__})") end else failed_to_log("#{msg} did not appear after #{wait} seconds. (#{window_handle}) (#{__LINE__})") end else failed_to_log("#{msg} did not appear after #{wait} seconds.(#{window_handle}) (#{__LINE__})") end rescue failed_to_log("Close popup title=#{title} failed: '#{$!}' (#{__LINE__})") end |
#close_modal_s ⇒ Object
TODO: Logging
675 676 677 678 |
# File 'lib/awetestlib/regression/browser.rb', line 675 def close_modal_s # simply closes the frontmost Safari dialog Appscript.app("Safari").activate; Appscript.app("System Events").processes["Safari"].key_code(52) end |
#close_new_window_popup(popup) ⇒ Object
close popup in new window
522 523 524 525 526 527 528 529 |
# File 'lib/awetestlib/regression/browser.rb', line 522 def close_new_window_popup(popup) if is_browser?(popup) url = popup.url debug_to_log("Closing popup '#{url}' ") popup.close end end |
#close_panel_by_text(browser, panel, strg = 'Close') ⇒ Object
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 |
# File 'lib/awetestlib/regression/browser.rb', line 531 def close_panel_by_text(browser, panel, strg = 'Close') if validate(browser, @myName, __LINE__) if @browserAbbrev == 'IE' panel.link(:text, strg).click! elsif $USE_FIREWATIR begin panel.link(:text, strg).click rescue => e if not rescue_me(e, __method__, "link(:text,'#{strg}').click", "#{panel.class}") raise e end end else panel.link(:text, strg).click(:wait => false) end sleep_for(1) if validate(browser, @myName, __LINE__) passed_to_log("Panel '#{strg}' (by :text) closed.") true end else failed_to_log("Panel '#{strg}' (by :text) still open.") end rescue failed_to_log("Click on '#{strg}'(by :text) failed: '#{$!}' (#{__LINE__})") end |
#close_popup(title, button = "OK", text = '', side = 'primary', wait = WAIT, desc = '', quiet = false) ⇒ Object Also known as: close_popup_validate_text
def close_modal_ie(title=“”, button=“OK”, text=”, side = ‘primary’, wait = WAIT)
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 |
# File 'lib/awetestlib/regression/browser.rb', line 559 def close_popup(title, = "OK", text = '', side = 'primary', wait = WAIT, desc = '', quiet = false) #TODO needs simplifying and debug code cleaned up title = translate_popup_title(title) msg = "'#{title}'" msg << " with text '#{text}'" if text.length > 0 msg << " (#{desc})" if desc.length > 0 @ai.Opt("WinSearchChildren", 1) # Match any substring in the title if @ai.WinWait(title, text, wait) > 0 myHandle = @ai.WinGetHandle(title, text) full_text = @ai.WinGetText(title) #debug_to_report("Found popup handle:'#{myHandle}', title:'#{title}', text:'#{full_text}'") if myHandle.length > 0 debug_to_log("hwnd: #{myHandle.inspect}") passed_to_log("#{msg} appeared.") unless quiet sleep_for(0.5) @ai.WinActivate(title, text) if @ai.WinActive(title, text) # > 0 #Hack to prevent fail when windows session locked debug_to_log("#{msg} activated.") if @ai.ControlFocus(title, text, ) # > 0 controlHandle = @ai.ControlGetHandle(title, '', "[CLASS:Button; TEXT:#{}]") if not controlHandle = "&#{}" controlHandle = @ai.ControlGetHandle(title, '', "[CLASS:Button; TEXT:#{}]") end debug_to_log("Handle for button '#{}': [#{controlHandle}]") debug_to_log("#{msg} focus gained.") # sleep_for(2) if @ai.ControlClick(title, text, , side) # > 0 # if @ai.ControlClick(title, text, "[Handle:#{controlHandle}]", side) > 0 # debug_to_log("#{msg} #{side} click on 'Handle:#{controlHandle}'." ) debug_to_log("#{msg} #{side} click on '#{}' successful.") sleep_for(1) if @ai.WinExists(title, text) > 0 debug_to_log("#{msg} close popup failed on click '#{}'. Trying WinClose. (#{__LINE__})") @ai.WinClose(title, text) if @ai.WinExists(title, text) > 0 debug_to_log("#{msg} close popup failed with WinClose('#{title}','#{text}'). (#{__LINE__})") @ai.WinKill(title, text) if @ai.WinExists(title, text) > 0 debug_to_log("#{msg} close popup failed with WinKill('#{title}','#{text}'). (#{__LINE__})") else debug_to_log("#{msg} closed successfully with WinKill('#{title}','#{text}').") end else debug_to_log("#{msg} closed successfully with WinClose('#{title}','#{text}').") end else passed_to_log("#{msg} closed successfully.") unless quiet end else failed_to_log("#{msg} #{side} click on '#{}' failed. (#{__LINE__})") end else failed_to_log("#{msg} Unable to gain focus on button (#{__LINE__})") end else failed_to_log("#{msg} Unable to activate (#{__LINE__})") end else failed_to_log("#{msg} did not appear after #{wait} seconds. (#{__LINE__})") end else failed_to_log("#{msg} did not appear after #{wait} seconds. (#{__LINE__})") end rescue failed_to_log("Close popup title=#{title} failed: '#{$!}' (#{__LINE__})") end |
#close_popup_by_button_title(popup, strg, desc = '') ⇒ Object
1021 1022 1023 |
# File 'lib/awetestlib/regression/browser.rb', line 1021 def (popup, strg, desc = '') click(popup, :link, :title, strg, desc) end |
#close_popup_by_text(popup, strg = 'Close', desc = '') ⇒ Object
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/awetestlib/regression/browser.rb', line 629 def close_popup_by_text(popup, strg = 'Close', desc = '') count = 0 url = popup.url if validate(popup, @myName, __LINE__) count = string_count_in_string(popup.text, strg) if count > 0 # @waiter.wait_until( browser.link(:text, strg).exists? ) if @waiter begin popup.link(:text, strg).click rescue => e if not rescue_me(e, __method__, "link(:text,'#{strg}')", "#{popup.class}") raise e end end passed_to_log("Popup #{url} closed by clicking link with text '#{strg}'. #{desc}") true else failed_to_log("Link :text=>'#{strg}' for popup #{url} not found. #{desc}") end end rescue failed_to_log("Close popup #{url} with click link :text+>'#{strg}' failed: '#{$!}' (#{__LINE__})") debug_to_log("#{strg} appears #{count} times in popup.text.") raise end |
#close_window_by_title(browser, title, desc = '', text = '') ⇒ Object
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
# File 'lib/awetestlib/regression/browser.rb', line 364 def close_window_by_title(browser, title, desc = '', text = '') msg = "Window '#{title}':" if @ai.WinWait(title, text, WAIT) > 0 passed_to_log("#{msg} appeared. #{desc}") myHandle = @ai.WinGetHandle(title, text) full_text = @ai.WinGetText(title) debug_to_log("#{msg} hwnd: #{myHandle.inspect}") debug_to_log("#{msg} title: '#{title}' text: '#{full_text}'") if @ai.WinClose(title, text) > 0 passed_to_log("#{msg} closed successfully. #{desc}") else failed_to_log("#{msg} close failed. (#{__LINE__}) #{desc}") end else failed_to_log("#{msg} did not appear after #{WAIT} seconds. (#{__LINE__}) #{desc}") end rescue failed_to_log("#{msg}: Unable to close: '#{$!}'. (#{__LINE__}) #{desc}") end |
#do_taskkill(severity, pid) ⇒ Object
121 122 123 124 125 126 127 128 |
# File 'lib/awetestlib/regression/browser.rb', line 121 def do_taskkill(severity, pid) if pid and pid > 0 and pid < 538976288 info_to_log("Executing taskkill for pid #{pid}") (severity, %x[taskkill /t /f /pid #{pid}]) end rescue error_to_log("#{$!} (#{__LINE__})") end |
#filter_bailout_from_rescue(err, msg) ⇒ Object
1025 1026 1027 1028 1029 1030 1031 |
# File 'lib/awetestlib/regression/browser.rb', line 1025 def filter_bailout_from_rescue(err, msg) if msg =~ /bailing out/i raise err else error_to_log(msg) end end |
#find_other_browsers ⇒ Object
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
# File 'lib/awetestlib/regression/browser.rb', line 348 def find_other_browsers cnt = 0 if @targetBrowser.abbrev == 'IE' Watir::IE.each do |ie| debug_to_log("#{ie.inspect}") ie.close() cnt = cnt + 1 end end debug_to_log("Found #{cnt} IE browser(s).") return cnt rescue error_to_log("#{$!} (#{__LINE__})\n#{Kernel.caller.to_yaml}", __LINE__) return 0 end |
#find_popup(browser, how, what, desc = '') ⇒ Object
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 |
# File 'lib/awetestlib/regression/browser.rb', line 847 def find_popup(browser, how, what, desc = '') msg = "Find popup :#{how}=>'#{what}'. #{desc}" popup = Watir::IE.find(how, what) # TODO: too browser specific sleep_for(1) debug_to_log("#{popup.inspect}") if is_browser?(popup) # title = popup.title passed_to_log(msg) return popup else failed_to_log(msg) end rescue failed_to_log("Unable to find popup :#{how}=>'#{what}'. #{desc} '#{$!}' (#{__LINE__})") end |
#go_to_url(browser, url = nil, redirect = nil) ⇒ Object
82 83 84 85 86 87 88 89 90 |
# File 'lib/awetestlib/regression/browser.rb', line 82 def go_to_url(browser, url = nil, redirect = nil) if url @myURL = url end ("URL: #{@myURL}") browser.goto(@myURL) rescue fatal_to_log("Unable to navigate to '#{@myURL}': '#{$!}'") end |
#handle_popup(title, text = '', button = 'OK', side = 'primary', wait = WAIT, desc = '') ⇒ Object
771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 |
# File 'lib/awetestlib/regression/browser.rb', line 771 def handle_popup(title, text = '', = 'OK', side = 'primary', wait = WAIT, desc = '') title = translate_popup_title(title) msg = "'#{title}'" if text.length > 0 msg << " with text '#{text}'" end @ai.Opt("WinSearchChildren", 1) # match title from start, forcing default if and .length > 0 if =~ /ok|yes/i id = '1' else id = '2' end else id = '' end if @ai.WinWait(title, '', wait) > 0 myHandle = @ai.WinGetHandle(title, '') window_handle = "[HANDLE:#{myHandle}]" full_text = @ai.WinGetText(window_handle) debug_to_log("Found popup handle:'#{myHandle}', title:'#{title}', text:'#{full_text}'") controlHandle = @ai.ControlGetHandle(window_handle, '', "[CLASS:Button; TEXT:#{}]") if not controlHandle # button = "&#{button}" controlHandle = @ai.ControlGetHandle(window_handle, '', "[CLASS:Button; TEXT:&#{}]") end if text.length > 0 if full_text =~ /#{text}/ passed_to_log("Found popup handle:'#{myHandle}', title:'#{title}', text includes '#{text}'. #{desc}") else failed_to_log("Found popup handle:'#{myHandle}', title:'#{title}', text does not include '#{text}'. Closing it. #{desc}") end end @ai.WinActivate(window_handle, '') @ai.ControlClick(window_handle, '', id, side) if @ai.WinExists(title, '') > 0 debug_to_log("#{msg} @ai.ControlClick on '#{}' (ID:#{id}) with handle '#{window_handle}' failed to close window. Trying title.") @ai.ControlClick(title, '', id, side) if @ai.WinExists(title, '') > 0 debug_to_report("#{msg} @ai.ControlClick on '#{}' (ID:#{id}) with title '#{title}' failed to close window. Forcing closed.") @ai.WinClose(title, '') if @ai.WinExists(title, '') > 0 debug_to_report("#{msg} @ai.WinClose on title '#{title}' failed to close window. Killing window.") @ai.WinKill(title, '') if @ai.WinExists(title, '') > 0 failed_to_log("#{msg} @ai.WinKill on title '#{title}' failed to close window") else passed_to_log("Killed: popup handle:'#{myHandle}', title:'#{title}'. #{desc}") true end else passed_to_log("Forced closed: popup handle:'#{myHandle}', title:'#{title}'. #{desc}") true end else passed_to_log("Closed on '#{}': popup handle:'#{myHandle}', title:'#{title}'. #{desc}") true end else passed_to_log("Closed on '#{}': popup handle:'#{myHandle}', title:'#{title}'. #{desc}") true end else failed_to_log("#{msg} did not appear after #{wait} seconds. #{desc} (#{__LINE__})") end rescue failed_to_log("Unable to handle popup #{msg}: '#{$!}' #{desc} (#{__LINE__})") end |
#is_browser?(browser) ⇒ Boolean Also known as: is_browser
863 864 865 866 867 868 869 870 871 872 873 874 875 |
# File 'lib/awetestlib/regression/browser.rb', line 863 def is_browser?(browser) myClass = browser.class.to_s case @targetBrowser.abbrev when 'IE' myClass =~ /Watir::/i # TODO: should this be /Watir::IE/i ? when 'FF' myClass =~ /Watir::Browser/i when 'S' myClass =~ /Watir::Safari/i when 'C' myClass =~ /Watir::Browser/i end end |
#kill_browser(hwnd, lnbr, browser = nil, doflag = false) ⇒ Object
177 178 179 180 181 182 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 209 210 211 |
# File 'lib/awetestlib/regression/browser.rb', line 177 def kill_browser(hwnd, lnbr, browser = nil, doflag = false) # TODO Firefox logit = false if @browserAbbrev == 'FF' if is_browser?(browser) # and browser.url.length > 1 logit = true here = __LINE__ url = browser.url capture_screen(browser, Time.new.to_f) if @screenCaptureOn browser.close if url.length > 0 @status = 'killbrowser' fatal_to_log("Kill browser called from line #{lnbr}") end elsif hwnd pid = Watir::IE::Process.process_id_from_hwnd(hwnd) if pid and pid > 0 and pid < 538976288 if browser.exists? here = __LINE__ logit = true url = browser.url capture_screen(browser, Time.new.to_f) if @screenCaptureOn browser.close sleep(2) if browser.exists? do_taskkill(FATAL, pid) end @status = 'killbrowser' end end if logit debug_to_log("#{@browserName} window hwnd #{hwnd} pid #{pid} #{url} (#{here})") fatal_to_log("Kill browser called from line #{lnbr}") end end end |
#login(browser, user, password) ⇒ Object
:category: Basic :tags:logon, login, user, password, url TODO: Needs to be more flexible about finding login id and password textfields TODO: Parameterize url and remove references to environment
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
# File 'lib/awetestlib/regression/browser.rb', line 390 def login(browser, user, password) myURL = @myAppEnv.url runenv = @myAppEnv.nodename ("URL: #{myURL}") ("Beginning login: User: #{user} Environment: #{runenv}") if validate(browser, @myName, __LINE__) browser.goto(myURL) if validate(browser, @myName) set_textfield_by_name(browser, 'loginId', user) set_textfield_by_name(browser, 'password', password) (browser, 'Login') if validate(browser, @myName) passed_to_log("Login successful.") end else failed_to_log("Unable to login to application: '#{$!}'") # screen_capture( "#{@myRoot}/screens/#{myName}_#{@runid}_#{__LINE__.to_s}_#{Time.new.to_f.to_s}.jpg") end end rescue failed_to_log("Unable to login to application: '#{$!}'") end |
#logout(browser, where = @myName, lnbr = __LINE__) ⇒ Object
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
# File 'lib/awetestlib/regression/browser.rb', line 452 def logout(browser, where = @myName, lnbr = __LINE__) #TODO Firewatir 1.6.5 does not implement .exists for FireWatir::Firefox class debug_to_log("Logging out in #{where} at line #{lnbr}.", lnbr, true) debug_to_log("#{__method__}: browser: #{browser.inspect} (#{__LINE__})") if ['FF', 'S'].include?(@browserAbbrev) || browser.exists? case @browserAbbrev when 'FF' if is_browser?(browser) url = browser.url title = browser.title debug_to_log("#{__method__}: Firefox browser url: [#{url}]") debug_to_log("#{__method__}: Firefox browser title: [#{title}]") debug_to_log("#{__method__}: Closing browser: #{where} (#{lnbr})") if url and url.length > 1 browser.close else browser = FireWatir::Firefox.attach(:title, title) browser.close end end when 'IE' hwnd = browser.hwnd pid = Watir::IE::Process.process_id_from_hwnd(hwnd) debug_to_log("#{__method__}: Closing browser: hwnd #{hwnd} pid #{pid} #{where} (#{lnbr}) (#{__LINE__})") browser.close if browser.exists? and pid > 0 and pid < 538976288 # value of uninitialized memory location debug_to_log("Retry close browser: hwnd #{hwnd} pid #{pid} #{where} #{lnbr} (#{__LINE__})") browser.close end if browser.exists? and pid > 0 and pid < 538976288 # value of uninitialized memory location kill_browser(browser.hwnd, __LINE__, browser, true) end when 'S' if is_browser?(browser) url = browser.url title = browser.title debug_to_log("Safari browser url: [#{url}]") debug_to_log("Safari browser title: [#{title}]") debug_to_log("Closing browser: #{where} (#{lnbr})") close_modal_s # to close any leftover modal dialogs browser.close end when 'C' if is_browser?(browser) url = browser.url title = browser.title debug_to_log("Chrome browser url: [#{url}]") debug_to_log("Chrome browser title: [#{title}]") debug_to_log("Closing browser: #{where} (#{lnbr})") if url and url.length > 1 browser.close #else #browser = FireWatir::Firefox.attach(:title, title) #browser.close end end else raise "Unsupported browser: '#{@browserAbbrev}'" end end # rescue => e # if not e.is_a?(Vapir::WindowGoneException) # raise e # end end |
#open_browser(url = nil) ⇒ Object
:category: A_rdoc_test Opens a browser and returns a reference to it. If url is specified the browser is opened to that url, otherwise it is opened to a bland page
- Parameters
-
url - a string containing the full url. Optional.
Example
browser = open_browser('www.google.com')
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/awetestlib/regression/browser.rb', line 30 def open_browser(url = nil) debug_to_log("Opening browser: #{@targetBrowser.name}") case @targetBrowser.abbrev when 'IE' @myBrowser = open_ie if @myBrowser.class.to_s == "Watir::IE" @myHwnd = @myBrowser.hwnd @waiter = Watir::Waiter.new(WAIT) end when 'FF' @myBrowser = open_ff_for_version when 'S' aBrowser = Watir::Safari.new @myBrowser = aBrowser when 'C', 'GC' @myBrowser = open_chrome else raise "Unsupported browser: #{@targetBrowser.name}" end if url go_to_url(@myBrowser, url) end @myBrowser end |
#open_chrome ⇒ Object
78 79 80 |
# File 'lib/awetestlib/regression/browser.rb', line 78 def open_chrome browser = Watir::Browser.new(:chrome) end |
#open_ff ⇒ Object
73 74 75 76 |
# File 'lib/awetestlib/regression/browser.rb', line 73 def open_ff Watir::Browser.default = 'firefox' browser = Watir::Browser.new end |
#open_ff_for_version(version = @targetVersion) ⇒ Object
64 65 66 67 68 69 70 71 |
# File 'lib/awetestlib/regression/browser.rb', line 64 def open_ff_for_version(version = @targetVersion) if version.to_f < 4.0 browser = open_ff else browser = Watir::Browser.new(:firefox) end browser end |
#open_ie ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/awetestlib/regression/browser.rb', line 55 def open_ie if $watir_script browser = Watir::IE.new else browser = Watir::Browser.new :ie end browser end |
#open_popup_through_link_title(browser, title, pattern, name) ⇒ Object
1033 1034 1035 1036 1037 1038 1039 1040 |
# File 'lib/awetestlib/regression/browser.rb', line 1033 def open_popup_through_link_title(browser, title, pattern, name) click_title(browser, title) #TODO need some kind of wait for process here sleep_for 2 attach_iepopup(browser, pattern, name) rescue failed_to_log("Unable to open popup '#{name}': '#{$!}' (#{__LINE__})") end |
#run ⇒ Object
DO WE NEED? Use this method to tell user they need to create a run method?
5 6 7 8 9 10 11 12 13 |
# File 'lib/awetestlib/regression/browser.rb', line 5 def run #DO WE NEED? Use this method to tell user they need to create a run method? setup set_script_variables run_test rescue fatal_to_log("(#{__LINE__}) #{$!}") browser.close raise end |
#token_auth(browser, role, token, id = 'token_pass') ⇒ Object
92 93 94 95 96 97 98 |
# File 'lib/awetestlib/regression/browser.rb', line 92 def token_auth(browser, role, token, id = 'token_pass') set_textfield_by_id(browser, id, token) (browser, 'Continue') if validate_text(browser, 'The requested page requires authentication\.\s*Please enter your Passcode below', nil, true) bail_out(browser, __LINE__, "Token authorization failed on '#{token}'") end end |
#translate_popup_title(title) ⇒ Object
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 |
# File 'lib/awetestlib/regression/browser.rb', line 879 def translate_popup_title(title) new_title = title case @browserAbbrev when 'IE' if @browserVersion case @browserVersion when '8.0' case title when "Microsoft Internet Explorer" new_title = "Message from webpage" when "The page at" new_title = "Message from webpage" end when '7.0' case title when "Message from webpage" new_title = "Microsoft Internet Explorer" when "The page at" new_title = "Windows Internet Explorer" end when '6.0' case title when "Message from webpage" new_title = "Microsoft Internet Explorer" when "The page at" new_title = "Microsoft Internet Explorer" end else case title when "Microsoft Internet Explorer" new_title = "Message from webpage" when "The page at" new_title = "Message from webpage" end end else case title when "Microsoft Internet Explorer" new_title = "Message from webpage" when "The page at" new_title = "Message from webpage" end end when 'FF' case title when 'File Download' new_title = 'Opening' when "Microsoft Internet Explorer" new_title = 'The page at' when "Message from webpage" new_title = 'The page at' end when 'C' case title when 'File Download' new_title = 'Save As' when "Microsoft Internet Explorer" new_title = 'The page at' when "Message from webpage" new_title = 'The page at' end end new_title end |
#validate(browser, fileName = '', lnbr = __LINE__, dbg = false) ⇒ Object Also known as: validate_browser
Verifies health of the browser. Looks for common http and system errors that are unrecoverable and attempts to gracefully bail out of the script. Calls rescue_me() when trying to capture the text to filter out known false errors and handle container elements that don’t respond to the .text method. category: bullet-proofing tags: system, http, fatal, error example: See click() related methods: rescue_me()
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 |
# File 'lib/awetestlib/regression/browser.rb', line 1051 def validate(browser, fileName = '', lnbr = __LINE__, dbg = false) debug_to_log("#{__method__} begin") if dbg msg = '' myOK = true if not browser msg = "#{fileName}----browser is nil object. (#{lnbr})" myOK = false elsif not is_browser?(browser) msg = "#{fileName}----not a browser. (#{lnbr})" debug_to_log(browser.inspect) myOK = false else if browser.respond_to?(:url) if not browser.url == @currentURL @currentURL = browser.url debug_to_log("Current URL: [#{@currentURL}]") # mark_testlevel( "Current URL: [#{@currentURL}]", 1 ) end end if @capture_js_errors if browser.respond_to?(:status) if browser.status.downcase =~ /errors? on page/ and not browser.status.downcase.include?('Waiting for') capture_js_error(browser) end end end begin browser_text = browser.text.downcase rescue => e if not rescue_me(e, __method__, "browser.text.downcase", "#{browser.class}", browser) debug_to_log("browser.text.downcase in #{__method__} #{browser.class}") debug_to_log("#{get_callers}") raise e else return true end end if browser_text if browser_text.match(/unrecognized error condition has occurred/i) msg = "#{fileName}----Unrecognized Exception occurred. (#{lnbr})" myOK = false elsif browser_text.match(/cannot find server or dns error/i) msg = "#{fileName}----Cannot find server error or DNS error. (#{lnbr})" myOK = false elsif browser_text.match(/the rpc server is unavailable/i) msg = "#{fileName}----RPC server unavailable. (#{lnbr})" myOK = false elsif browser_text.match(/404 not found/i) or browser_text.match(/the page you were looking for does\s*n[o']t exist/i) msg = "#{fileName}----RFC 2068 HTTP/1.1: 404 URI Not Found. (#{lnbr})" myOK = false elsif browser_text.match(/we're sorry, but something went wrong/i) or browser_text.match(/http status 500/i) msg = "#{fileName}----RFC 2068 HTTP/1.1: 500 Internal Server Error. (#{lnbr})" myOK = false elsif browser_text.match(/internet explorer cannot display the webpage/i) msg = "#{fileName}----Probably RFC 2068 HTTP/1.1: 500 Internal Server Error. (#{lnbr})" myOK = false elsif browser_text.match(/503.*service unavailable/i) msg = "#{fileName}----RFC 2068 HTTP/1.1: 503 Service Unavailable. (#{lnbr})" myOK = false elsif browser_text.match(/java.lang.NullPointerException/i) msg = "#{fileName}----java.lang.NullPointerException. (#{lnbr})" myOK = false elsif browser_text.match(/due to unscheduled maintenance/i) msg = "#{fileName}----Due to unscheduled maintenance. (#{lnbr})" myOK = false elsif browser_text.match(/network\s+error\s*(.+)$/i) $1.chomp! msg = "#{fileName}----Network Error #{$1}. (#{lnbr})" myOK = false elsif browser_text.match(/warning: page has expired/i) msg = "#{fileName}----Page using information from form has expired. Not automatically resubmitted. (#{lnbr})" myOK = false elsif browser_text.match(/no backend server available/i) msg = "#{fileName}----Cannot Reach Server (#{lnbr})" myOK = false elsif browser_text.match(/sign on\s+.+\s+unsuccessful/i) msg = "#{fileName}----Invalid Id or Password (#{lnbr})" myOK = false elsif browser_text.match(/you are not authorized/i) msg = "#{fileName}----Not authorized to view this page. (#{lnbr})" myOK = false elsif browser_text.match(/too many incorrect login attempts have been made/i) msg = "#{fileName}----Invalid Id or Password. Too many tries. (#{lnbr})" myOK = false elsif browser_text.match(/system error\.\s+an error has occurred/i) msg = "#{fileName}----System Error. An error has occurred. Please try again or call the Help Line for assistance. (#{lnbr})" myOK = false elsif browser_text.match(/Internal Server failure,\s+NSAPI plugin/i) msg = "#{fileName}----Internal Server failure, NSAPI plugin. (#{lnbr})" myOK = false elsif browser_text.match(/Error Page/i) msg = "#{fileName}----Error Page. (#{lnbr})" myOK = false elsif browser_text.match(/The website cannot display the page/i) msg = "#{fileName}----HTTP 500. (#{lnbr})" myOK = false # elsif browser_text.match(/Insufficient Data/i) # msg = "#{fileName}----Insufficient Data. (#{lnbr})" # myOK = false elsif browser_text.match(/The timeout period elapsed/i) msg = "#{fileName}----Time out period elapsed or server not responding. (#{lnbr})" myOK = false elsif browser_text.match(/Unexpected\s+errors*\s+occur+ed\.\s+(?:-+)\s+(.+)/i) msg = "#{fileName}----Unexpected errors occurred. #{$2.slice(0, 120)} (#{lnbr})" if not browser_text.match(/close the window and try again/i) myOK = false else debug_to_log("#{msg}") end elsif browser_text.match(/Server Error in (.+) Application\.\s+(?:-+)\s+(.+)/i) msg = "#{fileName}----Server Error in #{1} Application. #{$2.slice(0, 100)} (#{lnbr})" myOK = false elsif browser_text.match(/Server Error in (.+) Application\./i) msg = "#{fileName}----Server Error in #{1} Application. '#{browser_text.slice(0, 250)}...' (#{lnbr})" myOK = false elsif browser_text.match(/An error has occur+ed\. Please contact support/i) msg = "#{fileName}----An error has occurred. Please contact support (#{lnbr})" myOK = false end else debug_to_log("browser.text returned nil") end end if not myOK msg << " (#{browser.url})" puts msg debug_to_log(browser.inspect) debug_to_log(browser.text) fatal_to_log(msg, lnbr) raise(RuntimeError, msg, caller) else debug_to_log("#{__method__} returning OK") if dbg return myOK end rescue errmsg = $! if errmsg.match(msg) errmsg = '' end bail_out(browser, lnbr, "#{msg} #{errmsg}") end |