1

我正在使用一个自动化框架来处理数百个测试用例,并且一旦编写了所有脚本 - 数千个。被测应用程序有一个错误页面,当发生内部错误时显示,这导致我们正常友好的对象超时错误,因为Watir找不到有问题的对象:

  1) Error:
Test_Case#test_case:
Watir::Wait::TimeoutError: timed out after 30 seconds, waiting for {:xpath=>"//small[@class=\"total-card-value\"]"} to become present
    C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/wait.rb:48:in `until'
    C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/watir-webdriver-0.6.11/lib/watir-webdriver/wait.rb:120:in `method_missing'
    C:/workspace/Automated_Test_Scripts/trunk/Phoenix/classes/sidebar.rb:85:in `get_total_card_value'
    C:/workspace/Automated_Test_Scripts/trunk/Phoenix/classes/sidebar.rb:65:in `check_total'
    C:/workspace/Automated_Test_Scripts/trunk/Phoenix/tests/Reloadable_Payment.rb:116:in `block in test_case'
    C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/ruby-mysql-2.9.12/lib/mysql.rb:675:in `call'
    C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/ruby-mysql-2.9.12/lib/mysql.rb:675:in `each'
    C:/workspace/Automated_Test_Scripts/trunk/Phoenix/tests/Reloadable_Payment.rb:50:in `test_case'

这个 Watir 错误并没有准确地告诉我在测试执行期间发生了什么,因为在这个例子中页面重定向到了错误页面。我想整理我的日志并防止显示 Watir 错误,而是显示自定义错误消息:

  if $b.text.include?("We're sorry, but something went wrong.")
    puts "\033[1;31;40m Phoenix has stopped responding and is showing the \"We're sorry...\" message. Please e-mail these test log steps to the Phoenix group.\033[0m"
  end

当我将它添加到拆解(Minitest::Unit)中时,它会按我的预期显示,但它也会显示超时错误,无论我根据其他示例尝试什么来加载错误的页面。

当我想在日志中显示此特定错误时,如何抑制对象超时错误?

4

0 回答 0