I am running a code in Selenium Grid. I have a class named TestBase as follows and I want to quit all the threads when I click on a button,but when I click on the button a Nullp
Personally, I wouldn't use ThreadLocal . I would just use protected member variables, having protected WebDriver being a member of a TestBase class. Then, once your session is started on the grid, make your test remember the session ID, then if there is an error, you can kill the Grid thread by sending a command to quit the driver along with the session id for that thread. I would basically be a JSON request. JSON wire protocol has a delete command that looks like this:
DELETE /session/:sessionId
By using ThreadLocal, in my opinion you are using something that is meant to handle local threads and trying to apply that concept to a remote service that has its own thread handling in it already. I guess I never use ThreadLocal because my testrunner does the thread forking for me: TestNG.