2

Essentially I have 1 test that I want to run on multiple threads at the same time. Currently the only was I have found to do it is to rewrite the test for every thread I want to run so if I want it 10 run 10 times in parallel I have to write 10 tests.

I'm trying to do some minor load testing on a website by using selenium and C# to open multiple instances and attempt to fill in a form. I'm also trying to test race conditions for when the sign-ups are full

[TestFixture]
[Parallelizable]
class TournamentPageScript1
{
    public static IWebDriver driver = new ChromeDriver();

    public static IWebDriver getDriverInstance()
    {
        return driver;
    }

    [SetUp]
    public void initialize()
    {
        driver.Navigate().GoToUrl("https://mywebsite.com");            
    }

    [Test]
    public void validateTournamentPage001()
    {
        //do some stuff
    }

    [TearDown]
    public void tearDown()
    {
        driver.Close();
    }
}
[TestFixture]
[Parallelizable]
class TournamentPageScript2
{
    public static IWebDriver driver = new ChromeDriver();

    public static IWebDriver getDriverInstance()
    {
        return driver;
    }

    [SetUp]
    public void initialize()
    {
        driver.Navigate().GoToUrl("https://mywebsite.com");            
    }

    [Test]
    public void validateTournamentPage002()
    {
        //do some stuff
    }

    [TearDown]
    public void tearDown()
    {
        driver.Close();
    }
}

I want to only have to write the test 1 time and have the Selenium repeat the test in parallel over multiple threads.

4
  • Is there some reason you aren't using a load testing tool that is designed to load test instead of Selenium? Commented Feb 5, 2019 at 17:48
  • I'm also trying to test race conditions for when multiple users sign up at the same time Commented Feb 5, 2019 at 18:41
  • 1
    How does using Selenium test race conditions where load testing does not? Race conditions of what? Commented Feb 5, 2019 at 18:42
  • I'm using selenium to complete and submit a registration form. The registration has a cap and once that cap is reached any further registration are put on a waitlist. If 10 people go to sign up at the same time with one spot left I want to make sure that 1 person is registered and 9 people are placed on a waitlist. Commented Feb 5, 2019 at 19:30

1 Answer 1

1

Yes, Selenium works well on multiple threads. However if you are trying to get Selenium to submit a form at exactly the same time you will have to have a fast enough processor to run all the threads 'at the same time' which might be difficult since Selenium is a bit heavy. So, in short, multiple instances of selenium work well at the same time but you will have to see if you can practically achieve the speed for your situation.

related: C# multithreading

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.