团队城市中的红宝石测试用例失败

时间:2013-03-13 13:47:50

标签: ruby cucumber teamcity bdd

我是Ruby的新手,目前正在开发一个JAVA项目,该项目的行为测试用例用ruby(CUCUMBER BDD)编写。当我尝试通过TeamCity构建我的项目时,它显示了6个测试用例失败

"Watir::Exception::NoMatchingWindowFoundException: Unable to locate window,"

"Spec::Expectations::ExpectationNotMetError:"

错误。没有对这些测试用例进行任何更改。有关我应该查看的位置的任何建议吗?

这是我的env.rb文件..我需要在这里更改任何内容。

require 'watir'
require 'open-uri'
require 'spec'
require 'win32ole'
require 'rake'
require 'cucumber/rake/task'
require 'net/http'
require 'uri'
require 'mysql'
require 'active_record'
require 'features/db/mysqldb'
require 'features/db/order'
require 'features/db/listener_state'

def clear_all_mock_requests
  open 'http://xxxxxx:8080/httpmockserver/soapResponse!clearAllRequests.action'
end

Mysqldb.connect("xxx", "xxx", "xx", "xxx", "xxxxx")


clear_all_mock_requests()

Watir::Browser.default = ENV['browser'] == 'firefox' ? 'firefox' : 'ie'
#Watir::Browser.default = 'firefox'

BROWSER = Watir::Browser.new

WIN32OLE.class_eval do ||

  def visible?;
    return false if self.style.invoke('display').downcase == 'none';
    return true;
  end

  def type
    {:text_field=>'text', :radio=>'radio', :select_list => 'select-one', :checkbox => 'checkbox'}.each do |method, name|
      return name if BROWSER.method(method).call(:name, self.name).exist?
    end
    return nil
  end

  def exist?
    return true
  end
end

NilClass.class_eval do ||
  def exist?
    return false
  end
end


at_exit do
  BROWSER.close
end

1 个答案:

答案 0 :(得分:0)

Watir::Exception::NoMatchingWindowFoundException: Unable to locate window通常意味着您正试图锁定不存在的浏览器。检查您的browser.open功能。