Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium RC: Run tests in multiple browsers automatically

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.

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

How have other people automated this?

This is my implementation:

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.

like image 406
Daniel Beardsley Avatar asked Oct 17 '08 19:10

Daniel Beardsley


People also ask

Can selenium run multiple browsers?

Selenium is able to run tests in parallel, but CrossBrowserTesting makes it even simpler - allowing you to test across multiple browsers and mobile devices with just a few extra lines of code.

Does Selenium RC support looping?

Selenium Integrated Development Environment (IDE)Selenium IDE does not support conditional statements, exception handling, loops, screenshot capture, etc. For automating complex use cases, a majority of developers and testers prefer to opt for Scripting testing instead of Record & Replay testing.

Is Selenium RC can run only a test suite?

Selenium RC is an important component in the Selenium test suite. It is a testing framework that enables a QA or a developer to write test cases in any programming language in order to automate UI tests for web applications against any HTTP website.


1 Answers

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.

like image 176
ya23 Avatar answered Oct 26 '22 06:10

ya23