Permalink
Browse files

JBEHAVE-750: better webdriver provider adherence

  • Loading branch information...
1 parent cabb9e3 commit 21fa9c671e3c3d1dc8e5a871e80d505475e7c27e @paul-hammant paul-hammant committed Mar 24, 2012
@@ -10,6 +10,7 @@ public FluentWebDriverPage(WebDriverProvider driverProvider) {
}
private FluentWebDriverImpl fluentWebDriver() {
+ makeNonLazy();
return new FluentWebDriverImpl(webDriver());
}
@@ -22,12 +22,12 @@
*/
public abstract class WebDriverPage implements WebDriver, HasInputDevices, JavascriptExecutor, HasCapabilities {
- private WebDriver webDriver;
+ private ThreadLocal<WebDriver> webDriver = new ThreadLocal<WebDriver>();
private final WebDriverProvider driverProvider;
public WebDriverPage(WebDriverProvider driverProvider) {
this.driverProvider = driverProvider;
- this.webDriver = new LazyWebDriver(driverProvider);
+ this.webDriver.set(new LazyWebDriver(driverProvider));
}
public void get(String url) {
@@ -128,11 +128,11 @@ public Capabilities getCapabilities() {
protected synchronized void makeNonLazy() {
// keep doing this per call as WebDriver instances changes per thread.
- webDriver = driverProvider.get();
+ webDriver.set(driverProvider.get());
}
protected WebDriver webDriver() {
- return webDriver;
+ return webDriver.get();
}
}

0 comments on commit 21fa9c6

Please sign in to comment.