Thread Guard Class in Selenium

When we run our test cases in parallel using TestNg in selenium, you might have faced issues like some environmental, or some unknown issues halting the parallel execution.

Parallel execution is nothing but running the selenium in multiple threads, when one thread interrupts the other thread then JVM throws exceptions

To avoid these kinds of issues selenium provides a class called ThreadGuard, this class helps you solve the parallel running issues.

Like webdriver listener we have to wrap the webdriver instance using the ThreadGuard class, for that purpose we a method called protect() in ThreadGuard class.


										WebDriver driver = ThreadGuard.protect(new FirefoxDriver());			
										

This class has no importance than protecting the webdriver on the multi-threads.

Create Headless Chrome Browser in Selenium webdriver

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions
  • Vinod
    Hi karthik
    Thanks for beautiful explanation it's really good tutorial. 
    
    Could you please provide more details on framework using POM and sample working Framework code. 
    
    Thanks in advance
    Reply
  • Protractor Training

    new tutorial I am starting new Protractor training batch on Weekends. Course starts from 08-june-2019 [10am IST to 1 pm IST] based on online for 6 days, and course fee is INR 10, 000.

    Interested people can confirm the seat by calling to +91 8971673487 or whatsapp to +91 9003381224

    Find the course content : View Content