ruby-on-rails – Selenium RC:自动在多个浏览器中运行测试

所以,我已经开始创建一些使用 Selenium RC直接在浏览器中测试我的Web应用程序的Ruby单元测试.我正在使用 Selenum-Client用于ruby.我已经为我继承的所有其他selenium测试创建了一个基类.

这会创建大量SeleniumDriver实例,并在每个实例上调用所有缺少的方法.这基本上是并行运行测试.

其他人如何自动化这个?

这是我的实现:

class SeleniumTest < Test::Unit::TestCase
  def setup
    @seleniums = %w(*firefox *iexplore).map do |browser|
      puts 'creating browser ' + browser
      Selenium::SeleniumDriver.new("localhost",4444,browser,"http://localhost:3003",10000)
    end

    start
    open start_address
  end

  def teardown
      stop
  end

  #sub-classes should override this if they want to change it
  def start_address
    "http://localhost:3003/"
  end

  # Overrides standard "open" method
  def open(addr)
    method_missing 'open',addr
  end

  # Overrides standard "type" method
  def type(inputLocator,value)
    method_missing 'type',inputLocator,value
  end

  # Overrides standard "select" method
  def select(inputLocator,optionLocator)
    method_missing 'select',optionLocator
  end

  def method_missing(method_name,*args)
    @seleniums.each do |selenium_driver|
      if args.empty?
        selenium_driver.send method_name
      else
        selenium_driver.send method_name,*args
      end

    end
  end
end

这样可行,但如果一个浏览器出现故障,则整个测试失败,无法知道哪个浏览器失败了.

解决方法

你试过 Selenium Grid吗?我认为它创建了非常好的摘要报告,显示了您需要的详细信息.我可能错了,因为我已经有一段时间不使用它了.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...