<?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>Test Automation Blog &#187; Tips &amp; Tricks</title>
	<atom:link href="http://testautomationblog.com/tag/tips-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://testautomationblog.com</link>
	<description>On software test automation and quality assurance</description>
	<lastBuildDate>Sun, 16 May 2010 09:33:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>The Hidden Firefox Profile in Selenium RC Server</title>
		<link>http://testautomationblog.com/2010/05/05/the-hidden-firefox-profile-in-selenium-rc-server/</link>
		<comments>http://testautomationblog.com/2010/05/05/the-hidden-firefox-profile-in-selenium-rc-server/#comments</comments>
		<pubDate>Wed, 05 May 2010 19:24:21 +0000</pubDate>
		<dc:creator>TAB</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[automation problems]]></category>
		<category><![CDATA[capture network traffic]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[firefox profile template]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://testautomationblog.com/?p=210</guid>
		<description><![CDATA[You might not know that Selenium provides a feature which allows you to capture the network traffic during a test. Another useful Selenium feature I use is the ability to start the RC server by providing a specific Firefox profile for running the tests. The problem is that those two features do not work together.]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="aligncenter size-full wp-image-222" title="Image (c) Arthur Caranta (Arthur40A)" src="http://testautomationblog.com/wp-content/uploads/2010/05/selenium_capture_network_traffic.jpg" alt="Image (c) Arthur Caranta (Arthur40A)" width="300" height="388" /></p>
<p>You might not know that Selenium provides a feature which allows you to capture the network traffic during a test. This might be handy in some cases - for example if you want to check the HTTP response headers returned by the server for some reason or to verify that a specific HTTP request is triggered during a test. I use it for example to verify that a web analytics request is properly triggered on a particular web page.<br />
To use this feature you must start your tests by providing a special option to the start method, i.e.  <strong>selenium.start("captureNetworkTraffic=true");</strong></p>
<p>Another useful Selenium feature I use is the ability to start the RC server by providing a specific Firefox profile for running the tests. Your normal Firefox settings are not used when running tests in <em>*chrome</em> mode. If you want to have a specific Firefox plugin active, or if for example you must use a proxy to access the tested pages, you have to use the <strong>-firefoxProfileTemplate</strong> setting when starting the Selenium server and provide the path to a custom Firefox profile folder that contains all the settings and plugins you want to use.</p>
<p>The problem is that those two features do not work together - when I use the captureNetworkTraffic=true option, I always get some generic Firefox profile and not the one I provide in the firefoxProfileTemplate parameter.</p>
<p>Here is my workaround for this problem. It turns out that inside the Selenium RC server jar there is a folder called <em>customProfileDirCUSTFFCHROME</em>, which contains the small generic firefox profile, used in this case and probably also in the case when you don't provide a custom Firefox profile.</p>
<p>If you want to capture the network traffic and still use a custom Firefox profile,  here  is how you can hack your selenium-server.jar to include a  custom profile.</p>
<ul>
<li>Extract the<em> customProfileDirCUSTFFCHROME</em> folder from selenium-server.jar</li>
<li>Close all Firefox processes. Start Firefox with the <em>-profilemanager</em> option.</li>
<li>Choose 'Create Profile' from the dialog that appears, click 'Choose Folder' and select the folder extracted  from the jar file.This way you will use the profile provided by selenium as a starting point. You can then make configuration changes, add plugins etc.</li>
<li>When you exit firefox, pack all the changed files from the extracted profile folder back into the jar file. Now selenium will always use your custom profile</li>
</ul>
<p>I tested this with Selenium 1.0.3. Works like a charm.</p>
]]></content:encoded>
			<wfw:commentRss>http://testautomationblog.com/2010/05/05/the-hidden-firefox-profile-in-selenium-rc-server/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Selecting Unnamed Pop-up Windows in Selenium</title>
		<link>http://testautomationblog.com/2009/10/08/selecting-unnamed-pop-up-windows-in-selenium/</link>
		<comments>http://testautomationblog.com/2009/10/08/selecting-unnamed-pop-up-windows-in-selenium/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 18:11:04 +0000</pubDate>
		<dc:creator>TAB</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[automation problems]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Pop-Up]]></category>
		<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Tips & Tricks]]></category>

		<guid isPermaLink="false">http://testautomationblog.com/?p=133</guid>
		<description><![CDATA[If the application you are testing tends to open new browser windows using the target="_blank" technique, you might have some problems with Selenium.]]></description>
			<content:encoded><![CDATA[<p><em>If the application you are testing tends to open new browser windows using the target="_blank" technique, you might have some problems with Selenium.</em></p>
<p>One of the reasons I find <a href="http://seleniumhq.org/" target="_blank">Selenium</a> a great test automation tool for the web  is that it lets you easily run your test scripts on different browsers without too much effort. Most scripts will run smoothly on IE, Firefox and even on more exotic browsers like Safari, Opera and Chrome without needing browser-specific code or having to tweak the test for a particular browser.  One of the few areas where you are likely to face problems is the handling of pop-up windows.  If the application you are testing tends to open new browser windows using the <strong>target="_blank" </strong>technique, you might have some problems with Selenium. The standard <strong>.selectWindow()</strong> method provided by Selenium requires either a title of the pop-up window (which is often the same as the title of the main window) or a name or a variable name (which are both missing, when the window is opened using a target="_blank" link).</p>
<p>You will need a workaround to select such windows and unfortunately the workarounds do not always work the same for all browsers. The following code snippets might be useful if you run into the same problem. They are tested on the <strong>*chrome</strong> and <strong>*iehta</strong> Selenium modes (with Internet Explorer 7 and Firefox 3).</p>
<p>Here is how you can select the pop-up window which is opened after a target="_blank" link is clicked. This actually combines several hacks and workarounds, but works at the end (at least for me):</p>
<pre class="java">        <span style="color: #808080; font-style: italic;">//A hack to select unnamed pop-up windows</span>
        <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>browser.<span style="color: #006600;">equals</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;*iehta&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
            <span style="color: #808080; font-style: italic;">//Find out if Selenium substituted the blank target...</span>
            <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>selenium.<span style="color: #006600;">isElementPresent</span><span style="color: #66cc66;">&#40;</span>
                       <span style="color: #ff0000;">&quot;//a[starts-with(@target,'selenium_blank')]&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
                <span style="color: #808080; font-style: italic;">// ...and make it notice the new window on IE</span>
                selenium.<span style="color: #006600;">openWindow</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span>, selenium.<span style="color: #006600;">getAttribute</span><span style="color: #66cc66;">&#40;</span>
                      <span style="color: #ff0000;">&quot;//a[starts-with(@target,'selenium_blank')]@target&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
            <span style="color: #66cc66;">&#125;</span>
        <span style="color: #66cc66;">&#125;</span>
        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> winNames = selenium.<span style="color: #006600;">getAllWindowNames</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        <span style="color: #808080; font-style: italic;">//the last one is the pop-up window we want</span>
        selenium.<span style="color: #006600;">waitForPopUp</span><span style="color: #66cc66;">&#40;</span>winNames<span style="color: #66cc66;">&#91;</span>winNames.<span style="color: #006600;">length</span><span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#93;</span>, timeout<span style="color: #66cc66;">&#41;</span>;
        selenium.<span style="color: #006600;">selectWindow</span><span style="color: #66cc66;">&#40;</span>winNames<span style="color: #66cc66;">&#91;</span>winNames.<span style="color: #006600;">length</span><span style="color: #cc66cc;">-1</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</pre>
<p>And here is how you can go back to the main window after you finished working with the pop-up:</p>
<pre class="java">        <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> winTitles = selenium.<span style="color: #006600;">getAllWindowTitles</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
        selenium.<span style="color: #006600;">selectWindow</span><span style="color: #66cc66;">&#40;</span>winTitles<span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</pre>
]]></content:encoded>
			<wfw:commentRss>http://testautomationblog.com/2009/10/08/selecting-unnamed-pop-up-windows-in-selenium/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
