我正在使用Selenium 2(Webdriver)在一个ASP.NET网站上构建服务,用户可以输入他们的URL,并获得使用不同浏览器制作的页面截图。
我的页面托管在Windows Server 2008 R2上。
使用FirefoxDriver
拍摄屏幕截图效果很好。
但是当我使用InternetExplorerDriver
时,我只得到一个空的黑文件。
该应用程序正在以管理员身份运行-因此不应存在权限问题。
我的代码:
// Opening the Browser
var ieCapabilities = DesiredCapabilities.InternetExplorer();
ieCapabilities.SetCapability(InternetExplorerDriver.IntroduceInstabilityByIgnoringProtectedModeSettings, true);
var browserIe = new InternetExplorerDriver(ieCapabilities);
browserIe.Navigate().GoToUrl("http://www.google.com");
// Screenshot
var dir = Server.MapPath("/screenshots/");
browserIe.GetScreenshot().SaveAsFile(dir + "Filename.png", ImageFormat.Png);
browserIe.Close();
有什么想法,为什么我的文件是黑色的?谢谢!