All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jbehave.web.selenium.DisplayPoolingFirefoxWebDriverProvider Maven / Gradle / Ivy

There is a newer version: 4.0-beta-1
Show newest version
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