Reputation: 912
I am having an issue while trying to take a screenshot using selenium with the 32 bit IE driver.
The page that I am testing only works on IE and I am using the 32 bits driver since the 64 driver is too slow.
The issue that I have is that in some pages that are too long this makes the Screenshot to fail or just to take one part of the page and the other part in black. This is not the issue the issue is that if selenium fails to take the screenshot IE stops responding and needs to be recover. When this happens the driver (obviously) can't find any element and my test case fail.
I am doing something like:
try{
Screnshot ss = ((ITakeScreenshot)driver).GetScreenshot();
ss.SaveAdFile("path", ImageFormat.Png);
}catch{
Log.Error("And Error happened");
}
So I'm not worry about if the screenshot is beeing take or not my problem is that if it fails I can't continue with the test case. Is there any way to unfreeze the explorer? or to make sure that the screenshot don't fail (I prefer to see black in the screenshot that see my test fail because of a screenshot of a page too large)
P.S I tried with driver.Dispose() even though this works (unfreeze the browser) it kills the communication that Selenium and the browser have. If there is any way to reestablish the connection that might work.
Upvotes: 0
Views: 468
Reputation: 42528
I would take a screenshot of the viewport instead of the full page. It will be faster and more stable:
DesiredCapabilities caps = DesiredCapabilities.internetExplorer();
caps.setCapability("ie.enableFullPageScreenshot", false);
WebDriver driver = new InternetExplorerDriver(caps);
driver.get("http://stackoverflow.com/");
File file = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
driver.quit();
Upvotes: 1