Home > How-To > Using captureEntirePageScreenshot with Selenium

Using captureEntirePageScreenshot with Selenium

Selenium provides a way to to capture the entire page displayed in the browser as a screenshot and save it as a png file on the disk. This functionality is only available in Selenium RC and is available for firefox (*chrome mode) and in IE (*iexploreproxy ) using Experimental utility Snapsie.

// Capture screen shot 

Firefox is supported out of the box but it needs little setup for it to work in IE. To use the method in IE go through following steps.

1. Download and install Microsoft VC++ Redistributable Package

2. Download and unzip Snapsie from http://snapsie.sourceforge.net/
Copy Snapsie.dll to windows/system or windows/system32 folder Register Snapsie.dll using “regsvr32 Snapsie.dll

3. Snapsie download comes with some tests, open the test files and try to save the page in browser as a screenshot. You will have to allow the browser to install the active-x control since snapsie is an active-x control.

4. Add the site you are testing and want to capture to Trusted Sites in Internet Explorer otherwise the active-x control will not be loaded when you run your site through RC and try to capture the screenshot.

To programatically add your site to Trusted Sites for Internet Explorer add the following keys to windows registry. Save the contents in .reg file and double click to run or call from a windows batch script. The following example adds http://www.aol.com to the trusted sites.


[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\aol.com]

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\aol.com\www]

If you run your tests on a fresh windows image every time, here is a sample .bat file you can use to install all the above things and start your selenium tests.


@echo off

REM Install in silent mode

C:\selenium-tests\vcredist_x86.exe /Q

C:\windows\regedit.exe  /s C:\selenium-tests\ie-trusted-sites.reg

copy C:\selenium-tests\snapsie-0.2\Snapsie.dll  C:\windows\system32\Snapsie.dll

C:\windows\system32\regsvr32.exe /s  C:\windows\system32\Snapsie.dll	

REM Start your tests here
Categories: How-To Tags: , ,
  1. ankit jain
    November 8, 2010 at 9:24 am

    To enable active content to run in Internet Explorer 8. Goto Tools > Internet Options and then Tick “allow active content to run in files on my computer.”

  2. December 16, 2010 at 11:51 am


    The commandline:

    fails with selenium RC.
    TypeError Traceback (most recent call last)

    /home/manu/Labo/Cefetes_Colatina/Scripts/ in ()

    TypeError: capture_entire_page_screenshot() takes exactly 3 arguments (2 given)

    I’ve seen it should be a bug in selenium that has been correted.

  3. gede
    February 1, 2012 at 7:57 am


    i tried the method in XP,Vista,Windows7 OS with no error
    except [Home premium] version of Vista and Windows7

    could help me.

    • February 1, 2012 at 1:57 pm

      Gede, I don’t have a copy of windows home premium vista or windows 7, What error are you getting ?

      Also try loading the test page that comes with snapsie to see if that works for you ?

      • gede
        February 2, 2012 at 2:47 am

        the error is :
        “Snapsie failed:Automation server can’t create object.”

        >Also try loading the test page that comes with snapsie to >see if that works for you ?
        i am sorry how to do that.

  1. October 17, 2010 at 6:48 am
  2. October 18, 2010 at 12:51 pm
  3. June 29, 2011 at 2:33 pm
  4. March 9, 2012 at 9:13 am
  5. January 20, 2013 at 9:41 pm
  6. September 30, 2013 at 6:36 pm
  7. March 14, 2017 at 1:11 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: