-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for entire page screenshot #5
Comments
This is intentional. Internally we run Opera in fullscreen mode, and the screenshots are taken with the OperaLauncher program so that we can capture the output of plugins such as Flash. To get a screenshot of the page it would be best to use I'll look into implementing the TakesScreenshot interface. |
Hi Stuart, Thanks for your reply. ScreenShotReply scr = ((OperaWebElement) ((OperaDriver)driver).findElementByTagName("body")).saveScreenshot(0);
FileUtils.writeByteArrayToFile(new File("c:\\temp\\screenshot.png"), scr.getPng()); For large pages, the part outside the viewport is black. I get the same problem with IEDriver but comes out properly with FirefoxDriver. BTW, for other webdrivers, this is how one would do it using TakesScreenshot: File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("c:\\temp\\screenshot.png")); |
Looks like IEDriver also has similar problems on 32bit machines. |
Hi, public class CustomOperaDriver extends OperaDriver implements TakesScreenshot {
@Override
public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException {
final ScreenShotReply scr = ((OperaWebElement) findElementByTagName("body")).saveScreenshot(0);
String base64Image = null;
try {
base64Image = new String(Base64.encodeBase64(scr.getPng()), "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new WebDriverException("Could not convert image to base64!", e);
}
return target.convertFromBase64Png(base64Image);
}
} |
Added known issue note about this to the README: 313c726 |
Hi,
The screenshotting functionality seems to be broken. It gives the screenshot of the whole desktop instead of just the webpage inside the browser.
Here is the code i'm using to test this:
WebDriver driver = new OperaDriver();
driver.get("http://news.google.com");
ScreenShotReply scr = ((OperaDriver) driver).saveScreenshot(0);
FileUtils.writeByteArrayToFile(new File("c:\temp\screenshot.png"), scr.getPng());
In my experience, it is best supported in FirefoxDriver. So, it would be nice to have it work the same way in OperaDriver too.
Also, it would be great if opera screenshotting mechanism would follow the standard WebDriver TakesScreenshot interface so that it can be interoperable with other webdrivers as well.
Thanks,
Shauvik
The text was updated successfully, but these errors were encountered: