ExpressUnit

Helgevold Consulting, LLC

RSS

XPathItUp

SeleniumHelper

How to Execute Selenium Tests in Multiple Threads

I have recently added support for multi-threaded test execution in ExpressUnit. The following article will demonstrate how this new feature can be used when executing Selenium web tests.

The degree of multi-threading is controlled through configuration, and by setting the degreeOfParallelism to n, your tests will execute using up to n threads, depending on your hardware's capabilities.



  
      
Configuration Section

The same configuration section is used to specify your selenium host (Selenium RC) and the start-up url for your tests.

Sample tests:
Code listing 1 shows two sample Selenium web tests that are configured to run in parallel. The WebTestContext defined in the using statement is responsible for instantiating the ISelenium object and launching/stopping the browser, but it assumes that a Selnium RC process is running.

[TestClass]
public class SampleWebTest
{
    [WebTest]
    public void WebTest1()
    {
        using (WebTestContext ctx = new WebTestContext())
        {
            ctx.Selenium.Open("Default.aspx");

            Confirm.IsTrue(ctx.Selenium.IsElementPresent(
                           XPathFinder.Find.Tag("div").With.Text("This is a test form1").ToXPathExpression()));

        }
    }
    
    [WebTest]
    public void WebTest2()
    {
        using (WebTestContext ctx = new WebTestContext())
        {
            ctx.Selenium.Open("Default.aspx");

            Confirm.IsTrue(ctx.Selenium.IsElementPresent(
                        XPathFinder.Find.Tag("div").Containing("This is").ToXPathExpression()));
        }
	}
}

Figure1 shows a screen shoot of ExpressUnit running the two web tests in parallel. The orange circles next to the tests indicate which tests are currently running.


Figure 1

ExpressUnit can be downloaded from the following location Download

Share
You comment has been saved. It will appear as soon as we have approved it
Please fill out all fields

Feel free to comment on this article!

Your name


Title


Your comment




Written by
Sudipto Paul

Date
8/12/2011 11:16:49 AM

Title
Selenium 2..

Hi,

Can ExpressUnit support the new Selenium 2 with Webdriver.

Sudipto.

© Helgevold Consulting, LLC 2010