开发者

How to run all the classes in a single instance in Selenium RC?

开发者 https://www.devze.com 2022-12-23 17:05 出处:网络
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开发者_JAVA技巧 instance.To use the same session per *.cs file use the [TestFi

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开发者_JAVA技巧 instance.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消