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 selenium.captureEntirePageScreenShot("screenshot.png");
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.
ie-trusted-sites.reg
[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] "http"=dword:00000002
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.
launch.bat
@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
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.”
Hi,
The commandline:
selenium.captureEntirePageScreenShot(“screenshot.png”);
fails with selenium RC.
academ.sel.capture_entire_page_screenshot(“screenshot.png”)
—————————————————————————
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.
hello
i tried the method in XP,Vista,Windows7 OS with no error
except [Home premium] version of Vista and Windows7
could help me.
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 ?
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.