Internet Explorer screenshot?

1,020 views
Skip to first unread message

kaygee

unread,
May 5, 2009, 5:38:38 PM5/5/09
to webdriver
I'm looking into methods to find rendering problems in cross-browser/
platform testing. Will there ever be an IE screenshot method? The FF
method helps for cross-platform, but not cross-browser... if not does
anyone know of an automated method to do this?

Thanks!
KG

Michael Tamm

unread,
May 6, 2009, 5:46:52 PM5/6/09
to webd...@googlegroups.com
As far as I know Selenium can take screen shots in Firefox and IE, maybe that can help you.

Of course we want to be able to take screenshots in all browsers with WebDriver someday...

Regards, Michael

2009/5/5 kaygee <kay...@gmail.com>

Kevin Gann

unread,
May 6, 2009, 6:34:04 PM5/6/09
to webd...@googlegroups.com
Thanks for the reply. That does help, but I was hoping to minimize the amount of test frameworks I need to support. I was hoping for something built into the IE driver like the FirefoxDriver.saveScreenshot() method.

I assume you mean the method that takes a screenshot of the whole screen?

http://binil.wordpress.com/2006/12/22/taking-screenshots-with-selenium/

KG

Jason Huggins

unread,
May 6, 2009, 6:06:43 PM5/6/09
to webd...@googlegroups.com

Don't know which language you are using, but the Robot library in Java
can take screenshots (and is therefore cross-platform, and nice it's
browser agnostic... cross-browser). This is what Selenium uses to take
screenshots, but you can use the Robot library on its own outside the
context of browser testing tool.

cheers,
hugs

Bert van Brakel

unread,
May 7, 2009, 5:39:17 AM5/7/09
to webdriver
source code snippet for screenshots across multiple monitors. Munge to
your own requirements

import java.awt.AWTException;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Properties;

import javax.imageio.ImageIO;
....
//read in user prefs for this screenshot
String path = "file/path/to/save/screenshot/to.extension";


Robot robot = new Robot();

// To support dual monitors, we need to do some funkiness

// all the screens we have
GraphicsDevice[] devices =
GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
// where we collect all the individual screenshots
BufferedImage[] images = new BufferedImage[devices.length];

int maxWidth = 0;
int maxHeight = 0;
// collect the screenshots. We will merge them from left to right
later
for (int i = 0; i < devices.length; i++) {
GraphicsDevice device = devices[i];
GraphicsConfiguration config = device.getDefaultConfiguration();
Rectangle bounds = config.getBounds();
BufferedImage image = robot.createScreenCapture(bounds);
if (image.getHeight() > maxHeight) {
maxHeight = image.getHeight();
}
maxWidth += image.getWidth();
images[i] = image;
}
//stitch the individual screenshots together into a single image.
All bottom aligned
BufferedImage merged = new BufferedImage(maxWidth, maxHeight,
BufferedImage.TYPE_INT_RGB);
int dx1 = 0;
for (int i = 0; i < images.length; i++) {
BufferedImage image = images[i];
merged.getGraphics().drawImage(image, dx1, 0, dx1 + image.getWidth
(), image.getHeight(), 0, 0,image.getWidth(), image.getHeight(),
null);
// ensure next image is offset to the right
dx1 += image.getWidth();
}
ImageIO.write(merged, org.codehaus.plexus.util.FileUtils.getExtension
(path).toUpperCase(), new File(path));

Regards,
Bert

Kevin Gann

unread,
Jun 8, 2009, 1:03:31 AM6/8/09
to webd...@googlegroups.com
Hey guys... thanks for the help!

I was able to get this working locally, but I'm having trouble getting it work work on some Windows Hudson slaves I have executing via COM... The snapshots are taken, but they're black... I know this isn't really a Webdriver issue, but maybe some of you all use Hudson, slaves, etc... as it's a logical extension so testing multiple browsers on multiple platforms.

Thanks again..

Simon Stewart

unread,
Jun 8, 2009, 4:57:00 AM6/8/09
to webd...@googlegroups.com
It's possible that the remote nodes have their screen savers on....

Simon

Kevin Gann

unread,
Jun 8, 2009, 11:32:49 AM6/8/09
to webd...@googlegroups.com
Using Windows group policies I disabled screen savers and rebooted. I'm wondering if execution on Windows via COM/DCOM doesn't have frame buffer to capture from? I'm going to try some things throughout the day to see if I can get some traction...

Is anyone else using a similar setup?

Any further questions I'm going to post to the Hudson forum as I think I'm already outside the realm of webdriver....

Simon Stewart

unread,
Jun 8, 2009, 1:21:48 PM6/8/09
to webd...@googlegroups.com
If you're running as a service, it's possible that you're running IE
headless. WebDriver can cope with this, but the robot may not be able
to....

Simon

Kevin Gann

unread,
Jun 8, 2009, 1:31:10 PM6/8/09
to webd...@googlegroups.com
I believe that's the case. It's interesting though that the ffx driver is able to take screenshots of itself without the robot. I haven't looked at the underlying code, but it has to be different... and I thought I was being clever doing this... ;)

Simon Stewart

unread,
Jun 8, 2009, 2:04:07 PM6/8/09
to webd...@googlegroups.com
Firefox supplies a handy mechanism that makes it easy to take screen
shots. IE's not quite so easy. At some point, I'll integrate something
like snapsie into the IE driver, which will help.

Simon

Kevin Gann

unread,
Jun 8, 2009, 2:57:04 PM6/8/09
to webd...@googlegroups.com
Thanks for the additional reply...

FYI... I'm going to go with the workaround of starting the Hudson slaves via JNLP from command prompt... it allows me to work around the COM/DCOM and Windows service madness. I played around with looking at the devices the robot detects while executing as a service and attempted to stitch them all together but they were all blank/black as well...

blackrat

unread,
Jun 19, 2009, 4:48:32 AM6/19/09
to webdriver
I found that using remote desktop (MSTSC/rdesktop), caused screenshots
to go to cat in a cellar at midnight mode after you disconnected and
this caused me endless fun and excitement for a few days.

My setup may be similar to yours; 5 remote Windows machines (actually
VMs running on a Linux server), requirements to screenshot headless
etc. Screenshots fine when the remote desktop session was displayed on
my local machine; black on black when the remote desktop session was
closed.

Since my remote servers were running under KVM, one of the options
that I had was to use the KVM native way (VNC) to access the Windows
VMs, and once I switched from rdesktop (MSTSC) to VNC everything was
fine. So all I had to do was bring the half dozen or so VMs up in KVM
to make sure the right video was being used, close them all and then
never touch them with rdesktop again.

Maybe this'll work for you too.

Best wishes,
Mac

On Jun 8, 4:32 pm, Kevin Gann <kay...@gmail.com> wrote:
> Using Windows group policies I disabled screen savers and rebooted. I'm
> wondering if execution on Windows via COM/DCOM doesn't have frame buffer to
> capture from? I'm going to try some things throughout the day to see if I
> can get some traction...
>
> Is anyone else using a similar setup?
>
> Any further questions I'm going to post to the Hudson forum as I think I'm
> already outside the realm of webdriver....
>
> On Mon, Jun 8, 2009 at 1:57 AM, Simon Stewart <simon.m.stew...@gmail.com>wrote:
>
>
>
>
>
> > It's possible that the remote nodes have their screen savers on....
>
> > Simon
>
> > On Mon, Jun 8, 2009 at 6:03 AM, Kevin Gann<kay...@gmail.com> wrote:
> > > Hey guys... thanks for the help!
>
> > > I was able to get this working locally, but I'm having trouble getting it
> > > work work on some Windows Hudson slaves I have executing via COM... The
> > > snapshots are taken, but they're black... I know this isn't really a
> > > Webdriver issue, but maybe some of you all use Hudson, slaves, etc... as
> > > it's a logical extension so testing multiple browsers on multiple
> > platforms.
>
> > > Thanks again..
>
> > > On Thu, May 7, 2009 at 2:39 AM, Bert van Brakel <bertvanbra...@gmail.com

Kevin Gann

unread,
Jun 19, 2009, 9:30:56 AM6/19/09
to webd...@googlegroups.com
Thanks for the reply! I have almost the same setup as yours. The environment is sort of like my own internal "http://browsershots.org/" with the advantage of doing more than one screen. :) Interesting results on your side... I also wondered what effect rdc had, but didn't have time to experiment.
Reply all
Reply to author
Forward
0 new messages