<?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>The BrowserMob Blog &#187; Load Testing Tips</title>
	<atom:link href="http://blog.browsermob.com/category/load-testing-tips/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.browsermob.com</link>
	<description>All about browsers, performance testing, and load testing</description>
	<lastBuildDate>Tue, 27 Dec 2011 17:00:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Recent Customer engagements &#8211; handling file uploads and streaming content</title>
		<link>http://blog.browsermob.com/2011/12/recent-customer-engagements-handling-file-uploads-and-streaming-content/</link>
		<comments>http://blog.browsermob.com/2011/12/recent-customer-engagements-handling-file-uploads-and-streaming-content/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 05:20:39 +0000</pubDate>
		<dc:creator>Joel Weierman</dc:creator>
				<category><![CDATA[Load Testing Tips]]></category>
		<category><![CDATA[file upload]]></category>
		<category><![CDATA[file uploads]]></category>
		<category><![CDATA[stream load test]]></category>
		<category><![CDATA[streaming content]]></category>
		<category><![CDATA[streaming load test]]></category>
		<category><![CDATA[windows media streaming]]></category>

		<guid isPermaLink="false">http://blog.browsermob.com/?p=1910</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
Our Professional Services team has been extremely busy over the past several months helping Customers prepare for what proved to be a very busy online shopping season. I&#8217;d like to share with you a couple of unique challenges that we came across and how we were able to use the BrowserMob platform and some special <a href='http://blog.browsermob.com/2011/12/recent-customer-engagements-handling-file-uploads-and-streaming-content/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
<p>Our Professional Services team has been extremely busy over the past several months helping Customers prepare for what proved to be a very busy online shopping season. I&#8217;d like to share with you a couple of unique challenges that we came across and how we were able to use the BrowserMob platform and some special customizations in order to successfully test what normally would be impossible using just Selenium or a traditional http-based testing approach. </p>
<p><strong>File Uploads</strong></p>
<p>We worked with a large online greeting card company to completely automate the creation of a card, complete with multiple file uploads. Typically, we see file uploads implemented using a standard web form which are easy to automate with Selenium and the BrowserMob <a href="http://static.browsermob.com/api/com/browsermob/api/BrowserMob.html#filePath%28java.lang.String%29">filePath</a> directive. However, in this case, the upload used a Flash component to control the upload which then presented a native OS dialog to the user to select the file as in the screenshot below.</p>
<p><a href="http://blog.browsermob.com/wp-content/uploads/2011/12/upload-dialog-2.png"><img src="http://blog.browsermob.com/wp-content/uploads/2011/12/upload-dialog-2.png" alt="" title="upload-dialog-2" width="556" height="386" class="aligncenter size-full wp-image-1920" /></a></p>
<p>Unfortunately, these types of dialogs are not accessible by Selenium and thus require native mouse and keyboard integration as mentioned in this <a href="http://blog.browsermob.com/2009/12/flash-and-flex-automation-options-using-selenium/">this</a> earlier blog post. As the interaction was relatively simple (just select the file to be uploaded), we were able to automate this using BrowserMob&#8217;s special native keyboard and mouse utilities. </p>
<p>As a result, we were able to completely automate the creation of a card from start to finish and the Customer was subsequently able to integrate this script into their regular testing process. Please keep in mind that this type of interaction is quite brittle as it relies on specific x,y coordinates to be clicked on and can cause the script to break over time as objects are re-positioned on the site. In this case, as the interaction was relatively simple, it worked out well. For more complex interactions using Flex, we strongly recommend checking out Gorilla Logic&#8217;s solutions as mentioned in <a href="http://blog.browsermob.com/2011/08/flex-automation-using-selenium-and-flexmonkey/">this article.</a></p>
<p><strong>Streaming Media</strong></p>
<p>Another Customer came to us with a requirement to simulate a streaming media event for hundreds of users they were hosting using a Windows Media infrastructure. We were able to customize the boot-up process of our standard load testing agents and install the Mplayer plugin for Firefox which allowed us to stream the content across hundreds of browser and multiple locations. The Customer was then able to diagnose performance issues and bottlenecks in advance of the actual live event, saving them a lot of time and effort in the process. </p>
<p>During this engagement, we also used a special statistical sampling technique to verify that the content was playing as expected. In the script, we purposely threw an error, approximately 5% of the time which then took a screenshot and video of the transaction which we were able to review in real-time along with the Customer&#8217;s team. The relevant script snippet to accomplish this is included below:</p>
<pre>
function randomid(minVal,maxVal)
{
  var randVal = minVal+(Math.random()*(1+maxVal-minVal));
  return Math.floor(randVal);
}

if (!browserMob.isValidation()) {
    	var id = randomid(1,1000000000);
    	//randomly take a screenshot 5% of the time
    	var shot = randomid(1,20);
    	if (shot == 5) {
		throw("Catch body broken: IOException " + "user id " + userid + "-" + id + " " + new Date().toString());
        }
</pre>
<p>What type of special testing requirements do you have that are complex and challenging? Contact us and let us know, as we can help you come up with a solution!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.browsermob.com/2011/12/recent-customer-engagements-handling-file-uploads-and-streaming-content/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tip &amp; Trick: Schedule your load test for up to 60 minutes</title>
		<link>http://blog.browsermob.com/2011/11/tip-trick-schedule-your-load-test-for-up-to-60-minutes/</link>
		<comments>http://blog.browsermob.com/2011/11/tip-trick-schedule-your-load-test-for-up-to-60-minutes/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 23:30:43 +0000</pubDate>
		<dc:creator>Connie</dc:creator>
				<category><![CDATA[Load Testing Tips]]></category>

		<guid isPermaLink="false">http://blog.browsermob.com/?p=1899</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
Consider scheduling your load tests for up to 60 minutes. You can always stop the test earlier.  By scheduling it for 60 minutes, you retain the option to run the test longer or even pause/resume the test, effectively getting a second test for free. The cost of a shorter test, i.e. 5, 10, or 15 <a href='http://blog.browsermob.com/2011/11/tip-trick-schedule-your-load-test-for-up-to-60-minutes/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
<p>Consider scheduling your load tests for up to 60 minutes. You can always stop the test earlier.  By scheduling it for 60 minutes, you retain the option to run the test longer or even pause/resume the test, effectively getting a second test for free. The cost of a shorter test, i.e. 5, 10, or 15 minutes, is the same as a 60 minute test, so there&#8217;s really nothing to loose.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.browsermob.com/2011/11/tip-trick-schedule-your-load-test-for-up-to-60-minutes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox 7 support</title>
		<link>http://blog.browsermob.com/2011/11/firefox-7-support/</link>
		<comments>http://blog.browsermob.com/2011/11/firefox-7-support/#comments</comments>
		<pubDate>Wed, 02 Nov 2011 23:19:55 +0000</pubDate>
		<dc:creator>MarkW</dc:creator>
				<category><![CDATA[Customer Feature]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Load Testing Tips]]></category>
		<category><![CDATA[Monitoring]]></category>

		<guid isPermaLink="false">http://blog.browsermob.com/?p=1869</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
We are happy to announce that we recently added support for Firefox 7 to our monitoring and load testing products! You can now explicitly specify the Firefox version your script will run against.  Currently we support both Firefox 3.6 and Firefox 7. For example, the following script will open the Firefox 7 browser and navigate <a href='http://blog.browsermob.com/2011/11/firefox-7-support/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
<p>We are happy to announce that we recently added support for <strong>Firefox 7 to our monitoring and load testing products</strong>!  You can now explicitly specify the Firefox version your script will run against.   Currently we support both Firefox 3.6 and Firefox 7.</p>
<p>For example, the following script will open the Firefox 7 browser and navigate to a url:</p>
<pre>var selenium = browserMob.openBrowser("FF7");
browserMob.beginTransaction();
browserMob.beginStep("Home Page");
selenium.open("http://seleniumhq.org/");
browserMob.endStep();
browserMob.endTransaction();</pre>
<p>The same is possible when using the Selenium 2.0 API (WebDriver):</p>
<pre>var webDriver = browserMob.openBrowserWebDriver("FF7");
browserMob.beginTransaction();
browserMob.beginStep("Home Page");
webDriver.get("http://seleniumhq.org/");
browserMob.endStep();
browserMob.endTransaction();</pre>
<h4>Firefox 3.6</h4>
<p><strong>Existing monitors and load tests will continue to use Firefox 3 by default</strong>.  New monitors will default to using Firefox 7, so you if you want to create a new monitor and have it run against Firefox 3.6, specify &#8220;FF3&#8243; as the browser type:</p>
<pre>var selenium = browserMob.openBrowser("FF3");</pre>
<p><span style="font-weight: bold">Future Versions</span></p>
<p>In the future, we will add support for more Firefox versions.  If you want to keep up with the latest version of Firefox installed on our systems, you will need to  specify &#8220;FF&#8221;:</p>
<pre>var selenium = browserMob.openBrowser("FF");</pre>
<p>When we upgrade to a later version of Firefox, the script will automatically use the new version.</p>
<h4>Local Validator</h4>
<p><strong>Local validator will use the Firefox version you have installed by default</strong>.  You can override the locations it looks in for the different browsers in a property file.  The file is located in your home directory on Unix and under your user folder on Windows.</p>
<p><span style="font-family: monospace">$HOME/.browserMob/config.properties</span></p>
<p>For example, if you have Firefox 7 installed in the default path and Firefox 3 under a different directory,  you can use the following <strong>config.properties</strong> to point local validator to the Firefox executables:</p>
<pre>FF3 = C:/Program Files/Mozilla Firefox 3/firefox.exe
FF7 = C:/Program Files/Mozilla Firefox/firefox.exe</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.browsermob.com/2011/11/firefox-7-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Scripting for BrowserMob using WebDriver</title>
		<link>http://blog.browsermob.com/2011/10/scripting-for-browsermob-using-webdriver/</link>
		<comments>http://blog.browsermob.com/2011/10/scripting-for-browsermob-using-webdriver/#comments</comments>
		<pubDate>Tue, 01 Nov 2011 04:44:58 +0000</pubDate>
		<dc:creator>Anu Sandhanam</dc:creator>
				<category><![CDATA[FAQ]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Load Testing]]></category>
		<category><![CDATA[Load Testing Best Practices]]></category>
		<category><![CDATA[Load Testing Tips]]></category>

		<guid isPermaLink="false">http://blog.browsermob.com/?p=1846</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
Hello Readers!! It gives me immense pleasure in meeting you with yet another article on WebDriver. WebDriver has been creating a lot of buzz among the Selenium community lately and BrowserMob, an active member of the Selenium community, wasted no time in announcing its support for the WebDriver API. I hope you had the chance <a href='http://blog.browsermob.com/2011/10/scripting-for-browsermob-using-webdriver/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
<p>Hello Readers!! It gives me immense pleasure in meeting you with yet another article on WebDriver. WebDriver has been creating a lot of buzz among the Selenium community lately and BrowserMob, an active member of the Selenium community, wasted no time in announcing its support for the WebDriver API.</p>
<p>I hope you had the chance to read the great <a href="http://blog.browsermob.com/2011/07/introducing-selenium-2-webdriver-support/" target="_blank">introduction article on the Webdriver API</a> by fellow blogger Ben.</p>
<p>In this article I would like to touch on the basics of scripting with the WebDriver and the BrowserMob API.<br />
I’m sure many of you, who are new to this API are asking yourselves these questions just like I did.</p>
<ul>
<li>What is WebDriver?</li>
<li>Why is it needed?</li>
</ul>
<p>WebDriver is a framework for automated testing of web applications. WebDriver is a part of Selenium 2.0, which is a major departure from the 1.0 model. Selenium 1.0 is a client-server architecture which uses the RC libraries to program tests that communicate with the server, and the server relays those commands to a browser.</p>
<p>The primary downside of the 1.0 model is that it is written in JavaScript. Browsers impose a strict security model on any JavaScript that they execute in order to protect a user from malicious scripts. Additionally, the API for RC has grown over time that users find it hard to keep up with this ever growing dictionary of methods. The WebDriver helps overcome both these hurdles with an object oriented API that controls the browser itself rather than running as a JavaScript application within the browser.</p>
<p>WebDriver has five major Interfaces &#8211; <a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.ImeHandler.html" target="_blank">ImeHandler</a>, <a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.Navigation.html" target="_blank">Navigation</a>, <a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.Options.html" target="_blank">Options</a>, <a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.TargetLocator.html" target="_blank">TargetLocator</a> , <a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html" target="_blank">Timeouts</a>, the methods of which fall into following three categories.</p>
<ul>
<li>Control of the browser itself
<p>Eg: get(), navigate(), close()etc</li>
<li>Selection of WebElements
<p>Eg: findElement(), findElements() etc</li>
<li>Debugging aids
<p>Eg: getCurrentUrl(), getPageSource(), getTitle() etc</li>
</ul>
<p>Now that we have a clear understanding of what WebDriver is and what its benefits are, let’s take a deep dive into the various useful WebDriver methods exposed via BrowserMob through some example scripts. Let’s look at this simple script below, to begin with.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> driver <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">openBrowserWebDriver</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> tx <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">beginTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> step <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Home Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
driver.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://seleniumhq.org/docs/06_test_design_considerations.html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// polls DOM every 500 ms for ten seconds until the text 'Test Design Considerations' is found</span>
driver.<span style="color: #660066;">manage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">timeouts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">implicitlyWait</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span>  TimeUnit.<span style="color: #660066;">SECONDS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Content validation - find element by xpath</span>
driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//div[@id='test-design-considerations']/h1[contains(text(), 'Test Design Considerations')]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">endTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Deciphering the script…</p>
<ul>
<li><em>var driver = browserMob.openBrowserWebDriver();</em><br />
The openBrowserWebDriver()method of WebDriver starts a WebDriver browser session.</li>
<p></p>
<li><em>driver.get(&#8220;http://seleniumhq.org/docs/06_test_design_considerations.html&#8221;);</em><br />
    The ‘get’ method which is equivalent to selenium.open() is used to navigate to any web page.</li>
<p></p>
<li><em>driver.manage().timeouts().implicitlyWait(10,  TimeUnit.SECONDS);<br />
driver.findElement(By.xpath(&#8220;//div[@id='test-design-considerations']/h1[contains(text(), 'Test Design Considerations')]&#8220;));</em></p>
<p></p>
<p>WebDriver has a blocking API. i.e. WebDriver will wait until the page has fully loaded (that is, the &#8220;onload&#8221; event has fired) before returning control to your test or script. However, under some conditions it is possible for a ‘get’ call to return before the page has finished loading. The classic example is JavaScript starting to run after the page has loaded (triggered by onload). Browsers (e.g. Firefox) will notify WebDriver when the basic HTML content has been loaded, which is when WebDriver returns. It&#8217;s difficult to know when JavaScript has finished executing, since JS code may schedule functions to be called in the future, depend on server response, etc. WebDriver cannot wait for all conditions to be met before the test proceeds because it does not know them. The solution to ensure whether the element involved in the next interaction is present and ready is to use the ‘Wait’ class to wait for a specific element to appear. This class simply calls findElement over and over, until the element is found (or a timeout has expired). Since this is the behavior desired by default for many users, a mechanism for implicitly-waiting for elements to appear has been implemented. This is accessible through the <a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/WebDriver.Timeouts.html" target="_blank">Timeouts() interface of the WebDriver class</a> (WebDriver.manage().timeouts() ). In the example script above, the driver.manage.timeouts().implicitlyWait call polls the DOM every 500 ms for 10 seconds until the text ‘Test Design Considerations’ is found.</li>
</ul>
<p><strong>Tips: </strong></p>
<ul>
<li>Optionally you can reset the Implicit Timeout to zero using the code below, as once set, it remains effective until the life of the WebDriver instance. The default setting is zero, i.e zero wait time.

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">driver.<span style="color: #660066;">manage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">timeouts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">implicitlyWait</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>  TimeUnit.<span style="color: #660066;">SECONDS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>It is possible to set a timeout for the entire step as such using the setStepTimeout method of the browserMob API. 

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Setting a step timeout of 10 seconds</span>
browserMob.<span style="color: #660066;">setStepTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
…….
<span style="color: #660066;">browserMob</span>.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Alternatively, browserMob’s  waitFor() method could be used in place of the implicitlyWait() for content validation. Modifying our script with waitFor()…

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> step <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Home Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
driver.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://seleniumhq.org/docs/06_test_design_considerations.html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">waitFor</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">return</span> check <span style="color: #339933;">=</span> driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//div[@id='test-design-considerations']/h1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">startsWith</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;test design considerations&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>check<span style="color: #009900;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #3366CC;">&quot;Content validation failed&quot;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ul>
<p>Great!! We just wrote our first WebDriver script. We now know how to interact with page elements via the findElement method of WebDriver’s WebElement Interface using XPath. But does WebDriver provide other alternatives for interaction? Absolutely.  Below are few alternative ways. As implied through the script, using the ‘findElement’ is a great way to validate page content before proceeding to the next step in the script.</p>
<p><strong>By.cssSelector:</strong><br />
<em>driver.findElement(By.cssSelector(&#8220;div#test-design-considerations &gt; h1&#8243;));</em></p>
<p><strong>By.linkText:</strong><br />
<em>driver.findElement(By.linkText(&#8220;Data Driven Testing&#8221;));</em></p>
<p><strong>By.partialLinkText:</strong><br />
<em>driver.findElement(By.partialLinkText(&#8220;Data Driven&#8221;));</em></p>
<p><strong>By.id:</strong><br />
<em>driver.findElement(By.id(&#8220;side&#8221;));</em></p>
<p><strong>By.className:</strong><br />
<em>driver.findElement(By.className(&#8220;expandable&#8221;));</em></p>
<p><strong>By.name:</strong><br />
<em>driver.findElement(By.name(&#8220;q&#8221;));</em></p>
<p><strong>By.tagName:</strong><br />
<em>driver.findElement(By.tagName(&#8220;input&#8221;));</em></p>
<p><strong>driver.findElements:</strong><br />
In situations where you have to iterate through multiple elements with the same id/class/tag name etc or have to pick one randomly, the ‘findElements’ method comes in handy. The example script below uses this method to pick a random suggestion from an AutoSuggest list.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;AutoSuggest&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
driver.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.simon.com/default.aspx&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> elem <span style="color: #339933;">=</span> driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">cssSelector</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input[id*='KeywordTextBox']&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// clear the search box first</span>
elem.<span style="color: #660066;">clear</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// type Carlsbad in the search box</span>
elem.<span style="color: #660066;">sendKeys</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;carlsbad&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// wait for autosuggest to populate</span>
driver.<span style="color: #660066;">manage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">timeouts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">implicitlyWait</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span> TimeUnit.<span style="color: #660066;">SECONDS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> autoSuggest <span style="color: #339933;">=</span> driver.<span style="color: #660066;">findElements</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//div[@class='ac_results']/ul/li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// 'autoSuggest' from above is a Java List. Either use size() to get its length </span>
<span style="color: #006600; font-style: italic;">// or convert this to an array - autoSuggest.toArray().length</span>
&nbsp;
browserMob.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>autoSuggest.<span style="color: #660066;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// click on a random element – picking the last element in this case</span>
<span style="color: #003366; font-weight: bold;">var</span> selected <span style="color: #339933;">=</span> driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//div[@class='ac_results']/ul/li[&quot;</span><span style="color: #339933;">+</span>autoSuggest.<span style="color: #660066;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// throw an error if content validation returns false</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>driver.<span style="color: #660066;">getTitle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">contains</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Search Results&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #3366CC;">'Content error: &quot;Search Results&quot; not found'</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As you can see, I’ve also managed to introduce a few other useful methods through this script. The comments above each one of them describe their purpose. </p>
<p><strong>Tips: </strong></p>
<ul>
<li>sendKeys can also be used to simulate pressing of the keyboard keys by using the &#8220;Keys&#8221; class. It is possible to call sendKeys on any element. The code below triggers the “ENTER’ key press to force a form submission. The list of Keys supported can be found <a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/Keys.html" target="_blank">here</a>.

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">id</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'finalExpenses'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">sendKeys</span><span style="color: #009900;">&#40;</span>Keys.<span style="color: #000066; font-weight: bold;">RETURN</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>With advanced locators, it is possible to traverse down the DOM with a single line of code as in below:

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">driver.<span style="color: #660066;">findElements</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">tagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">findElements</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">tagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>
As the index starts with zero, the line of code above would click on the third “li” of the second “ul” on the page. </li>
</ul>
<p>A few more common page element interactions in detail…</p>
<p><strong>How to handle frames?</strong></p>
<p>Swinging between frames is easy with the <strong>switchTo() method of the TargetLocator interface of the WebDriver class.</strong></p>
<ul>
<li>Switch to the frame from main window</li>
<ul>
<li>By index

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">frame</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>By frame name

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">frame</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;frameName&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ul>
<li>Switch back to the parent window

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">defaultContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ul>
<p>The following example illustrates a simple swinging between two frames on a web page. Let’s assume the page has two frames, frame1 and frame2, out of which frame1 has a link and frame2 has a form.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">frame</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;frame1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SPAZ&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">defaultContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">frame</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;frame2&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">id</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;field_0&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">sendKeys</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;anu&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">className</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;form_button&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">defaultContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Try running this snippet commenting out the “driver.switchTo().defaultContent();” before switching to frame2 and you would end up with an error that frame2 cannot be located. This explains the need for switching back to the parent page from inside a frame first, before navigating to another frame on the same page.</p>
<p><strong>How to handle JavaScript Alert and Confirmation boxes?</strong></p>
<p>Confirmation boxes are handled the same way as the Alerts.</p>
<ul>
<li>Switch focus to the alert/confirmation box

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066;">alert</span> <span style="color: #339933;">=</span> driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Dismiss – equivalent to hitting “Cancel” button on the Confirmation box or ignoring an Alert by closing it.

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">alert</span>.<span style="color: #660066;">dismiss</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Alternatively accept – equivalent to hitting “OK” on the Alert or the Confirmation box

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">alert</span>.<span style="color: #660066;">accept</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Handle Confirmation boxes the JavaScript way

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">driver.<span style="color: #660066;">executeScript</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;window.confirm = function(msg){return true;};&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ul>
<p><strong>How to handle Pop-up Windows?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Handle Popup Windows&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
driver.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.javascript-coder.com/files/window-popup/javascript-window-open-example1.html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Get the handle to the current window</span>
<span style="color: #003366; font-weight: bold;">var</span> currentHandle <span style="color: #339933;">=</span> driver.<span style="color: #660066;">getWindowHandle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
driver.<span style="color: #660066;">manage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">timeouts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">implicitlyWait</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">10</span><span style="color: #339933;">,</span>  TimeUnit.<span style="color: #660066;">SECONDS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Open Pop-up</span>
driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">partialLinkText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Open the JavaScript Window&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Switch focus to Pop-up using its name</span>
driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">window</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mywindow'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Alternate way - if the Pop-up window doesn't have a name, which is very common - </span>
<span style="color: #006600; font-style: italic;">// get the handle to the last opened window</span>
<span style="color: #003366; font-weight: bold;">var</span> handles <span style="color: #339933;">=</span> driver.<span style="color: #660066;">getWindowHandles</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> handles.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span>
driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">window</span><span style="color: #009900;">&#40;</span>handles<span style="color: #009900;">&#91;</span>id<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//close popup</span>
driver.<span style="color: #660066;">executeScript</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;self.close ();&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//switch focus to parent window</span>
driver.<span style="color: #660066;">switchTo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">window</span><span style="color: #009900;">&#40;</span>currentHandle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>How to interact with SELECT drop-downs?</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> lastItem <span style="color: #339933;">=</span> driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//select[@class='dropDown']/option[last()]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
lastItem.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><strong>How to simulate advanced interaction such as Drag and Drop?</strong></p>
<p>The <a href="http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/interactions/Actions.html" target="_blank">Actions</a> subclass of the Selenium Interactions class makes emulation of these complex user gestures easier.</p>
<ul>
<li>Drag an element to drop on to another element

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">driver.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://devfiles.myopera.com/articles/735/example.html&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> from <span style="color: #339933;">=</span> driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//ul[@id='Fav']/li[3]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> to <span style="color: #339933;">=</span> driver.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//ul[@id='Tol']/li&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Actions<span style="color: #009900;">&#40;</span>driver<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">dragAndDrop</span><span style="color: #009900;">&#40;</span>from<span style="color: #339933;">,</span>to<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">perform</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Drag an element to an offset

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">driver.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://jqueryui.com/demos/draggable/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> draggable <span style="color: #339933;">=</span> browser.<span style="color: #660066;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #660066;">id</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;draggable&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
Actions<span style="color: #009900;">&#40;</span>driver<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">dragAndDropBy</span><span style="color: #009900;">&#40;</span>draggable<span style="color: #339933;">,</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">build</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">perform</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ul>
<p>I hope this article served as a comprehensive tutorial, covering most of the basics of WebDriver, if not all. See you soon with more useful WebDriver tips and tricks. Happy testing until then!!!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.browsermob.com/2011/10/scripting-for-browsermob-using-webdriver/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>FAQ:  How do I annotate a load test?</title>
		<link>http://blog.browsermob.com/2011/08/faq-how-do-i-annotate-a-load-test/</link>
		<comments>http://blog.browsermob.com/2011/08/faq-how-do-i-annotate-a-load-test/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 23:43:58 +0000</pubDate>
		<dc:creator>Mindy Hovern</dc:creator>
				<category><![CDATA[FAQ]]></category>
		<category><![CDATA[Load Testing Tips]]></category>
		<category><![CDATA[Load Testing]]></category>
		<category><![CDATA[New Feature]]></category>

		<guid isPermaLink="false">http://blog.browsermob.com/?p=1761</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
Select any time coordinate in your test plan and simply add a comment in the annotation field.  Your annotations are tracked and numbered with a flag, so to review, simply reference the number on the flag in the list of annotations made for that test plan.  Don’t worry about making mistakes, you can delete an <a href='http://blog.browsermob.com/2011/08/faq-how-do-i-annotate-a-load-test/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
<p>Select any time coordinate in your test plan and simply add a comment in the annotation field.  Your annotations are tracked and numbered with a flag, so to review, simply reference the number on the flag in the list of annotations made for that test plan.  Don’t worry about making mistakes, you can delete an annotation at any time.<a href="http://blog.browsermob.com/wp-content/uploads/2011/08/load-test-annotation.jpg"><img class="alignright size-full wp-image-1762" src="http://blog.browsermob.com/wp-content/uploads/2011/08/load-test-annotation.jpg" alt="" width="902" height="723" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.browsermob.com/2011/08/faq-how-do-i-annotate-a-load-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Traffic Tuesday: Testing Traffic and Performance Around the World</title>
		<link>http://blog.browsermob.com/2011/08/traffic_tuesday_traffic_around_the_world/</link>
		<comments>http://blog.browsermob.com/2011/08/traffic_tuesday_traffic_around_the_world/#comments</comments>
		<pubDate>Tue, 23 Aug 2011 11:47:20 +0000</pubDate>
		<dc:creator>Stephanie Klaiber</dc:creator>
				<category><![CDATA[Load Testing]]></category>
		<category><![CDATA[Load Testing Tips]]></category>
		<category><![CDATA[BrowserMob]]></category>
		<category><![CDATA[Webmetrics]]></category>
		<category><![CDATA[website traffic]]></category>

		<guid isPermaLink="false">http://blog.browsermob.com/?p=1749</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
Do you know where your website traffic is coming from? How about the percentage of traffic coming from various regions? A new report from, comScore, a market research firm, found that nearly 24.1% of total number of users visiting Amazon’s retail website in the month of June, came from the Asia Pacific region. Similarly, 24.9% <a href='http://blog.browsermob.com/2011/08/traffic_tuesday_traffic_around_the_world/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
<p>Do you know where your website traffic is coming from? How about the percentage of traffic coming from various regions?</p>
<p>A <a href="http://www.comscore.com/Press_Events/Press_Releases/2011/8/Amazon_Sites_Visited_by_1_in_5_Global_Internet_Users_in_June" target="_blank">new report</a> from, comScore, a market research firm, found that nearly 24.1% of total number of users visiting Amazon’s retail website in the month of June, came from the Asia Pacific region. Similarly, 24.9% of the total traffic on Apple’s website are from this same region.</p>
<p>As companies continue to expand their brands globally, it becomes increasingly important to keep track of where traffic is coming from, as load times and performance may vary depending on the region.</p>
<p>So how can you make sure you are running load tests that encompass traffic from around the world? Select a load testing tool that will allow you to test various traffic scenarios from around the world. For instance,  <a href="https://browsermob.com/website-load-testing" target="_blank">BrowserMob</a> offers <a href="http://blog.browsermob.com/2011/04/browsermob_tokyo_agent/" target="_blank">Tokyo as a location</a> from which you can generate traffic for your load test, as well as five other locations around the world.</p>
<p>For more information on load testing best practices, read the series: <a href="http://blog.browsermob.com/tag/load-testing-best-practices/" target="_blank">http://blog.browsermob.com/tag/load-testing-best-practices/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.browsermob.com/2011/08/traffic_tuesday_traffic_around_the_world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex Automation using Selenium and FlexMonkey</title>
		<link>http://blog.browsermob.com/2011/08/flex-automation-using-selenium-and-flexmonkey/</link>
		<comments>http://blog.browsermob.com/2011/08/flex-automation-using-selenium-and-flexmonkey/#comments</comments>
		<pubDate>Fri, 12 Aug 2011 21:55:27 +0000</pubDate>
		<dc:creator>Ben Jones</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[Load Testing Tips]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Selenium]]></category>

		<guid isPermaLink="false">http://blog.browsermob.com/?p=1621</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
Hello Testers &#8211; First, I have to admit that I am not a Flex/Flash developer and cannot take credit for the following content. This was produced by my colleague and fellow BrowserMob blogger, Anu. It is documented internally but I believe the BrowserMob community will find value so I scrubbed it and published it. Overview <a href='http://blog.browsermob.com/2011/08/flex-automation-using-selenium-and-flexmonkey/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
<p>Hello Testers &#8211; First, I have to admit that I am not a Flex/Flash developer and cannot take credit for the following content.  This was produced by my colleague and fellow BrowserMob blogger, <a href="http://blog.browsermob.com/author/anu/">Anu</a>. It is documented internally but I believe the BrowserMob community will find value so I scrubbed it and published it.</p>
<p><strong>Overview</strong></p>
<p>Traditionally, testing Flex/Flash applications was difficult because the logic/behavior is encapsulated from the browser.  With the introduction of Flex 3.x,  came the release of the Adobe Automation Framework; and Gorilla Logic developed a lightweight testing application called FlexMonkey. In conjunction, a Selenium plugin was created &#8211; FlexMonkium. Now Flex recording and playback are seamlessly interleaved with native Selenium recording and playback so you can easily automate the testing of hybrid web applications that mix HTML and Javascript with Flex.</p>
<p><strong> Prerequisites </strong></p>
<ul>
<li>In order to enable selenium interaction with Flex, you will have to compile your Flex objects with the FlexMonkey libraries. If you do not have access to your  swf files or don&#8217;t have the ability to compile swf files with FlexMonkey, then this solution may not be  suitable.
<ul>
<li>More on the compilation here: <a class="external-link" rel="nofollow" href="http://www.gorillalogic.com/books/flexmonkey-docs/flexmonkey-quick-start">http://www.gorillalogic.com/books/flexmonkey-docs/flexmonkey-quick-start</a></li>
</ul>
</li>
</ul>
<ul>
<li>FlexMonkium needs to be installed.
<ul>
<li>FlexMonkium is a bridge between FlexMonkey and Selenium that enables creating and running FlexMonkey test cases through the Selenium IDE.</li>
<li>Installation Instructions:
<ul>
<li>Install the <a class="external-link" rel="nofollow" href="http://seleniumhq.org/projects/ide/">Selenium-IDE</a>.</li>
<li>Install the FlexMonkiumConsole by running the <a class="external-link" rel="nofollow" href="http://www.gorillalogic.com/flexmonkium/downloads">FlexMonkium installer</a> (<em>requires registration</em>). Please note the location of your executable because you will need to tell the Firefox plugin where to find it. When the installation is complete,  the FlexMonkiumConsole window will appear (a small application window with three buttons); you can close it for now.</li>
<li>Download and unzip the <a class="external-link" rel="nofollow" href="http://www.gorillalogic.com/flexmonkium/downloads">FlexMonkium zip file</a> (<em>requires registration</em>). It contains:flexmonkium.xpi &#8211; The FlexMonkium Firefox extension installer; user-extensions.js &#8211; The FlexMonkium extensions for Selenium-RC.
<ul>
<li>Install the .xpi file by opening Firefox and selecting File&#8211;&gt;Open from the File menu.</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>If installed properly, a small black icon should appear on restarting firefox and opening the selenium IDE as indicated in the picture below.</li>
<p><img style="border: solid 1px #000000;margin: 10px" src="/wp-content/uploads/2011/08/flexmonkium_console.png" alt="" />
</ul>
<ul>
<li>If the console does not appear, select Options &gt; FlexMonkium&#8230; from the Selenium menu, click on the Browse&#8230; button and navigate to where you installed the FlexMonkiumConsole executable.</li>
<li>Click on the little black FlexMonkey icon in the IDE. It should open up a small console. If the .swf files were compiled properly with the FlexMonkey libraries, a little green ball should appear in the console, as indicated in the picture below</li>
<p><img style="border: solid 1px #000000;margin: 10px" src="/wp-content/uploads/2011/08/flexmonkey_icon.png" alt="" /></p>
<li>It shows up in yellow, otherwise</li>
<p><img style="border: solid 1px #000000;margin: 10px" src="/wp-content/uploads/2011/08/flexmonkium_console2.png" alt="" /></ul>
<p><em>It is very important to add &#8220;verifyFlexMonkey&#8221; commands wherever applicable to ensure that the Flex loaded completely and is ready to move on to the next step.</em></p>
<p><strong>FlexMonkey methods that are supported currently by BrowserMob</strong></p>
<ul>
<li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">input<span style="color: #009900;">&#40;</span>String id<span style="color: #339933;">,</span> String value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">changeFocus<span style="color: #009900;">&#40;</span>String id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span>String id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">change<span style="color: #009900;">&#40;</span>String id<span style="color: #339933;">,</span> String value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">click<span style="color: #009900;">&#40;</span>String id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">verifyProperty<span style="color: #009900;">&#40;</span>String id<span style="color: #339933;">,</span> String propertyType<span style="color: #339933;">,</span> String value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">selectText<span style="color: #009900;">&#40;</span>String id<span style="color: #339933;">,</span> int StartPositionOfString int EndPositionOfString<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">select<span style="color: #009900;">&#40;</span>String id<span style="color: #339933;">,</span>String Value<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">getProperty<span style="color: #009900;">&#40;</span>String id<span style="color: #339933;">,</span> String propertyType<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ul>
<p><strong> IDE Script to BrowserMob script conversion</strong></p>
<p>Currently automatic conversion of the IDE script to BrowserMob script isn&#8217;t available. Manual conversion is required.</p>
<ul>
<li>First script the site with selenium IDE.</li>
<li>Save the script and upload to BrowserMob.</li>
<li>The BrowserMob validation will fail because BrowserMob doesn&#8217;t do the automatic conversion of the FlexMonkey markup into BrowserMob compatible code. Copy/paste your  script to a favorite text editor and manually convert the script to a BrowserMob compatible version.</li>
<li>Whenever the script goes to a new page, a new handle needs to be created to the Flex object like below:</li>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Step 1: Home&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;https://www.domain.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// create handle to the flex object - This waits for however long</span>
<span style="color: #006600; font-style: italic;">// the selenium timeout is set, to create the handle</span>
<span style="color: #006600; font-style: italic;">// in other words, this line of code waits for the however long</span>
<span style="color: #006600; font-style: italic;">// the selenium timeout is set, for the swf to load on the page.</span>
<span style="color: #006600; font-style: italic;">// SWF is the id of the swf</span>
<span style="color: #003366; font-weight: bold;">var</span> fm <span style="color: #339933;">=</span> selenium.<span style="color: #660066;">flexMonkey</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SWF&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
....</pre></div></div>

<li>Manually convert the rest of the FlexMonkey markup as illustrated below:
<ul>
<li>verifyProperty(String id, String propertyType, String value);</li>
<p>&lt;Verify <span style="color: #ff0000">value=&#8221;trendChart&#8221;</span> prop=&#8221;automationName&#8221;&gt;&lt;Attribute <span style="color: #ff0000">name=&#8221;zoom&#8221;</span> <span style="color: #ff0000">expectedValue=&#8221;1&#8243;</span> type=&#8221;property&#8221;/&gt;&lt;/Verify&gt;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// SWF is the id of the swf</span>
<span style="color: #003366; font-weight: bold;">var</span> timeout <span style="color: #339933;">=</span> <span style="color: #CC0000;">120000</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">//creating a handle for the flex object</span>
fm <span style="color: #339933;">=</span> selenium.<span style="color: #660066;">flexMonkey</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SWF&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">waitFor</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
 <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
  fm.<span style="color: #660066;">verifyProperty</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;trendChart&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;zoom&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  success <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> success<span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  exception <span style="color: #339933;">=</span> e<span style="color: #339933;">;</span>
  success <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> success<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>success<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  browserMob.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>success<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  transaction.<span style="color: #660066;">setSuccess</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">throw</span> exception<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; after &quot;</span> <span style="color: #339933;">+</span> timeout <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; ms&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<li>change(String id, String value); (used when changing tabs)</li>
<p>&lt;UIEvent <span style="color: #ff0000">command=&#8221;Change&#8221; value=&#8221;bar&#8221;</span> prop=&#8221;automationName&#8221;&gt;&lt;arg <span style="color: #ff0000">value=&#8221;Current Bill&#8221;</span>/&gt;&lt;/UIEvent&gt;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">fm <span style="color: #339933;">=</span> selenium.<span style="color: #660066;">flexMonkey</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SWF&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fm.<span style="color: #660066;">change</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;bar&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;Current Bill&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<li>input(String id, String value); (form inputs)</li>
<p>&lt;UIEvent <span style="color: #ff0000">command=&#8221;Input&#8221; value=&#8221;password&#8221;</span> prop=&#8221;automationName&#8221;&gt;&lt;arg <span style="color: #ff0000">value=&#8221;abc&#8221;</span>/&gt;&lt;/UIEvent&gt;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">fm <span style="color: #339933;">=</span> selenium.<span style="color: #660066;">flexMonkey</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SWF&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fm.<span style="color: #660066;">input</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;password&quot;</span><span style="color: #339933;">,</span> pw<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<li>selectText(String id, int StartPositionOfString int EndPositionOfString); (used to select form inputs before inputting any text)</li>
<p>&lt;UIEvent <span style="color: #ff0000">command=&#8221;SelectText&#8221; value=&#8221;password&#8221;</span> prop=&#8221;automationName&#8221;&gt;&lt;arg <span style="color: #ff0000">value=&#8221;0&#8243;</span>/&gt;&lt;arg <span style="color: #ff0000">value=&#8221;6&#8243;</span>/&gt;&lt;/UIEvent&gt;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">fm <span style="color: #339933;">=</span> selenium.<span style="color: #660066;">flexMonkey</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SWF&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fm.<span style="color: #660066;">selectText</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;password&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<li>click(String id);</li>
<p>&lt;UIEvent <span style="color: #ff0000">command=&#8221;Click&#8221; value=&#8221;Logout&#8221;</span> prop=&#8221;automationName&#8221;/&gt;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">fm <span style="color: #339933;">=</span> selenium.<span style="color: #660066;">flexMonkey</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;SWF&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
fm.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Logout&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</ul>
</li>
</ul>
<p>Hopefully this provides a starting point for external monitoring and/or testing of Flex applications. It should be noted that Webmetrics also offers the capability for monitoring Silverlight and Flash with the <a href="http://www.webmetrics.com/monitoring-services/enterprise-monitoring/services/visual-monitoring/overview">Visual Monitoring</a> service.  </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.browsermob.com/2011/08/flex-automation-using-selenium-and-flexmonkey/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Repost: In the Driver’s Seat: Load Testing Best Practices – Scripting</title>
		<link>http://blog.browsermob.com/2011/08/repost-in-the-driver%e2%80%99s-seat-load-testing-best-practices-%e2%80%93-scripting/</link>
		<comments>http://blog.browsermob.com/2011/08/repost-in-the-driver%e2%80%99s-seat-load-testing-best-practices-%e2%80%93-scripting/#comments</comments>
		<pubDate>Mon, 08 Aug 2011 11:51:32 +0000</pubDate>
		<dc:creator>Anu Sandhanam</dc:creator>
				<category><![CDATA[FAQ]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Load Testing]]></category>
		<category><![CDATA[Load Testing Best Practices]]></category>
		<category><![CDATA[Load Testing Tips]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[BrowserMob]]></category>
		<category><![CDATA[load testing best practices]]></category>
		<category><![CDATA[Neustar]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Webmetrics]]></category>

		<guid isPermaLink="false">http://blog.browsermob.com/?p=1487</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
Hello Readers!! Welcome back to Part 3 of our Load Testing Best Practices series, which focuses on writing good load testing scripts. As I’m sure you would agree to, load testing is an imperative part of every development effort. One of the key components to your load testing efforts is a good load testing script <a href='http://blog.browsermob.com/2011/08/repost-in-the-driver%e2%80%99s-seat-load-testing-best-practices-%e2%80%93-scripting/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
<p>Hello Readers!! Welcome back to Part 3 of our Load Testing Best Practices series, which focuses on writing good load testing scripts.</p>
<p>As I’m sure you would agree to, load testing is an imperative part of every development effort. One of the key components to your load testing efforts is a good load testing script that simulates real user behavior on your web site in the most realistic and accurate way possible.</p>
<p>Before you take a deep dive into the scripting, there are few things you need to plan ahead of time.</p>
<ul>
<li> The first one obviously is the scenario outline. Many clients seek the help of their analytics to identify their most visited pages.</li>
<li> Secondly, identify a reasonable range of pause times between steps.</li>
<li> As the next step, identify if your script will involve randomization or parameterization. If so, are you planning on using a datafile or an array of random values in the script?</li>
</ul>
<p>If you have the answers for all of the above then you are half way through already as what&#8217;s remaining is packaging this into a script which is the objective of this post.  This post is a step by step tutorial on how to write a good load testing  script using the Selenium API and the BrowserMob platform.  However,  some of the tips and information can be used to help with script  creation on other platforms as well. We will be focusing on how to  organize your scripts, how and why to perform content validation, how to  build robust and reusable scripts with the help of optimized selenium  locators amongst other tips and guidelines on the best practices. I’m  confident that at the end of this article you will be able to create  your own load testing scripts in no time.</p>
<p>If you haven’t done so already, you are encouraged to install the following to assist in building the load testing scripts.</p>
<ul>
<li><a href="http://seleniumhq.org/projects/ide/" target="_blank">Selenium IDE</a></li>
<li><a href="http://getfirebug.com/" target="_blank">Firebug</a></li>
<li><a href="https://addons.mozilla.org/en-us/firefox/addon/xpath-finder/" target="_blank">Xpath Finder</a></li>
</ul>
<p><strong>What makes a good load testing script?</strong></p>
<ol>
<li><em><strong>Detailed Comments and Descriptions</strong></em></li>
<p>Although the presence or absence of these is in no way going to affect the performance of your load test, it is always a good practice to include comments wherever possible as they make a good reference for later use, irrespective of the scripting language under use. It is easy to add comments while scripting with the IDE. Right click on the IDE and choose ‘Insert New Comment’.</p>
<p><a href="http://blog.browsermob.com/wp-content/uploads/2011/08/comments2.bmp"><img src="http://blog.browsermob.com/wp-content/uploads/2011/08/comments2.bmp" alt="" /></a></p>
<p><em><strong>Tip:</strong> All comments added in the IDE are automatically converted to “Step Descriptions” when the script is uploaded to BrowserMob. i.e the comment in the picture above would be converted to a BrowserMob step description like below:</em></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Open CNN Home Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Giving each step/page a brief description rather than just “Step 1”, “Step 2” etc also helps find out easily how each step/page is performing during the load testing.</p>
<p><a href="http://blog.browsermob.com/wp-content/uploads/2011/08/graph.png"><img src="http://blog.browsermob.com/wp-content/uploads/2011/08/graph.png" alt="" width="679" height="363" /></a></p>
<li><em><strong>Content validation combined with proper use of ‘waitForPageToLoad’ and ‘waitForNetworkTrafficToStop’</strong></em></li>
<p>“Content validation” is an essential part of every load testing script. Content validation is the only means to confirm the right page got downloaded or the right action was performed during a load test and this can be accomplished by searching for an appropriate piece of content in every step that confirms the validity of the page being downloaded. Selenium has various useful commands that can be used for content validation such as verifyTextPresent, VerifyElementPresent, assertTextPresent, assertElementPresent, waitForTextPresent, waitForElementPresent etc.</p>
<p><em><strong>Tip:</strong> While recording actions with IDE, it is easy to add content validation at the appropriate places. Highlight the appropriate piece of content in each page load, right click and choose the appropriate content validation command as in the screenshot below:</em></p>
<p><a href="http://blog.browsermob.com/wp-content/uploads/2011/08/verify_text.bmp"><img src="http://blog.browsermob.com/wp-content/uploads/2011/08/verify_text.bmp" alt="" /></a></p>
<p>Consider the snippets below:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Open CNN Home Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.cnn.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">verifyTextPresent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Latest news&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>[Example: 1a]</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Open CNN Home Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.cnn.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">waitForTextPresent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Latest news&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>[Example: 1b]</p>
<p><em>Which one of the above is the right one? </em></p>
<p>The first one will fail immediately because the page needs to load completely or at least partially until the content “Latest news” becomes visible. The second one may not fail but is recommended only if you intend to measure the “Perceived Load Time” rather than the complete “Page Load Time”. What is the difference between the two? In the second snippet above (script 1b), the script is going to wait only until the content “Latest news” becomes visible before moving on to the next step. To a user that intends to load the CNN Home page and click on the first article under “Latest news”, this perceived load time is all they are going to care about. Whereas, the complete “Page Load Time” is measured only if the script waits for the page to load completely before moving on to the next step and this can be accomplished by using <a href="http://static.browsermob.com/api/com/browsermob/api/Selenium.html#waitForPageToLoad(java.lang.String)" target="_blank">selenium API’s waitForPageToLoad</a> and/or <a href="http://static.browsermob.com/api/com/browsermob/api/BrowserMob.html#waitForNetworkTrafficToStop(long,%20long)" target="_blank">BrowserMob API’s waitForNetworkTrafficToStop</a>.</p>
<p>Modifying the second snippet from above:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> timeout <span style="color: #339933;">=</span> <span style="color: #CC0000;">60000</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Open CNN Home Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.cnn.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">verifyTextPresent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Latest news&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>[Example: 1c]</p>
<p><em>When is BrowserMob API’s waitForNetworkTrafficToStop helpful? </em></p>
<p>Consider the scenario wherein the user loads the site united.com and tries to find the airport code using the site’s AutoSuggest feature.</p>
<p><a href="http://blog.browsermob.com/wp-content/uploads/2011/08/UNITED.png"><img src="http://blog.browsermob.com/wp-content/uploads/2011/08/UNITED.png" alt="" width="521" height="506" /></a></p>
<p>Let’s consider the snippet below that tries to simulate the above scenario:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Step 1: United Airlines Home&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.united.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">verifyTextPresent</span><span style="color: #009900;">&#40;</span>“Travel information”<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Step 2: Choose Flights using AutoSuggest&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id=shop_from0_temp&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">typeKeys</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id=shop_from0_temp&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;SAN &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">mouseOver</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;css=div#autoSuggestDiv &amp;gt; div&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">clickAt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;css=div#autoSuggestDiv &amp;gt; div&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
………
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>[Example: 1d]</p>
<p>Running a validation for the script above threw the error “Element css=div#autoSuggestDiv &gt; div not found”. What was the reason? Look at the waterfall chart for united.com Home page below:</p>
<p><a href="http://blog.browsermob.com/wp-content/uploads/2011/08/index.png"><img src="http://blog.browsermob.com/wp-content/uploads/2011/08/index.png" alt="" width="743" height="28" /></a></p>
<p><a href="http://blog.browsermob.com/wp-content/uploads/2011/08/united_1a.png"><img src="http://blog.browsermob.com/wp-content/uploads/2011/08/united_1a.png" alt="" width="929" height="577" /></a><br />
<a href="http://blog.browsermob.com/wp-content/uploads/2011/08/united_2a.png"><img src="http://blog.browsermob.com/wp-content/uploads/2011/08/united_2a.png" alt="" width="929" height="540" /></a><br />
<a href="http://blog.browsermob.com/wp-content/uploads/2011/08/united_3a.png"><img src="http://blog.browsermob.com/wp-content/uploads/2011/08/united_3a.png" alt="" width="850" height="560" /></a><br />
<a href="http://blog.browsermob.com/wp-content/uploads/2011/08/united_4a.png"><img src="http://blog.browsermob.com/wp-content/uploads/2011/08/united_4a.png" alt="" width="929" height="305" /></a></p>
<p>The ‘waitForPageToLoad’ at Step 1 captured the traffic only until the document was complete. But as the waterfall chart above shows, several images, JavaScript files and iframes loaded asynchronously after the document was complete, especially the JavaScript file ‘airportSuggestion.js’ which was required for the autosuggestion at Step 2. Since the script simulated entering of the airport code ‘SAN’ even before the airportSuggestion.js was loaded, the autosuggest did not work as expected, resulting in a script failure.</p>
<p>Here is the modified script that works as expected:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Step 1: United Airlines Home &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.united.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">waitForNetworkTrafficToStop</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2000</span><span style="color: #339933;">,</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">verifyTextPresent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Travel information&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Step 2: Choose Flights using AutoSuggest &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id=shop_from0_temp&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">typeKeys</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id=shop_from0_temp&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;SAN &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// wait for the network traffic to stop and the autosuggest to populate</span>
browserMob.<span style="color: #660066;">waitForNetworkTrafficToStop</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2000</span><span style="color: #339933;">,</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">mouseOver</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;css=div#autoSuggestDiv &amp;gt; div&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">clickAt</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;css=div#autoSuggestDiv &amp;gt; div&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>[Example: 1e]</p>
<p>I’d like to highlight one more important aspect of the ‘waitForPageToLoad/waitFor[Text/Element]Present’ and ‘waitForPageToLoad/verify[Text/Element]Present’ combination. While both work fine it is recommended to use the combination waitForPageToLoad/verify[Text/Element]Present for load testing. Why?</p>
<p>Consider the snippets below:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> timeout <span style="color: #339933;">=</span> <span style="color: #CC0000;">60000</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Open CNN Home Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.cnn.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">verifyTextPresent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Latest news&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>[Example: 1f]</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> timeout <span style="color: #339933;">=</span> <span style="color: #CC0000;">60000</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Open CNN Home Page&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.cnn.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">waitForTextPresent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Latest news&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>[Example: 1g]</p>
<p>Both would exhibit the same behavior when the page loads successfully. However, in the instance of an error, say an ‘Internal Server’ error or a ‘Connection Reset’ error, the script would declare an error immediately after the error page loads with script 1f while it’ll wait for 60 more seconds to declare the same error with script 1g as the ‘waitForTextPresent(“Latest news”) is going to wait for 60 more seconds, which is the timeout we’ve set in the script, to declare the same content error, irrespective of the page’s status code. Besides,  script 1f will help simulate more transactions in the same amount of time than script 1g, especially in the event of errors.</p>
<li><em><strong>Setting Proper Timeouts</strong></em></li>
<p>The default selenium timeout is 30 seconds (30000 milliseconds) and the default TimeUnit in use by BrowserMob is milliseconds. It must be remembered that most of the &#8216;waitFor&#8217; commands like the &#8216;waitForElementpresent&#8217;, &#8216;waitForVisible&#8217;, &#8216;waitFortextPresent&#8217; etc wait for however long this default selenium timeout is set to. Timeouts can be set the following way in the script:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> timeout <span style="color: #339933;">=</span> <span style="color: #CC0000;">60000</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>It is recommended to set the timeout value before the actual transaction begins in the script. Studies show that the ideal page load time is 5 seconds. Any amount of load time greater than this is considered unacceptable for real users. However, 5 seconds is too small of a timeout threshold for load testing as load times are expected to rise with increase in user load. Hence, 60 seconds to 120 seconds would be considered ideal. The upper limit on the timeout threshold set by BrowserMob is 120 seconds.</p>
<p>Occasionally, you may have the necessity to set a different timeout value for different page loads which can be accomplished by the solution proposed in this <a href="http://blog.browsermob.com/2010/06/advanced-handling-of-page-timeouts-in-selenium/" target="_blank">article</a>. The article on <a href="http://blog.browsermob.com/2011/03/selenium-tips-wait-with-waitforcondition/" target="_blank">waitForCondition</a> may also make an interesting read to learn more about advanced handling of timeouts.</p>
<li><em><strong>Optimization of Locators</strong></em></li>
<p>Selenium provides several ways of locating elements on pages. It may be worthwhile to read through this before proceeding further: <a href="http://release.seleniumhq.org/selenium-remote-control/0.9.2/doc/dotnet/Selenium.html" target="_blank">http://release.seleniumhq.org/selenium-remote-control/0.9.2/doc/dotnet/Selenium.html</a></p>
<p>The most commonly used locator is the xpath. FireFox plugins like xpath finder, firebug may be used to identify the correct xpath for the appropriate elements. Below are a couple of useful articles on this topic:</p>
<p><a href="http://blog.browsermob.com/2008/12/using-firebug-for-load-testing/" target="_blank">http://blog.browsermob.com/2008/12/using-firebug-for-load-testing/ </a></p>
<p><a href="http://blog.browsermob.com/2009/04/test-your-selenium-xpath-easily-with-firebug/" target="_blank">http://blog.browsermob.com/2009/04/test-your-selenium-xpath-easily-with-firebug/</a></p>
<p><a href="http://blog.browsermob.com/wp-content/uploads/2011/08/xpath1.bmp"><img src="http://blog.browsermob.com/wp-content/uploads/2011/08/xpath1.bmp" alt="" /></a></p>
<p>Optimization of the locators used is extremely important for script robustness and re-usability. In the screenshot below, the IDE has captured the xpath ‘link=Arrested GI had gunpowder, ammo’ when clicking on the first article under “Latest News”. Obviously, the script will work only until this article is available on the Home Page. The xpath shown by firefbug for the same is ‘/html/body/div[5]/div/div[4]/div[3]/div/div[3]/div/ul[2]/li/a’ . Again, this might work temporarily but the moment the site is updated and the DOM changes, the script could break because of this complex xpath as the hierarchy of the elements could have been altered. ‘//ul[@class='cnn_bulletbin']/li[1]/a’ would be a much more optimized and a less brittle xpath for this example. Learn more about locators and pattern matching <a href="http://blog.browsermob.com/2011/02/regular-expressions-and-pattern-matching-with-browsermob-and-selenium/" target="_blank">here</a>.</p>
<li><em><strong>Pause Times</strong></em></li>
<p>Inserting pause times in between steps is essential in order to simulate real user actions more closely. A range of pause times is recommended over a fixed time as different users browse through a web site at different paces. Both <a href="http://static.browsermob.com/api/com/browsermob/api/BrowserMob.html#pause(long)" target="_blank">BrowserMob</a> and <a href="http://static.browsermob.com/api/com/browsermob/api/Selenium.html#pause(java.lang.String)" target="_blank">Selenium API’s pause</a> method can be used to insert think/pause times in between steps.</p>
<li><em><strong>Randomization</strong></em></li>
<p>In the context of load testing, I want to emphasize the extreme importance of having large datasets available for testing. Many important bugs simply do not surface unless you deal with very large entities such thousands of users, thousands of mail server mailboxes etc. For scenarios involving product checkout, browsing through product pages etc, consider randomizing the product being purchased or browsed through, from a list of several products in order to simulate real user behavior more realistically as not all users are going to be purchasing the same product at the same time. Randomization and parameterization can be achieved in a few ways which are explained in depth <a href="http://blog.browsermob.com/2010/10/parameterizing-your-tests-part-2/" target="_blank">here</a> and <a href="http://blog.browsermob.com/help/creating-a-test/parameterizing-your-tests/" target="_blank">here</a>.</p>
<li><strong><em>Use of quickStop() and stopExpected()</em></strong></li>
<p>The BrowserMob API has two methods that come in handy when you want to pause a test that has exceptionally lengthy scripts running, such as loops that repeat certain actions several times over the course of the script execution.</p>
<p>By default, when a test is paused, BrowserMob will wait for the actively running scripts to finish executing and complete the current transaction. Long running scripts with loops or scripts testing a streaming video will not be interrupted until they complete. So in order to abort such transactions immediately on pausing, it is important to include the method <a href="http://static.browsermob.com/api/com/browsermob/api/BrowserMob.html#quickStop%28%29" target="_blank">browserMob.quickStop()</a> at the top of the script.</p>
<p>However, forcefully aborting the scripts could result in an increased error rate, skewing the results. This can be avoided by using quickStop() in conjunction with <a href="http://static.browsermob.com/api/com/browsermob/api/BrowserMob.html#stopExpected%28%29" target="_blank">stopExpected()</a>. This instructs BrowserMob that the script is expecting to be stopped at any time and if that happens, the sudden stop should not be considered an error.</p>
<p>Here is a complete script, incorporating all of the above:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">browserMob.<span style="color: #660066;">quickStop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">stopExpected</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> selenium <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">openBrowser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> c <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">getActiveHttpClient</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//  Set the timeout threshold</span>
<span style="color: #006600; font-style: italic;">//  Set a different timeout threshold for local validation as it has a limit on the</span>
<span style="color: #006600; font-style: italic;">// transaction length, capped at 2 minutes.</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>browserMob.<span style="color: #660066;">isValidation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> timeout <span style="color: #339933;">=</span> <span style="color: #CC0000;">30000</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000066; font-weight: bold;">else</span>
<span style="color: #009900;">&#123;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> timeout <span style="color: #339933;">=</span> <span style="color: #CC0000;">120000</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
selenium.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//*************** Randomize think time *********************//</span>
<span style="color: #003366; font-weight: bold;">function</span> randomXToY<span style="color: #009900;">&#40;</span>minVal<span style="color: #339933;">,</span>maxVal<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 	<span style="color: #003366; font-weight: bold;">var</span> randVal <span style="color: #339933;">=</span> minVal<span style="color: #339933;">+</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>maxVal<span style="color: #339933;">-</span>minVal<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	<span style="color: #000066; font-weight: bold;">return</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>randVal<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> sleep<span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span>y<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>browserMob.<span style="color: #660066;">isValidation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  		browserMob.<span style="color: #660066;">pause</span><span style="color: #009900;">&#40;</span>randomXToY<span style="color: #009900;">&#40;</span>x<span style="color: #339933;">,</span>y<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span>
 	<span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
  		browserMob.<span style="color: #660066;">pause</span><span style="color: #009900;">&#40;</span>randomXToY<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">//********** Randomly pick an articleId, SearchString combination *************//</span>
<span style="color: #003366; font-weight: bold;">function</span> randOption<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> list <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;1,PERMALINK;2,Related Links;3,Related Articles;4,Most Popular&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> myArray <span style="color: #339933;">=</span> list.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #006600; font-style: italic;">//pick a random combination from the array every time</span>
	<span style="color: #003366; font-weight: bold;">var</span> position <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span>myArray.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> myArray1 <span style="color: #339933;">=</span> myArray<span style="color: #009900;">&#91;</span>position<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</span> myArray1<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> selected <span style="color: #339933;">=</span> randOption<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> selected<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> string <span style="color: #339933;">=</span> selected<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Logging the variables being set provides a good means of troubleshooting</span>
browserMob.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Begin Transaction</span>
transaction <span style="color: #339933;">=</span> browserMob.<span style="color: #660066;">beginTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Open CNN Home&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #000066;">open</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;http://www.cnn.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">verifyTextPresent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Latest news&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
sleep<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">beginStep</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Click on a random article&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// Randomly clicking on an article with every script run</span>
selenium.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;//ul[@class='cnn_bulletbin']/li[&quot;</span><span style="color: #339933;">+</span>id<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;]/a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
selenium.<span style="color: #660066;">verifyTextPresent</span><span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
browserMob.<span style="color: #660066;">endStep</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
browserMob.<span style="color: #660066;">endTransaction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As web sites get complex, the scenarios for the load testing tend to get complex and so does the scripting and other load testing requirements such as configuration and set up. Our team of trained load testing experts is waiting to assist you with all your complex load testing requirements. <a href="http://www.webmetrics.com/About-Us/Contact-Us" target="_blank">Contact us</a> right away and get all your load testing needs fulfilled!!</p>
<p>Hope you enjoyed reading this article as much as I enjoyed writing it. Coming up next in this Load Testing Best Practices blog series is “Test Execution” so be sure to stay tuned.</p>
<p>Happy Testing!!</ol>
<hr />
<p><strong>More articles<em>In the Driver&#8217;s Seat</em> Series:</strong><br />
<a href="http://blog.browsermob.com/2011/07/repost-in-the-drivers-seat-load-testing-best-practices-planning-2/">Part One: Planning</a><br />
<a href="http://blog.browsermob.com/2011/07/repost-in-the-driver%e2%80%99s-seat-load-testing-best-practices-configuration/">Part Two: Configuration</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.browsermob.com/2011/08/repost-in-the-driver%e2%80%99s-seat-load-testing-best-practices-%e2%80%93-scripting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Repost: In the Driver’s Seat: Load Testing Best Practices &#8211; Configuration</title>
		<link>http://blog.browsermob.com/2011/07/repost-in-the-driver%e2%80%99s-seat-load-testing-best-practices-configuration/</link>
		<comments>http://blog.browsermob.com/2011/07/repost-in-the-driver%e2%80%99s-seat-load-testing-best-practices-configuration/#comments</comments>
		<pubDate>Thu, 28 Jul 2011 18:02:45 +0000</pubDate>
		<dc:creator>Steve Thurman</dc:creator>
				<category><![CDATA[Load Testing]]></category>
		<category><![CDATA[Load Testing Best Practices]]></category>
		<category><![CDATA[Load Testing Tips]]></category>
		<category><![CDATA[BrowserMob]]></category>
		<category><![CDATA[load testing best practices]]></category>
		<category><![CDATA[Neustar]]></category>
		<category><![CDATA[Webmetrics]]></category>

		<guid isPermaLink="false">http://blog.browsermob.com/?p=1462</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
So you reviewed part 1 of our best practices blog series, “Planning” and now you are wondering about configuring your test.  What are all the pieces that need to be thought about and configured?  Fortunately these are not complex questions; you just need to know some basic information: Where do you expect or see web <a href='http://blog.browsermob.com/2011/07/repost-in-the-driver%e2%80%99s-seat-load-testing-best-practices-configuration/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
<p><a href="http://blog.webmetrics.com/wp-content/uploads/2010/12/loadtesting.jpg"></a>So you reviewed part 1 of our best practices blog series, <a href="http://blog.browsermob.com/2011/07/repost-in-the-drivers-seat-load-testing-best-practices-planning-2/" target="_blank">“Planning”</a> and now you are wondering about configuring your test.  What are all the pieces that need to be thought about and configured?  Fortunately these are not complex questions; you just need to know some basic information:</p>
<ol>
<li>Where do you expect or see web traffic coming from?</li>
<li>How many users come to your site?</li>
<li>How should you apply your user load during the test?</li>
<li>Should you test with virtual users or real browser users?</li>
<li>Where do users spend the most time on your site?</li>
<li>How long do users take when navigating your site?</li>
<li>Do you use third party vendors?</li>
</ol>
<p><strong>Where do you expect to see web traffic from?</strong></p>
<p>Whether this is a new site getting ready to go live or an existing site already on the web you probably have a feel for where your visitors will be coming from.  A site like Amazon will have visitors from around the world, whereas the government site for a province in Canada will see most of its traffic come from the local province.  You want to be sure that when you test your site you have users coming from various points attempting to emulate your normal traffic.  If most of your traffic is coming from North America finding out your pages take twice as long to load in Asia is good to know, but only if you are planning on getting more users from Asia.  But if you focus on North America all the data gathered in the load test will help you make the experience on your site better for the majority of users.</p>
<p>If you don’t have the capacity to apply load from the most desirable locations for your load test you can use locations that are further away.  So for example you need to add Tokyo to get the load you want in your test.  You find that from Washington, D.C. your page load time is 2 seconds when there is no load on the site.  From Tokyo the page load time is 4 seconds with no load.  So you now know that testing from Tokyo has a 2 second lag and you can use that knowledge to better interpret results from the Tokyo location of your load test.</p>
<p>For more information on how to set up a multi-region test using BrowserMob, feel free to check out the tutorial at the end of this article.</p>
<p><strong>How many users come to your site?</strong></p>
<p>How many users should you choose to test on your load test?  This question should be answered during the planning phase by deciding what the goal of your load test is (for a detailed discussion see the previous blog <a href="http://blog.webmetrics.com/webmetrics-performance/loadtesting_planning/" target="_blank">“Planning”</a>).  Are you testing stability over time?  Are you attempting to find the breaking point of your site?  In general you can assume your site should be able to handle 250 users per core in your web server farm.  This can vary greatly depending on bottle necks in the code, in your network, or coming from the web to your network.  If you want to see when the site breaks, I suggest finding your peak traffic number and adding 10% during each interval until you see performance that is unacceptable.  This assumes of course that your site currently handles your peak traffic with good load times and a low error rate.    If you are testing stability over time (i.e. looking for a memory leak), then I suggest taking an average user load level and running at that level constantly over a time period beyond where you expect the issue to surface.</p>
<p><strong>How should you apply your user load during the test?</strong></p>
<p>Now that you have a number in mind, how are you going to apply that number of users to your load test?  Typically web traffic comes in waves.  It will surge and recede over the course of a day.  Even with a major event like a new Super Bowl commercial the surge is not instant, 1000 users appear over time not in the same second.  The best practice here is to set up your load test with intervals of ramps and constants, so that you can get granular data.  A ramp is a period where we increase/decrease users and a constant is a period where the user count remains unchanged but the users are executing scenarios on the site.  If we take a 1000 user test we could set up an hour test with intervals like this:</p>
<p style="text-align: center;"><a href="http://blog.webmetrics.com/wp-content/uploads/2011/07/LT-Table.jpg"><img class="size-full wp-image-1205 aligncenter" title="LT Table" src="http://blog.webmetrics.com/wp-content/uploads/2011/07/LT-Table.jpg" alt="Load Testing Best Practices _ configuration" width="256" height="315" /></a></p>
<p>This basically shows 20 total intervals, 10 ramps and 10 constants.  During each ramp users are added until the Max User count is reached.  During each constant the users are executing scenarios constantly.  Whenever a user finishes a scenario or encounters an error they will immediately start another scenario continuing to load the site at a constant level.</p>
<p>You could apply 1000 users at the beginning and run them over the course of the full hour but you will get data that only tells you about 1000 users.  Using the ramp methodology allows you to pin point when events occur.  You might find that between 400 and 500 users the page load times begin to take longer.  When you hit 600 users you start seeing errors due to connections being dropped.  When you hit 800 users your site falls over.  All of those pieces of data would be missed if you apply 1000 users to start.  You would just know that my site will fall over at 1000 users, but you won’t end up with a lot of actionable data pointing you to problem areas to address.</p>
<p><strong>Should you test with virtual users or real browser users?</strong></p>
<p>First let us define what each type of user is.  A virtual user is an agent that will mimic the http requests made by your site from a browser.  A real browser user is an agent that makes use of selenium to control an actual browser and navigates your site like a real user.  It takes fewer resources to create virtual users where you can get multiple users per CPU core.  A real browser user actually uses a browser on a computer and therefore is limited to one browser per core.  Virtual Users typically are single threaded and make each http request to build in order one at a time while browsers actually will make multiple http requests at the same time.</p>
<p>So how do you decide what type of user your site needs?  Virtual users are best for generating load on relatively simple sites that use traditional web forms and http get and post functionality.  You can also get a much higher user load for less as virtual users are less resource intensive.  Real Browsers are best for sites that use AJAX to refresh data for the user without making a full page request or make heavy use of JavaScript to enhance the user experience.</p>
<p>For very high volume testing, you can also use a combination of the two types of users by creating scripts that exercise the static parts of your site with virtual users and then real browser user scripts for the interactive parts of the site.  This will up the load on the site as a whole and will help you to achieve extremely high load levels.</p>
<p><strong>Where do users spend the most time on your site?</strong></p>
<p>The most important parts of your site to test are the parts that users most frequently visit.  This is not to say you shouldn’t exercise the more unused portions of your web site during a load test but the point is that you should try to keep your scripts small and focused.  This allows you to concentrate on particular processes or pages and get very detailed data pointing you to problem areas.  Let’s take a basic ecommerce site as an example.  Users come to the homepage, browse, select some products, checkout and leave, right?  Actually some users come to the homepage and then leave, some browse around and then leave, some add items to their cart and then abandon the cart and leave, and some buy the product they added to the cart.  So you can write a large script that comes to the homepage, navigates every category, picks some products, and then checks out but that is not really how your site is loaded.</p>
<p>For this example you would want to create 4 test scripts as follows:</p>
<p>1) Go to homepage and exit<br />
2) Homepage, browse a category and exit<br />
3) Homepage, browse, add product and exit<br />
4) Homepage, browse, add product and checkout</p>
<p>One that comes to the homepage and then exits, one that browses a category and then exits, one that browses for a product and adds that product to the cart and then exits, and finally one that browses the site for a product and adds the product to the cart and then checks out.  Then you apply a percent of the load to each script based on the real user traffic on your site.  Your checkout process may not be able to handle 2000 concurrent users but you may never have more than 5% of your users checking out which would mean checkout only needs to handle 100 concurrent users.</p>
<p>Again I want to stress simple is best when scripting.  You could set these scripts up to browse random categories and random products.  These scripts will take longer to write and will be more apt to run into products with not enough availability causing an error in the test that has nothing to do with the load.  You are better served to keep your scripts simple to start and then add functionality such that you get good coverage over the key components of your web site.  What you really want to do is eliminate unknown variables so that you can tell what page, item, or process is hanging when load is applied.</p>
<p><strong>How long do users take when navigating your site?</strong></p>
<p>The next thing to consider is how fast you want the scripts to execute.  By using computers we have removed the human element of looking over the page and figuring out where to click next.  We have scripted this and can click the next link the moment a page has loaded.  So again to better approximate reality you should consider adding user think time to scripts.  If you have appropriate analytics data available, you can gather information from your site to figure out what the actual time is that a user spends on the Home page before making the next selection.  As a general rule and in order to stress the site sufficiently, we use a function that randomizes the think time between 3 and 7 seconds after every page load.</p>
<p><strong>Do you use third party vendors?</strong></p>
<p>Please make sure your vendors are aware of the dates and times when you expect to run these load tests.  Many times when they are not notified they will see the spike in activity as an attack and may blacklist the IP’s where the traffic is coming from.  This would cause your load test to record either errors, as items wouldn’t be available for download, or you could get invalid page load time data as not all the components of your page would be downloading for the test.</p>
<p><strong>Parting Thoughts</strong></p>
<p>We have answered some basic questions and made several decisions regarding configuring your load test.  We know where we want user traffic to come from.  We have a target number of users, how to apply the user load during the test execution, and have picked the type of user best suited to the script.  We have allocated those users to different behaviors for the test.  We have determined a user think time to apply between actions.  We have either removed calls to third parties or notified them of the load test execution.  This has set us up for a load test that will service our needs and ensure that we get detailed data that will help us determine what areas of the site need attention.</p>
<p>You should now be ready for “Scripting” the next entry in this blog series.  Be sure to check back or subscribe to the RSS feed if you are interested.  Feel free to check the video below to see how to setup a multi-region test using our BrowserMob tool.  If you have any comments or suggestions for future posts you can reach us at <a href="mailto:marketing@webmetrics.com">marketing@webmetrics.com</a>.  Thanks!</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="349" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/hLHlnUEicUM?version=3&amp;hl=en_US" /></object></p>
<hr />
<p><strong>More in the <em>In the Driver&#8217;s Seat</em> Series:</strong><br />
<a href="http://blog.browsermob.com/2011/07/repost-in-the-drivers-seat-load-testing-best-practices-planning-2/">Part One: Planning</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.browsermob.com/2011/07/repost-in-the-driver%e2%80%99s-seat-load-testing-best-practices-configuration/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Repost: In the Driver&#8217;s Seat: Load Testing Best Practices &#8211; Planning</title>
		<link>http://blog.browsermob.com/2011/07/repost-in-the-drivers-seat-load-testing-best-practices-planning-2/</link>
		<comments>http://blog.browsermob.com/2011/07/repost-in-the-drivers-seat-load-testing-best-practices-planning-2/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 13:46:20 +0000</pubDate>
		<dc:creator>Joel Weierman</dc:creator>
				<category><![CDATA[Load Testing]]></category>
		<category><![CDATA[Load Testing Best Practices]]></category>
		<category><![CDATA[Load Testing Tips]]></category>
		<category><![CDATA[load testing best practices]]></category>
		<category><![CDATA[Neustar]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Webmetrics]]></category>

		<guid isPermaLink="false">http://blog.browsermob.com/?p=1417</guid>
		<description><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
This is the first part of a five-part blog series that will cover all the aspects of load testing, including planning, configuring, scripting, executing and analyzing. This first article focuses on the key areas and questions to consider when planning to run a test. Why test? I generally see customers greatly OVER-estimating their expected capacity <a href='http://blog.browsermob.com/2011/07/repost-in-the-drivers-seat-load-testing-best-practices-planning-2/'>[...]</a>]]></description>
			<content:encoded><![CDATA[<style type="text/css">
#leftcontainerBox {
float:left;
position: fixed;
top:40%;
left:60px;
z-index:1;
background-color:#F0F4F9}

#leftcontainerBox .buttons {
float:left;
clear:both;
margin:4px 4px 4px 4px;
width:55px;
height:60px;
padding-bottom:2px;
}


#bottomcontainerBox {
float:left;
height:30px;
width:100%;
background-color:#F0F4F9}

#bottomcontainerBox .buttons {
float:left;
height:30px;
width:85px;
margin:4px 4px 4px 4px;
}

</style>
<p>This is the first part of a five-part blog series that will cover all   the aspects of load testing, including planning, configuring,   scripting, executing and analyzing. This first article focuses on the   key areas and questions to consider when planning to run a test.</p>
<h3><strong>Why test?</strong></h3>
<p>I  generally see customers greatly OVER-estimating their expected   capacity and many are often shocked when they get the first set of test   results back from us. Usually, there is a lot of work to do in order to   get the website or application tuned up and ready for a full  production  release.</p>
<p>Load testing helps you scientifically  determine how many customers  the website or application will support &#8211;  BEFORE you potentially find  out the hard way (i.e. when users actually  come to your site and you  have to scramble to make last minute capacity  improvements). In the case  where your site generates online revenue,  it will also help you to  quantify your investment and give you specific  metrics on your overall  cost per transaction in terms of required  infrastructure. For example,  if the site is able to support 50,000  transactions under peak  conditions, you can take this number and divide  it by your monthly  infrastructure costs (say $2,000) to determine your  infrastructure&#8217;s  cost per transaction (e.g. 4 cents).</p>
<p>The key  here is to find out this information BEFORE it causes  irreparable harm  to your business, brand and reputation. The only  reliable way of doing  this is to plan a load test.</p>
<h3><strong>When to test?</strong></h3>
<p>The  ideal time to run your first load test is after User Acceptance   Testing (UAT) is complete, but prior to moving the application into   production. Load testing should be part of your project plan and it’s   important to allow for sufficient time in your plan to complete   performance and load testing. Based on my experience, you need to allow   for an absolute minimum of 2-3 weeks for appropriate load test  planning,  scripting and execution. Many customers try to compress this  time down  when things are running behind, but there are no tricks to  accelerating  this process (and generally this results in a painful  experience for  everyone involved and severe sleep deprivation!). The  process of load  testing and performance analysis is an incremental  process that requires  careful review and dedicated time from the  development team to address  any problems or recommendations from the  load tests.</p>
<h3><strong>How many tests should I run?</strong></h3>
<p>Based on our work with hundreds of customers over the years, we have found that <strong>three</strong> is the magic number.</p>
<ul>
<li>The <strong>first test</strong> provides you a benchmark and a baseline  snapshot of the current  performance of the site. There are always a  number of recommendations  for improvement from the first test and you  need time to let your team  react to the results and implement the  necessary changes.</li>
</ul>
<ul>
<li>The <strong>second test</strong> is designed to validate all the changes made  after the first test and  identify any remaining bottlenecks. Additional  tweaks to the  infrastructure or application itself are then made in  preparation for  the third test.</li>
</ul>
<ul>
<li>The <strong>third test</strong> is  then designed to be the final validation  point prior to go-live and  ideally will uncover the peak performance  point of the application.</li>
</ul>
<p>Of  course, your mileage may vary here. Some customers are able to   complete this process with just two tests, but generally we have found   it&#8217;s best to start with three tests and add additional ones as needed.</p>
<h3><strong>Real Browsers or Virtual Users?</strong></h3>
<p>With  the rapid adoption and investment in Cloud Computing, it&#8217;s now   possible to cost effectively launch thousands of real browsers an hour   to test a website. <a href="http://www.neustar.biz/">Neustar</a> offers this service in both a self-service platform as well as a fully managed engagement. For more information, visit the <a href="http://www.browsermob.com/">BrowserMob website</a>.   This has added a lot of realism to the process of load testing, which   until recently has been limited to the testing using a &#8220;virtual user&#8221;  or  &#8220;virtual browser&#8221; that simply mimics the http request/response  sequence  issued by the browser.</p>
<p>Testing with real browsers  provides unprecedented realism in driving  user load to the site and  generating a realistic load profile against  the application. This is  especially true with the wide prevalence of  AJAX and client side  plug-ins such as Flash/Flex. We have recently  partnered with <a href="http://www.gorillalogic.com/">Gorilla Logic</a> to make the process of load testing of Flex applications as easy as   possible. Now you can quickly create automated Flex test scripts and   launch thousands of real browsers to stress test your Flash/Flex   applications!</p>
<p>Testing with real browsers also greatly speeds up  the time to develop  test scripts. The scripts also interact with the  site from a functional  standpoint by referring directly to the  appropriate DOM elements that  comprise the page rather than relying on  mimicking of the underlying  http request/response sequence. This helps  to improve script re-use and  provides an additional assurance that the  test scripts will be  accurately performing the actions of a real user  when visiting the site.  Virtual user testing still has its place for  very high volume testing  and testing of web service transactions or  very simple websites, but in  general load testing with real browsers is  highly recommended for most  sites.</p>
<h3><strong>How much load should I test with?</strong></h3>
<p>500. Just kidding. <img src='http://blog.browsermob.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>The  answer comes down to whether you need to execute a &#8220;stress test&#8221;  or a  &#8220;load test.” Let me explain the difference between these two terms  and  how they impact your overall test plan.</p>
<p><strong>Stress Test</strong><br />
A &#8220;stress test&#8221; is designed to take the existing application   infrastructure and test it to the breaking point where one or more   bottlenecks are exposed. This involves sizing the test based on the   amount of expected traffic the total infrastructure is expected to   handle. A good general rule of thumb here is approximately 250   concurrent users per each CPU core available to process front-end web   server requests. Please note that this is a very rudimentary metric and   varies widely based on the type of web server, network infrastructure   and most importantly the application. Performance benchmarking can help   you better determine exactly what this number is, but 250 is generally a   good number to start with. For example, if you had a new application   with 2 front-end web servers installed on a quad-core machine, a   reasonable test would be to run with 2000 concurrent users (250 users x 2   machines x 4 cores).</p>
<p><strong>Load Test</strong><br />
A &#8220;load  test&#8221; is designed to test the site to a certain volume of page  views or  transactions, in order to validate that the site has sufficient   capacity to support expected user traffic. This type of data can be   obtained from web analytics data such as Omniture or Google Analytics.   Generally, the target volume is based on the peak hour of historical   usage for the application.</p>
<p>For example, say you find that in the  peak hour there are 50,000  pages being loaded and you expect a 20%  increase in overall web traffic  in the next several months. A good test  approach would be to target a  total load of 75,000 pages views so you  can determine the ability of the  application to serve up to and above  the target page view count.</p>
<h3><strong>Concurrent User Calculator</strong></h3>
<p><a href="http://sitestress.webmetrics.com/user_calc.html" target="_blank"><br />
<img src="http://blog.webmetrics.com/wp-content/uploads/2011/07/concurrent_user_calculator1-300x219.png" alt="" width="300" height="219" /><br />
</a></p>
<p>When  planning out your load test, it&#8217;s helpful to use a calculator to   determine the total number of concurrent users necessary to reach your   target load level. To illustrate and help with this process, I&#8217;ve   created a simple <a href="http://sitestress.webmetrics.com/user_calc.html">concurrent user calculator</a>.  Simply plug in the   desired number of page views and the rate (e.g. 100,000 page views per   hour), the session time and the desired test time (we generally   recommend 60 minutes) and the calculator will determine approximately   the number of users required to generate the associated number of page   views. The calculator can be easily extended to estimate the number of   transactions expected to complete during the test.</p>
<p>Before going  too far explaining the calculator though, let me first  explain a common  misconception between a &#8220;concurrent user&#8221; and a &#8220;unique  user&#8221; or  &#8220;user&#8221;. We have lots of customers that come to us and say that  they  need to test their site with 50,000 &#8220;users.” Most of the time,  what  they are trying to do is simulate the business requirement of  50,000  unique users coming to the site and performing a specific  transaction.  This is very different from the idea of a &#8220;concurrent  user.” A  concurrent user is designed to run through a transaction from  start to  finish and then immediately start again, repeating the same   transaction. This user will do this repeatedly, until the end of the   test. A &#8220;unique user,” on the other hand is simply a single execution of   a concurrent user or the completion of one transaction (execution of   the test script from start to finish). Depending on a number of factors,   concurrent users are able to generate the traffic equivalent of   thousands of unique users over the course of a standard test. The   calculator determines the number of <em>concurrent users</em> required  to  generate the expected amount of load. Now with definitions out of  the  way, let&#8217;s look at a specific of example of how to effectively use  the  calculator to plan your load test.</p>
<p>Say you have a 10-step  check out process and you want to ensure the  site can handle 1,000  checkouts in one hour. The total number of page  views associated with  this process is 10 steps x 1,000 transactions =  10,000 page views.  Let&#8217;s also assume that we expect each page load to  take 5 seconds and  the user to wait 5 seconds on each page. This would  give us a total  session time of 10 steps x 10 seconds = 100 seconds. So  plugging in  10,000 pages per hour and 100 seconds for the session time,  gives us a  concurrent user count of approximately 278. In this way, we  can  calculate how many users are needed to complete the key business   transactions for the website. It&#8217;s important to note here that these are   just estimations and highly dependent on the actual page load times   encountered during the test. As page load times start to degrade, the   overall throughput the site in terms of page views also degrades. Adding   additional users at this point becomes overkill and will not result in   an increase in the number of total pages loaded. This is why sizing of   the load test is critical to make sure you have enough traffic at the   ready to validate your objectives for the site.</p>
<h3><strong>Test data</strong></h3>
<p>Another  aspect of load test planning that is often overlooked is the  creation  of appropriate test account data. This often takes the form of  creating  individual user ID&#8217;s to log in to the site or a list of  products to  select from, etc. Creation of a realistic and accurate data  set is  important to get the most out of the load testing process. Many  times,  errors encountered during the load test are the result of an  incomplete  or inaccurate test data creation process. Depending on the  scope of  testing, the data creation can be time consuming so it&#8217;s  important to  identify early on what data needs to be created and the  process of  creating it. Typically, data creation scripts will be needed  to create  the necessary data sets. Alternatively, custom user test  scripts can be  written as part of the load testing engagement to create  the necessary  data sets.</p>
<h3><strong>Server and Network Monitoring</strong></h3>
<p>Finally,  you want to make sure you have a plan and resources in place  to  monitor the network devices, web server, and application and  database  servers that support the application. Load testing will give  you all  the key front-end metrics, and to get the most out of your test  you&#8217;ll  want to cross correlate this information closely with the  performance  counters from all the devices in the application delivery  chain.</p>
<h3><strong>Wrap-up</strong></h3>
<p>I  hope this article has given you a good sense of the importance of  load  testing, as well as the key steps and questions to consider when   planning to run a load test on your website or application. Next up in   this series is “Configuration” – so be sure to check back to read more,   as this blog series will be taking you through the full load testing   process.  Also, please feel free to drop us a line at Marketing@webmetrics.com if you have questions or comments or suggestions for future posts.  Thanks!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.browsermob.com/2011/07/repost-in-the-drivers-seat-load-testing-best-practices-planning-2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk (enhanced)

Served from: blog.browsermob.com @ 2012-02-08 07:17:07 -->
