I\'m trying to capture a screenshot of whole browser screen (e.g. with any toolbars, panels and so on) not only an entire page, so I\'m got this code:
using
Just and idea for hack. You may use Reflection methods to get process of firefox instance. First declare FirefoxDriverEx class inherited from FirefoxDriver - to access protected Binary property which encapsulates Process instance:
class FirefoxDriverEx : FirefoxDriver {
public Process GetFirefoxProcess() {
var fi = typeof(FirefoxBinary).GetField("process", BindingFlags.NonPublic | BindingFlags.Instance);
return fi.GetValue(this.Binary) as Process;
}
}
Than you may get process instance for access to MainWindowHandle property
using (var driver = new FirefoxDriverEx()) {
driver.Navigate().GoToUrl(url);
var process = driver.GetFirefoxProcess();
if (process != null) {
var screenCapture = new ScreenCapture();
var image = screenCapture.CaptureWindow(process.MainWindowHandle);
// ...
}
}