<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cloud Testing Blog &#187; capture</title>
	<atom:link href="http://www.cloudtesting.com/blog/tag/capture/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cloudtesting.com/blog</link>
	<description>Automated Functional, Cross Browser and Load Testing for Websites</description>
	<lastBuildDate>Tue, 23 Aug 2011 18:41:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Capturing screen shots of browsers with Selenium and Cloud Testing &#8211; Part 1</title>
		<link>http://www.cloudtesting.com/blog/2009/06/24/capturing-screen-shots-of-browsers-with-selenium-and-cloud-testing-part-1/</link>
		<comments>http://www.cloudtesting.com/blog/2009/06/24/capturing-screen-shots-of-browsers-with-selenium-and-cloud-testing-part-1/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 11:59:48 +0000</pubDate>
		<dc:creator>Phil Smith - Cloud Testing</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[capture]]></category>
		<category><![CDATA[screen shot]]></category>

		<guid isPermaLink="false">http://blog.cloudtesting.com/?p=295</guid>
		<description><![CDATA[When functionally testing your website, it is always useful to have a screen shot of what the browser window looked like. There are a number of ways of doing this. In this first of a series of articles we cover producing these with Selenium. Future articles will cover further advanced features of Selenium and using [...]]]></description>
			<content:encoded><![CDATA[<p>When functionally testing your website, it is always useful to have a screen shot of what the browser window looked like. There are a number of ways of doing this. In this first of a series of articles we cover producing these with Selenium. Future articles will cover further advanced features of Selenium and using the Cloud Testing Functional service.</p>
<h2><strong>Selenium</strong></h2>
<p>This article concentrates on the Java interface/driver for Selenium RC, however a number of other drivers are available to use (.NET, Perl, PHP, Python, Ruby).</p>
<p>There are two methods of the Selenium class that can be used to capture screen shots. Both capture a PNG to a file.</p>
<h3><span style="color:#000000;"><strong>captureScreenshot()</strong></span></h3>
<pre><span style="color:#000000;">void <strong>captureScreenshot </strong>(String filename);</span></pre>
<p>filename &#8211; a string of the filename to store the captured screen shot in. E.g.: &#8220;C:\sshot.png&#8221;.</p>
<p><span style="color:#000000;"> </span>This method captures the contents of the OS viewport (i.e. whatever is currently being displayed on the monitor), and works on all browsers.</p>
<h4>Example:</h4>
<pre style="padding-left:30px;">Selenium browser;</pre>
<pre style="padding-left:30px;">browser = new DefaultSelenium(seleniumServer,
    4444,
    "*firefox",
    "http://www.google.co.uk");</pre>
<pre style="padding-left:30px;">browser.start();</pre>
<pre style="padding-left:30px;">browser.open("/");</pre>
<pre style="padding-left:30px;">browser.captureScreenshot("C:\screenshot.png");</pre>
<pre style="padding-left:30px;">...</pre>
<h3>
<p><div id="attachment_307" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-307" title="Google-screenshot" src="http://cloudtesting.files.wordpress.com/2009/06/google-screenshot.png?w=300" alt="Image created using captureScreenshot()" width="300" height="224" /><p class="wp-caption-text">Image created using captureScreenshot()</p></div></h3>
<h3><span style="color:#000000;"><strong>captureEntirePageScreenshot()</strong></span></h3>
<pre><span style="color:#000000;">void <strong>captureEntirePageScreenshot </strong>(String filename, String kwargs);</span></pre>
<p>filename &#8211; a string of the filename to store the captured screen shot in. E.g.: &#8220;C:\sshot.png&#8221;.<br />
kwargs &#8211; a string that modifies the way the screenshot is captured. E.g.: &#8220;background=#CCFFDD&#8221;.</p>
<p>This saves the entire contents of the current window canvas (i.e. what is in the browser, but not the controls, status bar, scroll bars etc.). This currently only works with Firefox (using a built in feature), and IE if you install the SnapsIE tool (available from <a href="http://snapsie.sourceforge.net/">http://snapsie.sourceforge.net/</a>)</p>
<h4>Example:</h4>
<pre style="padding-left:30px;">Selenium browser;</pre>
<pre style="padding-left:30px;">browser = new DefaultSelenium(seleniumServer,
    4444,
    "*firefox",
    "http://www.google.co.uk");</pre>
<pre style="padding-left:30px;">browser.start();</pre>
<pre style="padding-left:30px;">browser.open("/");</pre>
<pre style="padding-left:30px;">browser.captureEntirePageScreenshot("C:\screenshot.png","");</pre>
<pre style="padding-left:30px;">...</pre>
<h2><strong> </strong></p>
<div id="attachment_310" class="wp-caption aligncenter" style="width: 310px"><strong><strong><img class="size-medium wp-image-310" title="Google-full-screenshot" src="http://cloudtesting.files.wordpress.com/2009/06/google-full-screenshot.png?w=300" alt="Image created using captureEntirePageScreenshot()" width="300" height="177" /></strong></strong><p class="wp-caption-text">Image created using captureEntirePageScreenshot()</p></div>
<p><strong> </strong></h2>
<p>Note that this image does not have any of the browser controls or OS visible.</p>
<h3>Long Pages</h3>
<p>If the web page extends to more than a screen, then this will all be captured with captureEntirePageScreenshot() as shown below:</p>
<div id="attachment_312" class="wp-caption aligncenter" style="width: 275px"><img class="size-medium wp-image-312" title="Google-full-screenshot-long" src="http://cloudtesting.files.wordpress.com/2009/06/google-full-screenshot2.png?w=265" alt="A long web page captured with captureEntirePageScreenshot()" width="265" height="300" /><p class="wp-caption-text">A long web page captured with captureEntirePageScreenshot()</p></div>
<p>Contrast this to the following image which does not display the whole page, just scroll bars:</p>
<div id="attachment_313" class="wp-caption aligncenter" style="width: 310px"><img class="size-medium wp-image-313" title="Google-screenshot2" src="http://cloudtesting.files.wordpress.com/2009/06/google-screenshot2.png?w=300" alt="Long web page captured with captureScreenshot()" width="300" height="224" /><p class="wp-caption-text">Long web page captured with captureScreenshot()</p></div>
<h3>Further Articles&#8230;</h3>
<p>In future articles, we will be covering advanced features of capturing images using Selenium, and how you can make use of these screen capture functions within the Cloud Testing service at <a href="http://www.cloudtesting.com">www.cloudtesting.com</a>.</p>
<p>See also</p>
<ul>
<li><a href="http://blog.cloudtesting.com/2009/06/24/capturing-screen-shots-of-browsers-with-selenium-and-cloud-testing-part-1/">Part 1 &#8211; Selenium screenshot basics</a></li>
<li><a href="http://blog.cloudtesting.com/2009/06/26/capturing-screen-shots-of-browsers-with-selenium-and-cloud-testing-part-2">Part 2 &#8211; Advanced screenshots with the Java Robot</a></li>
</ul>
<p><strong> </strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cloudtesting.com/blog/2009/06/24/capturing-screen-shots-of-browsers-with-selenium-and-cloud-testing-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

