WebDriver does not have an API, and this is not recommended, because Firefox does not fire certain events (for example, focus, blur) when the window is in the background. I usually get around this with a virtual machine (e.g. in VirtualBox) or a separate X-display.
jarib source
share