We then modi ed our initialValue() method to add each instance of WebDriverThread that we create to this new synchronized list. This is so that we can keep track of all our threads.
Next we renamed our @AfterSuite method, to ensure that the method names stay as descriptive as possible. It is now called closeDriverObjects(). This method does not just close down the instance of WebDriver that we are using like it did previously. Instead, it iterates through our webDriverThreadPool, closing every threaded instance we are keeping track of.
We don't actually know how many threads we are going to have running since this will be controlled by Maven. Thanks to this code, we don't have to know. What we do know is that, when our tests are nished, each WebDriver instance will be closed down cleanly, and without errors.
Finally we have added an @AfterMethod method called clearCookies() that will clear down the browser's cookies after each test. This should reset the browser to a neutral state without closing it so that we can start another test safely.
Please sign in to leave a comment.