Is it possible to use Spring to inject the WebDriver? I've read it can't be a singleton and should normally be instantiated during an @Before block. I'm ok with it being created at that point but I'd like to have it provided "magically" to some "helper" classes, instead of manually passing the reference to them.
update
I had it working fine locally with one test using
@DirtiesContext( classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
but as soon as I put it on our server that runs concurrent tests and things I run into this error.
Singleton bean creation not allowed while the singletons of this factory are in destruction.
Using a Prototype
isn't a good idea either because I also want to inject WebDriverBackedSelenium
(which needs driver and ended up creating 2 instances) , and in some prototype cases I run into this.
nested exception is org.openqa.selenium.WebDriverException: Error forwarding the new session Request timed out waiting for a node to become available