org.jbehave.web.selenium.DisplayPoolingFirefoxWebDriverProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jbehave-web-selenium Show documentation
Show all versions of jbehave-web-selenium Show documentation
Selenium and WebDriver API bindings for JBehave
package org.jbehave.web.selenium;
import org.openqa.selenium.firefox.FirefoxBinary;
public class DisplayPoolingFirefoxWebDriverProvider extends FirefoxWebDriverProvider {
private DisplayIdPool displayIdPool;
private ThreadLocal displayScreenId = new ThreadLocal();
private int refCt = 0;
public DisplayPoolingFirefoxWebDriverProvider(DisplayIdPool displayPool) {
this.displayIdPool = displayPool;
}
@Override
protected void decorateFirefoxBinary(FirefoxBinary binary) {
super.decorateFirefoxBinary(binary);
String displayID = displayIdPool.get();
displayScreenId.set(displayID);
binary.setEnvironmentProperty("DISPLAY", displayID);
System.out.println(new StringBuffer("Displays used=").append(++refCt).toString());
}
@Override
protected void ending() {
super.ending();
String displayId = displayScreenId.get();
displayIdPool.returnToPool(displayId);
System.out.println(new StringBuffer("Displays used=").append(--refCt).toString());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy