views:

37

answers:

1

I am using Selenium RC in C#. I have list of .cs files, Is there any way to execute all the files without opening multiple instance.

A: 

To use the same session per *.cs file use the [TestFixtureSetUp] attribute instead of the [SetUp] attribute when starting Selenium.

    [TestFixtureSetUp]
    public void SetupTest()
    {
        selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://change-this-to-the-site-you-are-testing/");
        selenium.Start();
        verificationErrors = new StringBuilder();
    }

This will run at the beginning of the File before any of the tests and then to kill it off put it in your [TestFixtureTearDown]

    [TestFixtureTearDown]
    public void TeardownTest()
    {
        try
        {
            selenium.Stop();
        }
        catch (Exception)
        {
            // Ignore errors if unable to close the browser
        }
        Assert.AreEqual("", verificationErrors.ToString());
    }

And then you can move tests from their individual files per test to 1 file per bit of functionality that you wish to test.

AutomatedTester