Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7901801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:19:41+00:00 2026-06-03T09:19:41+00:00

I am seeing some dead-instance weirdness running parallelized nested-loop web stress tests using Selenium

  • 0

I am seeing some dead-instance weirdness running parallelized nested-loop web stress tests using Selenium WebDriver, simple example being, say, hit 300 unique pages with 100 impressions each.

I’m “successfully” getting 4 – 8 WebDriver instances going using a ThreadLocal<FirefoxWebDriver> to isolate them per task thread, and MaxDegreeOfParallelism on a ParallelOptions instance to limit the threads. I’m partitioning and parallelizing the outer loop only (the collection of pages), and checking .IsValueCreated on the ThreadLocal<> container inside the beginning of each partition’s “long running task” method. To facilitate cleanup later, I add each new instance to a ConcurrentDictionary keyed by thread id.

No matter what parallelizing or partitioning strategy I use, the WebDriver instances will occasionally do one of the following:

  • Launch but never show a URL or run an impression
  • Launch, run any number of impressions fine, then just sit idle at some point

When either of these happen, the parallel loop eventually seems to notice that a thread isn’t doing anything, and it spawns a new partition. If n is the number of threads allowed, this results in having n productive threads only about 50-60% of the time.

Cleanup still works fine at the end; there may be 2n open browsers or more, but the productive and unproductive ones alike get cleaned up.

Is there a way to monitor for these useless WebDriver instances and a) scavenge them right away, plus b) get the parallel loop to replace the task segment immediately, instead of lagging behind for several minutes as it often does now?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T09:19:42+00:00Added an answer on June 3, 2026 at 9:19 am

    Since there is no OnReady event nor an IsReady property, I worked around it by sleeping the thread for several seconds after creating each instance. Doing that seems to give me 100% durable, functioning WebDriver instances.

    Thanks to your suggestion, I’ve implemented IsReady functionality in my open-source project Webinator. Use that if you want, or use the code outlined below.

    I tried instantiating 25 instances, and all of them were functional, so I’m pretty confident in the algorithm at this point (I leverage HtmlAgilityPack to see if elements exist, but I’ll skip it for the sake of simplicity here):

    public void WaitForReady(IWebDriver driver)
    {
        var js = @"{ var temp=document.createElement('div'); temp.id='browserReady';" +
                 @"b=document.getElementsByTagName('body')[0]; b.appendChild(temp); }";
        ((IJavaScriptExecutor)driver).ExecuteScript(js);
    
        WaitForSuccess(() =>
        {
            IWebElement element = null;
            try
            {
                element = driver.FindElement(By.Id("browserReady"));
            }
            catch
            {
                // element not found
            }
    
            return element != null;
        },
        timeoutInMilliseconds: 10000);
    
        js = @"{var temp=document.getElementById('browserReady');" +
             @" temp.parentNode.removeChild(temp);}";
        ((IJavaScriptExecutor)driver).ExecuteScript(js);
    }
    
    private bool WaitForSuccess(Func<bool> action, int timeoutInMilliseconds)
    {
        if (action == null) return false;
    
        bool success;
        const int PollRate = 250;
        var maxTries = timeoutInMilliseconds / PollRate;
        int tries = 0;
        do
        {
            success = action();
            tries++;
            if (!success && tries <= maxTries)
            {
                Thread.Sleep(PollRate);
            }
        }
        while (!success && tries < maxTries);
        return success;
    }
    

    The assumption is if the browser is responding to javascript functions and is finding elements, then it’s probably a reliable instance and ready to be used.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a third party component I'm using and I'm seeing some issues with
I'm using MVC3 .NET4.0 (VB), and I'm seeing some strange behavior on a simple
I'm using Pyamf as my backend for my Flex app and I'm seeing some
I created a web service reference in VS 2008. Should I be seeing some
I've been seeing some strange issues using the Alarm manager in Android, despite the
I'm running a Linux 2.6.36 kernel, and I'm seeing some random errors. Things like
I'm seeing some odd behaviour here using PrincipalContext.ValidateCredentials . The set-up is two Active
I'm seeing some strange behavior when trying to capture an instance of a C++
I'm seeing some strange (to me anyway) behavior when using MakeRelativeUri on Mono (2.6.7).
I'm seeing some very strange sorting behaviour using CaseInsensitiveComparer.DefaultInvariant. Words that start with a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.