本文介绍了Selenium RC:自动在多个浏览器中运行测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

So, I've started to create some Ruby unit tests that use Selenium RC to test my web app directly in the browser. I'm using the Selenum-Client for ruby. I've created a base class for all my other selenium tests to inherit from.

这会创建许多 SeleniumDriver 实例,并且在每个实例上调用所有缺少的方法.这实质上是并行运行测试.

This creates numerous SeleniumDriver instances and all the methods that are missing are called on each instance. This essentially runs the tests in parallel.

其他人是如何实现自动化的?

这是我的实现:

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', inputLocator, 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

这可行,但如果一个浏览器失败,则整个测试都会失败,并且无法知道它在哪个浏览器上失败.

This works, but if one browser fails, the whole test fails and there is no way to know which browser it failed on.

推荐答案

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

Did you try Selenium Grid? I think it creates pretty good summary report which shows details you need. I may be wrong, as I didn't use it for quite a while.

这篇关于Selenium RC:自动在多个浏览器中运行测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 19:06