<?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>Technology and Leadership</title>
	<atom:link href="http://technologyandleadership.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://technologyandleadership.com</link>
	<description>The intersection of Technology and Leadership</description>
	<lastBuildDate>Sat, 20 Aug 2011 18:20:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Inheritance &#8211; the Ace of the Object Oriented Programming world</title>
		<link>http://technologyandleadership.com/inheritance-the-ace-of-the-object-oriented-programming-world/</link>
		<comments>http://technologyandleadership.com/inheritance-the-ace-of-the-object-oriented-programming-world/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 18:16:16 +0000</pubDate>
		<dc:creator>Aruna</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[base class]]></category>
		<category><![CDATA[break]]></category>
		<category><![CDATA[child class]]></category>
		<category><![CDATA[derived class]]></category>
		<category><![CDATA[extends]]></category>
		<category><![CDATA[inheritance]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[object oriented programming]]></category>
		<category><![CDATA[parent class]]></category>
		<category><![CDATA[Reusability]]></category>
		<category><![CDATA[reuse]]></category>
		<category><![CDATA[sub class]]></category>
		<category><![CDATA[super]]></category>
		<category><![CDATA[super class]]></category>
		<category><![CDATA[switch case]]></category>
		<category><![CDATA[system.out.format]]></category>

		<guid isPermaLink="false">http://technologyandleadership.com/?p=1026</guid>
		<description><![CDATA[The code is just a junkyard if it is not designed for reuse. Re-usability is very simple if you understand inheritance, a very powerful principle of object oriented programming. For this reason I call inheritance the Ace of the object-oriented programming world. Here, I explain inheritance with a simple illustration. From the figure below can [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">The code is just a junkyard if it is not designed for reuse. Re-usability is very simple if you understand <strong>inheritance</strong>, a very powerful principle of object oriented programming. For this reason I call inheritance the Ace of the object-oriented programming world.</p>
<p style="text-align: justify;">Here, I explain inheritance with a simple illustration. From the figure below can you list the properties that are common to all the balloons?</p>
<p><a href="http://technologyandleadership.com/wp-content/uploads/2011/08/balloons1.png"><img class="alignnone size-large wp-image-1029" title="balloons" src="http://technologyandleadership.com/wp-content/uploads/2011/08/balloons1-620x404.png" alt="" width="620" height="404" /></a></p>
<p>&nbsp;</p>
<p align="JUSTIFY"><span style="color: #000000;">The below properties are common to every balloon:</span></p>
<ol>
<li>Color</li>
<li>Size</li>
<li>Price and so on</li>
</ol>
<p style="text-align: justify;">These properties that are common to all classes of a given type say balloon is stored in a class called the <strong>base class or super class or parent class</strong>. <strong>Inheritance is a powerful object oriented programming feature that allows a class to reuse the properties and methods of an already existing class while adding its own functionality.</strong> It&#8217;s the process of creating a new class as an <strong>extension</strong> of an existing class primarily to enhance the code re-usability. The class that extends is called the <strong>derived / sub class</strong> and the class getting extended is called the <strong>super / base class</strong>.</p>
<p align="JUSTIFY"><strong> </strong>Suppose there is a super class called superBalloon. There are different kinds of balloons such as birthday balloons, balloons that represent a theme like sports or Disneyland and so on. For class inheritance java uses the keyword <strong>extends. </strong>Now let&#8217;s write a small java program for the base class &#8220;superBalloon&#8221;.</p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">balloonInherit</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> superBalloon
<span style="color: #009900;">&#123;</span>
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * The superBalloon class defines methods and variables common to all balloons such as
	 * size, color and price
	 */</span>
	<span style="color: #666666; font-style: italic;">//commonly used fields in all balloons</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> size<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> color<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">double</span> price<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> number_of_balloons_purchased<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">double</span> total_cost<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> purchase<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span> price, <span style="color: #000066; font-weight: bold;">int</span> number_of_balloons_purchased<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		total_cost <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>price <span style="color: #339933;">*</span> number_of_balloons_purchased<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: justify;"><strong>A derived class is more specific and can have additional functionality of its own apart from that of the base class.</strong> Thus a birthday balloon is a specialized version of the balloon class having a new field called decoration cost specific to it&#8217;s type to better suit the needs.</p>
<p style="text-align: justify;"><a href="http://technologyandleadership.com/wp-content/uploads/2011/08/bday.png"><img class="alignnone size-full wp-image-1048" title="bday" src="http://technologyandleadership.com/wp-content/uploads/2011/08/bday.png" alt="" width="467" height="570" /></a></p>
<p style="text-align: justify;">We can also <strong>override /replace</strong> the behavior of the base class in the derived class. Here, in the below example the birthday balloon inherits the superBalloon class and defines a new field called decoration cost specific to it&#8217;s kind. We use the <strong>super </strong>keyword to reuse the already existing properties of the base class.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">balloonInherit</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> subPartyBalloon <span style="color: #000000; font-weight: bold;">extends</span> superBalloon
<span style="color: #009900;">&#123;</span>
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * Since this is a partyBalloon, an additional new field called decoration cost is added
	 * which is specific to this kind of balloon
	 */</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//Create an object for subPartyBalloon class and invoke the purchase method</span>
                subPartyBalloon bDayBalloon <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> subPartyBalloon<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		bDayBalloon.<span style="color: #006633;">purchase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> purchase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//Additional property specific to the type partyBalloon</span>
		<span style="color: #000066; font-weight: bold;">double</span> decoration_cost <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2.00</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Reuse the existing properties of the base class using super keyword</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">size</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">number_of_balloons_purchased</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">color</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;red&quot;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//These are the prices of the balloon depending on it's size</span>
		<span style="color: #000000; font-weight: bold;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">:</span>
				<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">price</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5.00</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">:</span>
				<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">price</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10.00</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #cc66cc;">30</span><span style="color: #339933;">:</span>
				<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">price</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">15.00</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span>
				<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Invalid size&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Invoke the the purchase methods of the super class to calculate the base_cost</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">purchase</span><span style="color: #009900;">&#40;</span>price,number_of_balloons_purchased<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Since it is a birthday party balloon the additional cost for decoration is added</span>
		total_cost <span style="color: #339933;">=</span> total_cost <span style="color: #339933;">+</span> decoration_cost<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;The total cost of %d %s birthday balloons is %.2f&quot;</span>, number_of_balloons_purchased,color,total_cost<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: justify;"><span style="color: #000000;">The switch-case control structure decides the price of the balloon based on the input size. Once a matching size is found it assigns value to the price variable and breaks the execution of the switch-case block. The total cost of the birthday balloons is calculated and the output is as below.</span></p>
<p><strong><span style="color: #008000;">OUTPUT:</span></strong></p>
<p>The total cost of 3 red birthday balloons is 32.00</p>
<p style="text-align: justify;">Now let&#8217;s create a java program for another derived class called subThemeBalloon. A theme based balloon has theme and design as additional fields specific to it&#8217;s kind. For example to represent the theme of Disneyland, a balloon is designed with the theme Disneyland and with the shape Mickey mouse.</p>
<p><a href="http://technologyandleadership.com/wp-content/uploads/2011/08/themebasedBalloons3.png"><img class="alignnone size-large wp-image-1055" title="themebasedBalloons3" src="http://technologyandleadership.com/wp-content/uploads/2011/08/themebasedBalloons3-620x413.png" alt="" width="620" height="413" /></a></p>
<p style="text-align: justify;">The subThemeBalloon class reuses the existing properties of the base class superBalloon using the <strong>super</strong> keyword. It also has three additional new fields viz. theme, design and decoration cost specific to it&#8217;s kind to better suit the needs.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">balloonInherit</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> subThemeBalloon <span style="color: #000000; font-weight: bold;">extends</span> superBalloon
<span style="color: #009900;">&#123;</span>
	<span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * A theme based balloon has theme and design as additional fields. For example to represent
	 * the theme of Disneyland a balloon is designed with the theme Disneyland and with
	 * the shape mickey mouse
	 **/</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">//Create an object of subThemeBalloon class and invoke the purchase method</span>
                subThemeBalloon themeBalloon <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> subThemeBalloon<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		themeBalloon.<span style="color: #006633;">purchase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> purchase<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">//Declare three additional properties that are specific to the type themeBalloon</span>
		<span style="color: #003399;">String</span> theme <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Disneyland&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> design <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Mickey Mouse&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> decoration_cost <span style="color: #339933;">=</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Reuse the existing properties of the base class using super keyword</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">number_of_balloons_purchased</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">20</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">price</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">15.00</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Invoke the purchase method of the base balloon class to calculate base cost using super keyword</span>
		<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">purchase</span><span style="color: #009900;">&#40;</span>price, number_of_balloons_purchased<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Add the decoration cost for the balloon</span>
		total_cost <span style="color: #339933;">=</span> total_cost <span style="color: #339933;">+</span> decoration_cost<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//Print the total cost of the balloon</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;The total cost of a %s %s balloon is %.2f&quot;</span>, theme, design, total_cost<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong><span style="color: #008000;">OUTPUT:</span></strong></p>
<p>The total cost of a Disneyland Mickey Mouse balloon is 305.00<br />
<strong></strong></p>
<p>&nbsp;</p>
<p>This is all about inheritance. Feel free to post any comments /questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://technologyandleadership.com/inheritance-the-ace-of-the-object-oriented-programming-world/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>30-feet view of test automation framework with selenium</title>
		<link>http://technologyandleadership.com/30-feet-view-of-test-automation-framework-with-selenium/</link>
		<comments>http://technologyandleadership.com/30-feet-view-of-test-automation-framework-with-selenium/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 19:28:58 +0000</pubDate>
		<dc:creator>Aruna</dc:creator>
				<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Software Testing]]></category>
		<category><![CDATA[Test Automation Tools]]></category>
		<category><![CDATA[assertEquals]]></category>
		<category><![CDATA[assertTrue]]></category>
		<category><![CDATA[automate faster]]></category>
		<category><![CDATA[data driven testing]]></category>
		<category><![CDATA[DefaultSelenium]]></category>
		<category><![CDATA[higly maintainable test suite]]></category>
		<category><![CDATA[HttpCommandProcessor]]></category>
		<category><![CDATA[modular testing framework]]></category>
		<category><![CDATA[Modularization]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[selenium java client driver]]></category>
		<category><![CDATA[Selenium RC]]></category>
		<category><![CDATA[Selenium Remote Control]]></category>
		<category><![CDATA[selenium test automation]]></category>
		<category><![CDATA[Selenium.getTitle]]></category>
		<category><![CDATA[Selenium.isTextPresent]]></category>
		<category><![CDATA[selenium.open]]></category>
		<category><![CDATA[selenium.start]]></category>
		<category><![CDATA[selenium.waitForPageToLoad]]></category>
		<category><![CDATA[setup selenium test automation framework]]></category>
		<category><![CDATA[setup test environment for selenium]]></category>
		<category><![CDATA[start selenium server]]></category>
		<category><![CDATA[step-by-step]]></category>
		<category><![CDATA[step-by-step Selenium RC setup]]></category>
		<category><![CDATA[test automation]]></category>
		<category><![CDATA[test automation framework]]></category>
		<category><![CDATA[test data]]></category>
		<category><![CDATA[test execution]]></category>
		<category><![CDATA[test setup with selenium]]></category>
		<category><![CDATA[testing practices]]></category>
		<category><![CDATA[TestNG]]></category>
		<category><![CDATA[writing a selenium test case]]></category>

		<guid isPermaLink="false">http://technologyandleadership.com/?p=938</guid>
		<description><![CDATA[Is selenium the future of test automation? That leads us to yet another important question, what was the past of test automation? Well&#8230;,I was just kidding. There are numerous amazing test automation tools out there but none of them could takeover the field of test automation. Why? It&#8217;s because, when you take a closer look [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><span style="color: #000000;">Is selenium the future of test automation? That leads us to yet another important question, what was the past of test automation? Well&#8230;,I was just kidding. There are numerous amazing test automation tools out there but none of them could takeover the field of test automation. Why? <strong>It&#8217;s because, when you take a closer look at any testing project, the complexity increases so much that it takes a real tester with highly sophisticated testing practices and coding skills more than a mere tool to handle those situations. </strong>Yes, any tool no matter how good it is, cannot simply provide the foundation for a sound test automation framework. It is we, the “testers”, who can do it! But how?</span></p>
<p style="text-align: justify;"><span style="color: #000000;">This article shows step-by-step how selenium with a hybrid of other tools and practices could be used by the tester to develop a <em><strong>highly maintainable, robust, sophisticated and sound test automation framework.</strong></em></span></p>
<p style="text-align: justify;"><span style="color: #000000;"><em><strong><a href="http://technologyandleadership.com/wp-content/uploads/2011/07/30feetview.png"><img class="alignnone size-full wp-image-941" title="30feetview" src="http://technologyandleadership.com/wp-content/uploads/2011/07/30feetview.png" alt="" width="660" height="456" /></a></strong></em></span></p>
<p>&nbsp;</p>
<p><span style="color: #000000;">This article gives a 30-feet overview of how a test automation framework with selenium looks like.</span></p>
<p>&nbsp;</p>
<h2><span style="color: #800000;"><strong>The little secrets of test automation:</strong></span></h2>
<p style="text-align: justify;"><span style="color: #000000;"><strong>Would you be interested to know how I can automate tests in just six weeks while others usually take over six months? I automate far faster and much cheaper than anyone else can do!</strong> Come on, my little secrets are so little.</span></p>
<p style="text-align: justify;"><span style="color: #000000;">Often in a testing project we tend to handle things in our own way that we see fit. The delicate test automation framework gets upset due to these gimmicks. Let me introduce you to the few main things that really counts during test automation:</span></p>
<ol>
<li style="text-align: justify;"><span style="color: #000000;">Customer focus</span></li>
<li style="text-align: justify;"><span style="color: #000000;">Easy-to-understand test case listing the user actions</span></li>
<li style="text-align: justify;"><span style="color: #000000;">Decoupling of test data from test execution</span></li>
<li style="text-align: justify;"><span style="color: #000000;">Intelligent exception handling</span></li>
<li style="text-align: justify;"><span style="color: #000000;">Data-driven testing framework</span></li>
<li style="text-align: justify;"><span style="color: #000000;">Modular testing framework </span></li>
<li>
<p style="text-align: justify;"><span style="color: #000000;">Separation of test verification from test script</span></p>
</li>
</ol>
<p><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --><span style="color: #000000;">Even if you are new to automation you can easily get a hang of it as you follow the steps outlined. Let me illustrate these principles with a simple demo. </span></p>
<p><strong>Pre-requisites: </strong></p>
<p>To execute the practical demonstration in this article we require the installation of <strong>JDK, Selenium Server, Selenium client driver for java, ant, TestNG, eclipse and TestNG plugin for eclipse.</strong></p>
<p><span style="color: #000000;">For installation/setting up of Selenium, please refer the article “</span><a href="http://technologyandleadership.com/selenium-rc-configuration-for-java-%E2%80%93-all-in-a-nutshell/" target="_blank">Selenium RC configuration for java – all in a nutshell</a><span style="color: #000000;">”. </span></p>
<p>In this demo I am using Ubuntu as platform. You could use your favorite platform for coding. So, let us walkthrough the steps for developing a robust and highly maintainable test automation framework with selenium.</p>
<p>&nbsp;</p>
<h2 style="text-align: justify;"><span style="color: #800000;"><strong>Step 1: Create java project and add references to external jars:</strong></span></h2>
<p style="text-align: justify;"><span style="color: #000000;">Suppose we want to dress perfectly for the weather with a rain hat, a rain coat and an umbrella. Now let&#8217;s develop a selenium test automation framework to test a very simple application that I have created called <strong>Weather Monster </strong>- “<a href="http://weathermonster.heroku.com/microposts">http://weathermonster.heroku.com/</a>”.</span></p>
<ol>
<li style="text-align: justify;"><span style="color: #000000;">Open eclipse → Create a new java project called <strong>weatherMonster</strong></span></li>
<li style="text-align: justify;"><span style="color: #000000;">Click on Next button → click on the Libraries tab</span></li>
<li style="text-align: justify;"><span style="color: #000000;">Click on <strong>Add External JARs</strong> button and add the respective jar files for selenium server, selenium java client driver and TestNG as shown in the diagram below → Click Finish</span></li>
</ol>
<p><a href="http://technologyandleadership.com/wp-content/uploads/2011/07/addreferences.png"><img class="alignnone size-full wp-image-951" title="addreferences" src="http://technologyandleadership.com/wp-content/uploads/2011/07/addreferences.png" alt="" width="614" height="326" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2><span style="color: #800000;"><strong>Step 2: Automatic configuration of test environment</strong></span></h2>
<p style="text-align: justify;"><span style="color: #000000;"><strong>A configuration script contains the key value pair needed to setup the test environment. </strong>These values could be changed dynamically using a shell script.</span></p>
<p style="text-align: justify;"><span style="color: #000000;">Let&#8217;s create a shell script to dynamically start the selenium server.</span></p>
<p style="text-align: justify;"><span style="color: #000000;">Create a new folder called “config” in the weatherMonster project and place the below shell script named<strong> config.sh</strong> in it.</span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Documents<span style="color: #000000; font-weight: bold;">/</span>working<span style="color: #000000; font-weight: bold;">/</span>installable<span style="color: #000000; font-weight: bold;">/</span>selenium<span style="color: #000000; font-weight: bold;">/</span>jar\ files<span style="color: #000000; font-weight: bold;">/</span>
gnome-terminal <span style="color: #660033;">--title</span>=<span style="color: #ff0000;">&quot;config&quot;</span> <span style="color: #660033;">-x</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;java -jar selenium-server-standalone-2.0rc2.jar&quot;</span></pre></div></div>

<p style="text-align: justify;">This shell script navigates to the folder path containing the selenium server jar file (Replace this path with respective path on your machine). It then opens a new GNOME-TERMINAL named config and runs the selenium server by execution of the command “java -jar selenium-server-standalone-2.0rc2.jar”</p>
<p style="text-align: justify;">To grant execution privileges to the script use chmod command as below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">777</span> config.sh</pre></div></div>

<p style="text-align: justify;">Then run the script using the below command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>config.sh</pre></div></div>

<p style="text-align: justify;"><strong>We need to run this script each time before test suite execution to start the selenium server.</strong></p>
<p style="text-align: justify;">Right click the src folder and create a package named config. Right click the config package and create a java class called seleniumTest.java</p>
<p style="text-align: justify;">Let&#8217;s assign values to the <strong>environment variables</strong> such as host, port, browser and so on.<br />
Since we <strong>do not want to hard code the test data</strong> and we would like to <strong>decouple test data from test execution</strong> let&#8217;s assign the test data to the variables separately in the config folder and organize them as shown below:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">config</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.thoughtworks.selenium.DefaultSelenium</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.thoughtworks.selenium.HttpCommandProcessor</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> seleniumTest
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">/*Environment variables*/</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> HOST <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">int</span> PORT <span style="color: #339933;">=</span> <span style="color: #cc66cc;">4444</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> BROWSER <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;firefox&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> BASE_URL <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;http://weathermonster.heroku.com&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//To set the baseURL and server port</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> HttpCommandProcessor PROC <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpCommandProcessor<span style="color: #009900;">&#40;</span>HOST,PORT, BROWSER, BASE_URL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//To create a selenium object for passing as variable</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> DefaultSelenium Selenium <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultSelenium<span style="color: #009900;">&#40;</span>PROC<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*Timeout*/</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> TIMEOUT<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;60000&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">/*Weather Monster home page*/</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> HOME_MSG <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is weathermonster, bringing you the weather&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> HOME_PAGETITLE <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Weather Monster&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>&nbsp;</p>
<h2><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --><span style="color: #800000;"><strong>Step 3: Modularization of commonly used methods</strong></span></h2>
<p style="text-align: justify;"><span style="color: #000000;">A module is a <strong>small independent script</strong> that represents AUT(Application Under Test). The most commonly used methods in the test case should be created as modules in separate folders that can be called and reused by many test cases. This increases the maintainability of the test suite. If there is a change, it needs to be applied only in one single place as opposed to all the places thus saving lots of time and cost.</span></p>
<p style="text-align: justify;"><span style="color: #000000;">Modularization also makes the test case <strong>easy-to-read and understand</strong>.</span></p>
<p style="text-align: justify;"><span style="color: #000000;">Consider the below test automation code. Can you understand it? It is a <strong>technical stack containing all the configuration details which is very hard to understand.</strong></span></p>
<p style="text-align: justify;"><span style="color: #000000;"><strong><a href="http://technologyandleadership.com/wp-content/uploads/2011/07/bad.png"><img class="alignnone size-full wp-image-961" title="bad" src="http://technologyandleadership.com/wp-content/uploads/2011/07/bad.png" alt="" width="649" height="127" /></a></strong></span></p>
<p>&nbsp;</p>
<p style="text-align: justify;"><span style="color: #000000;"><strong>The test case should list the user actions not the technical details. This makes the test case customer-focused and easy-to-read. </strong>Now, let&#8217;s move out all the technical stack from the test case to a separate module.</span></p>
<p style="text-align: justify;"><span style="color: #000000;">Right click the src folder and create a package named module. Right click the module package and create a java class called testInit.java.</span></p>
<p style="text-align: justify;"><span style="color: #000000;">Here we code all the technical details of starting selenium server for test initialization so that the actual test case is freed from these unnecessary details and can cover the main area to test.</span></p>
<p style="text-align: justify;"><span style="color: #000000;"><br />
</span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">module</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.thoughtworks.selenium.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">config.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> testInit <span style="color: #000000; font-weight: bold;">extends</span> SeleneseTestBase
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//Declare a new selenium test</span>
	seleniumTest test <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> seleniumTest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	@Test
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testSetup<span style="color: #009900;">&#40;</span>DefaultSelenium selenium<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//Open, maximize and focus on the facebook page. Delete all cookies</span>
			selenium.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			selenium.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			selenium.<span style="color: #006633;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span>test.<span style="color: #006633;">TIMEOUT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Handles timeout exception</span>
			selenium.<span style="color: #006633;">windowMaximize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			selenium.<span style="color: #006633;">windowFocus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			selenium.<span style="color: #006633;">deleteAllVisibleCookies</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Clear all session cookies before testing</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			 e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --><br />
<span style="color: #800000;"><strong>Step 4: Writing a selenium test case</strong></span></h2>
<p style="text-align: justify;"><span style="color: #000000;">Now that we already have modules for test setup and initialization, the writing of a selenium test case doesn&#8217;t take much effort. All we need to do is just call these modules and reuse them in our test case. <strong>This allows us to focus more on the customer.</strong></span></p>
<p style="text-align: justify;"><span style="color: #000000;">A good automation script should contain the actual code logic to perform and validate a business scenario.</span></p>
<p style="text-align: justify;"><span style="color: #000000;">Right click the src folder and create a package named testSuite. Right click the testSuite package and create a java class called weatherMonsterHome.java</span></p>
<p style="text-align: justify;"><span style="color: #000000;"><br />
</span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">testSuite</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/* Test case for weather monster home page*/</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">module.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">config.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.thoughtworks.selenium.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> weatherMonsterHome <span style="color: #000000; font-weight: bold;">extends</span> SeleneseTestBase
<span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//Declare a new selenium test</span>
	seleniumTest test <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> seleniumTest<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	testInit setUp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> testInit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	@Test
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testWeatherMonster<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">/*Test the home page of Weather Monster
			 * Pass the expected message and page title of the home page as parameters
			 */</span>
			setUp.<span style="color: #006633;">testSetup</span><span style="color: #009900;">&#40;</span>test.<span style="color: #006633;">Selenium</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			weatherMonster<span style="color: #009900;">&#40;</span>test.<span style="color: #006633;">Selenium</span>, test.<span style="color: #006633;">HOME_MSG</span>,test.<span style="color: #006633;">HOME_PAGETITLE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> weatherMonster<span style="color: #009900;">&#40;</span>DefaultSelenium Selenium, <span style="color: #003399;">String</span> strHomeMsg, <span style="color: #003399;">String</span> strExpectedHomePageTitle<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">/*Verification of Weather Monster home page*/</span>
			assertTrue<span style="color: #009900;">&#40;</span>Selenium.<span style="color: #006633;">isTextPresent</span><span style="color: #009900;">&#40;</span>strHomeMsg<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Message on the Weather Monster home page is displayed successfully&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			assertEquals<span style="color: #009900;">&#40;</span>Selenium.<span style="color: #006633;">getTitle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,strExpectedHomePageTitle<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Title of Weather Monster home page is correct&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: justify;"><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --><br />
<span style="color: #000000;">This decoupling of test script from all the test execution details has made the test case <em><strong>a very easy-to-read list of user actions.</strong></em></span></p>
<p style="text-align: justify;"><span style="color: #000000;">Ultimately the test structure is as below:</span></p>
<p style="text-align: justify;"><span style="color: #000000;"><a href="http://technologyandleadership.com/wp-content/uploads/2011/07/teststructure.png"><img class="alignnone size-full wp-image-968" title="teststructure" src="http://technologyandleadership.com/wp-content/uploads/2011/07/teststructure.png" alt="" width="311" height="356" /></a></span></p>
<h2><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --><span style="color: #800000;"><strong>Step 5: Run the test case</strong></span></h2>
<ol>
<li style="text-align: justify;"><span style="color: #000000;">Navigate to the config folder and give the below command to start selenium server:</span><span style="color: #000000;"><span style="color: #000000;"><br />
</span></span></li>
</ol>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>config.sh</pre></div></div>

<ul>
<li style="text-align: justify;"><span style="color: #000000;">Right click on weatherMonsterHome.java and select “Run as TestNG test”.</span></li>
</ul>
<p>&nbsp;</p>
<p><strong><span style="color: #008000;">OUTPUT:</span></strong></p>
<p><span style="color: #000000;"><span style="font-family: Monospace;"><span style="font-size: x-small;">RemoteTestNG starting</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monospace;"><span style="font-size: x-small;">Message on the Weather Monster home page is displayed successfully</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monospace;"><span style="font-size: x-small;">Title of Weather Monster home page is correct</span></span></span></p>
<p><span style="color: #000000;"><span style="font-family: Monospace;"><span style="font-size: x-small;">PASSED: testWeatherMonster</span></span></span></p>
<p>&nbsp;</p>
<p style="text-align: justify;"><!-- 		@page { margin: 0.79in } 		P { margin-bottom: 0.08in } --><span style="color: #000000;">We have missed out on a few little secrets of test automation like intelligent exception handling and data-driven testing. We shall get introduced to them in our next article, so stay tuned!</span></p>
<p><span style="color: #000000;">Feel free to ask any question or post comments.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://technologyandleadership.com/30-feet-view-of-test-automation-framework-with-selenium/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Selenium RC configuration for java – all in a nutshell</title>
		<link>http://technologyandleadership.com/selenium-rc-configuration-for-java-%e2%80%93-all-in-a-nutshell/</link>
		<comments>http://technologyandleadership.com/selenium-rc-configuration-for-java-%e2%80%93-all-in-a-nutshell/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 02:02:41 +0000</pubDate>
		<dc:creator>Aruna</dc:creator>
				<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Software Testing]]></category>
		<category><![CDATA[Test Automation Tools]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[Building TestNG with ant]]></category>
		<category><![CDATA[cobertura-1.9.4.1]]></category>
		<category><![CDATA[configuration of selenium RC for java]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[export PATH]]></category>
		<category><![CDATA[installation of ant]]></category>
		<category><![CDATA[installation of eclipse]]></category>
		<category><![CDATA[Installation of java]]></category>
		<category><![CDATA[installation of selenium RC for java]]></category>
		<category><![CDATA[installation of selenium RC with java client driver]]></category>
		<category><![CDATA[Installation of TestNG]]></category>
		<category><![CDATA[JDK]]></category>
		<category><![CDATA[Selenium client driver]]></category>
		<category><![CDATA[selenium client driver for java]]></category>
		<category><![CDATA[Selenium RC]]></category>
		<category><![CDATA[Selenium RC for java]]></category>
		<category><![CDATA[Selenium Remote Control]]></category>
		<category><![CDATA[Selenium Server]]></category>
		<category><![CDATA[selenium server jar]]></category>
		<category><![CDATA[selenium-java-client-driver.jar download]]></category>
		<category><![CDATA[setting class path for java]]></category>
		<category><![CDATA[TestNG]]></category>
		<category><![CDATA[TestNG plugin for Eclipse]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[which java]]></category>

		<guid isPermaLink="false">http://technologyandleadership.com/?p=866</guid>
		<description><![CDATA[What do we need to get started with selenium RC? Configuration of Selenium RC test automation framework with Java client driver is not that simple as it requires the installation of so many packages and it takes a die-hard effort to get all the required information on getting started at one place. It&#8217;s sometimes boring [...]]]></description>
			<content:encoded><![CDATA[<h2><span style="color: #800000;">What do we need to get started with selenium RC?</span></h2>
<p style="text-align: justify;">Configuration of Selenium RC test automation framework with Java client driver is not that simple as it requires the installation of so many packages and it takes a die-hard effort to get all the required information on getting started at one place. It&#8217;s sometimes boring and you might ask yourself &#8220;<em>Is this the only way to get started?</em>&#8220;. This article is not a shortcut but still presents all in a nutshell on how to get started with selenium RC. The below nutshell picture portrays all the software packages needed to set up Selenium RC for java. So now lets get started on the long road of setting up our test automation framework using selenium RC and java.</p>
<p style="text-align: justify;"><a href="http://technologyandleadership.com/wp-content/uploads/2011/06/nutshell.png"><img class="alignnone size-full wp-image-867" title="nutshell" src="http://technologyandleadership.com/wp-content/uploads/2011/06/nutshell.png" alt="" width="585" height="431" /></a></p>
<p style="text-align: justify;">Below are the step-by-step instructions for the installation and configuration of Selenium RC for java client driver on ubuntu platform. To start selenium server we need JAVA. So, let&#8217;s start with the installation of java.</p>
<h2 style="text-align: justify;"><span style="color: #800000;">Installation of java and setting class path:</span></h2>
<p style="text-align: justify;">Download Java JDK from the below path: <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html" target="_blank">http://www.oracle.com/technetwork/java/javase/downloads/index.html</a></p>
<p>To find the exact path where java is installed give the below command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">which</span> java</pre></div></div>

<p>OUTPUT: /usr/bin/java  Then set the path for JDK using the below commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>java
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">JAVA_HOME</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>java</pre></div></div>

<p>To check whether java path is set properly give the below command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">java <span style="color: #660033;">-version</span></pre></div></div>

<p>It should display the version of the Java installed.</p>
<h2><span style="color: #800000;">Installation of selenium RC with java client driver:</span></h2>
<p><span style="color: #000000;"><strong>Selenium Server:</strong> This is required to run the Selenium RC style scripts. </span> Download and extract the selenium server jar file from: <a href="http://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.0rc2.jar&amp;can=2&amp;q=" target="_blank">http://code.google.com/p/selenium/downloads/detail?name=selenium-server-standalone-2.0rc2.jar&amp;can=2&amp;q=</a> <strong></strong></p>
<p><strong>Selenium Client Driver for java:</strong> To create scripts that interact with the Selenium Server we need the selenium client driver. There are language-specific client drivers for ruby,c# and so on. Let us install the selenium client driver for java.  Download the client-driver for the programming language java: <a href="http://seleniumhq.org/download/" target="_blank">http://seleniumhq.org/download/</a></p>
<h2><span style="color: #800000;">Installation of ant:</span></h2>
<p>Install ant on ubuntu using the below command</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> ant ant-optional</pre></div></div>

<p>To find where ant has been installed give the below command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">which</span> ant</pre></div></div>

<p>Set the path of ant using the PATH variable as below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>ant</pre></div></div>

<h2><span style="color: #800000;">Installation of </span><span style="color: #800000;">Eclipse:</span></h2>
<p><span style="color: #000000;">Install eclipse in ubuntu using the below command: </span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> eclipse</pre></div></div>

<h2><span style="color: #800000;">TestNG plugin for eclipse:</span></h2>
<p>1. Open eclipse. 2. Click Help → Install New Software.. 3. Then click on Available Software Sites link  <a href="http://technologyandleadership.com/wp-content/uploads/2011/06/find_software.png"><img class="alignnone size-full wp-image-893" title="find_software" src="http://technologyandleadership.com/wp-content/uploads/2011/06/find_software.png" alt="" width="742" height="669" /></a> 4. Click on the Add button. Enter the site url as http://beust.com/eclipse to add TestNG plugin to eclipse.  <a href="http://technologyandleadership.com/wp-content/uploads/2011/06/addsite1.png"><img class="alignnone size-full wp-image-895" title="addsite" src="http://technologyandleadership.com/wp-content/uploads/2011/06/addsite1.png" alt="" width="956" height="558" /></a> Now the TestNG plugin for eclipse is added as below:  <a href="http://technologyandleadership.com/wp-content/uploads/2011/06/TestNG1.png"><img class="alignnone size-full wp-image-903" title="TestNG" src="http://technologyandleadership.com/wp-content/uploads/2011/06/TestNG1.png" alt="" width="956" height="555" /></a></p>
<h2><span style="color: #800000;">Installation and configuration of TestNG on ubuntu:</span></h2>
<p>The below command installs TestNG on ubuntu:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>cbeust<span style="color: #000000; font-weight: bold;">/</span>testng.git</pre></div></div>

<p><strong>Building TestNG with ant:</strong> Download cobertura-1.9.4.1-bin.zip from the below site into the home directory <a href="http://cobertura.sourceforge.net/download.html">http://cobertura.sourceforge.net/download.html</a> unzip using the below command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">unzip</span> cobertura-1.9.4.1-bin.zip</pre></div></div>

<p>Now navigate to the testng directory. Copy  ivy-2.1.0.jar into /ant/lib directory as shown below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> ivy-2.1.0.jar <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>ant<span style="color: #000000; font-weight: bold;">/</span>lib</pre></div></div>

<p>Now give ant command in the testng directory:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ant</pre></div></div>

<p>The OUTPUT should be <span style="color: #008000;">BUILD SUCCESSFUL.</span></p>
<p><span style="color: #008000;"><br />
</span><span style="color: #000000;">Now we have installed all that we need to get started with Selenium RC using the client driver for java. In the next article, we will create a test suite using this setup.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://technologyandleadership.com/selenium-rc-configuration-for-java-%e2%80%93-all-in-a-nutshell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Six steps for complete test automation with selenium grid</title>
		<link>http://technologyandleadership.com/six-steps-for-complete-test-automation-with-selenium-grid/</link>
		<comments>http://technologyandleadership.com/six-steps-for-complete-test-automation-with-selenium-grid/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 06:23:51 +0000</pubDate>
		<dc:creator>Aruna</dc:creator>
				<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Software Testing]]></category>
		<category><![CDATA[Test Automation Tools]]></category>
		<category><![CDATA[ant launch-hub]]></category>
		<category><![CDATA[ant launch-remote-control]]></category>
		<category><![CDATA[ant sanity-check]]></category>
		<category><![CDATA[browser compatibility testing]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[selenium grid]]></category>
		<category><![CDATA[Selenium Hub]]></category>
		<category><![CDATA[Selenium RC]]></category>
		<category><![CDATA[Selenium Remote Control]]></category>
		<category><![CDATA[selenium.browser]]></category>
		<category><![CDATA[selenium.host]]></category>
		<category><![CDATA[selenium.port]]></category>
		<category><![CDATA[test automation]]></category>
		<category><![CDATA[TestNG]]></category>
		<category><![CDATA[TestNG.xml]]></category>

		<guid isPermaLink="false">http://technologyandleadership.com/?p=818</guid>
		<description><![CDATA[&#160; The earlier article “Crucial aspects of browser compatibilty testing with Selenium Grid” gives insight into browser compatibility testing andthe architecture of one of the most popular browser compatibility testing tools, selenium grid. Nowlet&#8216;sget our hands dirty with test automation using Selenium Grid. &#160; Pre-requisites: The practice exercise in this article requires Eclipse, TestNG, ant, [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p style="text-align: justify;"><span style="font-family: Arial,sans-serif;">The earlier article <a href="http://technologyandleadership.com/crucial-aspects-of-browser-compatibilty-testing-with-selenium-grid/">“Crucial aspects of browser compatibilty testing with Selenium Grid”</a> </span><span style="font-family: Arial,sans-serif;">gives insight </span><span style="font-family: Arial,sans-serif;">into</span><span style="font-family: Arial,sans-serif;"> browser compatibility testing and</span><span style="font-family: Arial,sans-serif;">the architecture of one of the most popular browser compatibility testing tool</span><span style="font-family: Arial,sans-serif;">s</span><span style="font-family: Arial,sans-serif;">, </span><span style="font-family: Arial,sans-serif;">selenium grid. </span><span style="font-family: Arial,sans-serif;">Now</span><span style="font-family: Arial,sans-serif;">let</span><span style="font-family: Arial,sans-serif;">&#8216;s</span><span style="font-family: Arial,sans-serif;">get our hands dirty with </span><span style="font-family: Arial,sans-serif;">test automation using </span><span style="font-family: Arial,sans-serif;">Seleniu</span><span style="font-family: Arial,sans-serif;">m Grid.</span></p>
<p>&nbsp;</p>
<p style="text-align: justify;"><span style="font-family: Arial,sans-serif;"><strong>Pre-requisites:</strong></span></p>
<p style="text-align: justify;"><span style="font-family: Arial,sans-serif;">The practice exercise in this article requires <strong>Eclipse, TestNG, ant, Java, Selenium RC </strong><strong>and Selenium Grid.</strong> You can execute the code on your favorite platform. For this demo I am using ubuntu as platform.</span></p>
<p style="text-align: justify;"><span style="font-family: Arial,sans-serif;"><br />
</span></p>
<p><!-- p { margin-bottom: 0.08in; }a:link {  } --><span style="font-family: Arial,sans-serif;"><strong>Installation of Selenium Grid:</strong></span></p>
<p><span style="font-family: Arial,sans-serif;">Please refer the documentation in seleniumhq for selenium grid download and installation instructions</span></p>
<p><span style="font-family: Arial,sans-serif; color: #0000ff;"><a href="http://selenium-grid.seleniumhq.org/step_by_step_installation_instructions_for_windows.html">http://selenium-grid.seleniumhq.org/step_by_step_installation_instructions_for_windows.html</a> </span><br />
<span style="font-family: Arial,sans-serif; color: #0000ff;"> <a href="http://selenium-grid.seleniumhq.org/get_started.html">http://selenium-grid.seleniumhq.org/get_started.html</a> </span></p>
<p><span style="font-family: Arial,sans-serif;">Unzip the Selenium Grid folder and execute the below command in the Selenium Grid root directory to check whether it is installed correctly or not:</span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ant sanity-check</pre></div></div>

<p><span style="font-family: Arial,sans-serif;">The output should be <span style="color: #579d1c;"><strong>BUILD SUCCESSFUL</strong></span></span></p>
<p><!-- p { margin-bottom: 0.08in; } --><span style="font-family: Arial,sans-serif;">Now let&#8217;s get started. </span></p>
<p><span style="font-family: Arial,sans-serif;"><br />
</span></p>
<p>&nbsp;</p>
<h2><span style="font-family: Arial,sans-serif; color: #800000;"><strong>Step 1. Launch of selenium hub:</strong></span></h2>
<p><!-- p { margin-bottom: 0.08in; } --><span style="font-family: Arial,sans-serif;">Open a terminal and launch the selenium hub using the below command:</span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ant launch-hub</pre></div></div>

<p style="text-align: justify;">The hub is where the selenium remote controls providing the different environments like chrome on ubuntu or IE on Windows register themselves. We can view the list of remote controls registered with the hub at <span style="color: #0000ff;">http://localhost:4444/console</span></p>
<p style="text-align: justify;">Now the available remote controls section in the hub console displays nothing  since we did not start any remote control yet.</p>
<p>&nbsp;</p>
<h2><span style="font-family: Arial,sans-serif; color: #800000;"><strong>Step 2. Launch of selenium remote controls: </strong></span></h2>
<p><!-- p { margin-bottom: 0.08in; } --><span style="font-family: Arial,sans-serif;">To start a remote control open a new terminal and issue the below command:</span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ant launch-remote-control</pre></div></div>

<p style="text-align: justify;">Then, open the hub console <span style="color: #0000ff;">http://localhost:4444/console</span> . The selenium grid hub snapshot displays a remote control on port 5555 for firefox. This is the default environment if we do not specify our own.</p>
<p style="text-align: justify;">We can configure more than one selenium remote control with the same port but more than one remote control cannot run tests on the same port. The reason behind this is simple. For example, more than one person can call the same phone number but cannot talk over the phone to the same person at the same time. Only one call can be answered on a single phone at a time. Similarly it is impossible to run tests in parallel on two selenium remote controls configured with the same port number. We need to configure each remote control with unique port numbers. How do we do this?</p>
<p style="text-align: justify;">If we want to specify our own environment we need to use the Dport and Denvironment options as below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ant <span style="color: #660033;">-Dport</span>=<span style="color: #000000;">5556</span> <span style="color: #660033;">-Denvironment</span>=<span style="color: #000000; font-weight: bold;">*</span>chrome launch-remote-control</pre></div></div>

<p>&nbsp;</p>
<h2><span style="font-family: Arial,sans-serif; color: #800000;"><strong>Step 3. Automatic environment setup:</strong><br />
</span></h2>
<p style="text-align: justify;">Let&#8217;s create a bash script for automatically opening up new terminals and launching several remote controls with the desired environment. If you are working on windows you need to create a batch file instead of a bash script. The below script works only on ubuntu platform.</p>
<p style="text-align: justify;">Navigate to the selenium grid directory and create the below bash script. Let&#8217;s call it<strong> run.sh</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
gnome-terminal <span style="color: #660033;">--title</span>=<span style="color: #ff0000;">&quot;Hub&quot;</span> <span style="color: #660033;">-x</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;ant launch-hub&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">150</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;10 seconds wait over&quot;</span>
gnome-terminal <span style="color: #660033;">--tab</span> <span style="color: #660033;">--title</span>=<span style="color: #ff0000;">&quot;Chrome&quot;</span> <span style="color: #660033;">-x</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;ant -Dport=5555 -Denvironment=*chrome launch-remote-control&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;
gnome-terminal <span style="color: #660033;">--tab</span> <span style="color: #660033;">--title</span>=<span style="color: #ff0000;">&quot;Firefox&quot;</span> <span style="color: #660033;">-x</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;ant -Dport=5556 -Denvironment=*firefox launch-remote-control&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>amp;
gnome-terminal <span style="color: #660033;">--tab</span> <span style="color: #660033;">--title</span>=<span style="color: #ff0000;">&quot;Opera&quot;</span> <span style="color: #660033;">-x</span> <span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;ant -Dport=5557 -Denvironment=*opera launch-remote-control&quot;</span></pre></div></div>

<p style="text-align: justify;">The bash script opens a new gnome terminal called “Hub” and launches the selenium hub. It sleeps for 150 seconds waiting for the hub to get started. Depending on the time taken you can change the sleep period. The script then opens three other new terminals and registers three remote controls with the respective environments specified. On execution of the script the below output is got on <span style="color: #0000ff;">http://localhost:4444/console</span> page.</p>
<p><a href="http://technologyandleadership.com/wp-content/uploads/2011/06/gridsnap.png"><img class="alignnone size-full wp-image-855" title="gridsnap" src="http://technologyandleadership.com/wp-content/uploads/2011/06/gridsnap.png" alt="" width="438" height="195" /></a></p>
<p><!-- p { margin-bottom: 0.08in; } --><span style="font-family: Arial,sans-serif;">Now the environment is setup for selenium grid automation. Let&#8217;s write a simple selenium grid program.</span></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2><span style="font-family: Arial,sans-serif; color: #800000;"><strong>Step 4. Creating a java project called giftShop:</strong></span></h2>
<p>&nbsp;</p>
<p style="text-align: justify;"><span style="font-family: Arial,sans-serif;">Suppose you would like to cheer up your friend on her birthday and give her the best birthday party of all time. You are planning  to celebrate your friend&#8217;s birthday with balloons, cakes, ice creams and of course a birthday gift!. You are going to surprise your friend with &#8220;I have got something for you&#8221; from www.gifts.com in such a way that no one can ever put a price tag on the friendship. Let&#8217;s write a selenium program to test the display of birthday gifts page on www.gifts.com website on multiple browsers.</span></p>
<p style="text-align: justify;"><span style="font-family: Arial,sans-serif;"><a href="http://technologyandleadership.com/wp-content/uploads/2011/06/bday.png"><img class="alignnone size-full wp-image-846" title="bday" src="http://technologyandleadership.com/wp-content/uploads/2011/06/bday.png" alt="" width="577" height="436" /></a></span></p>
<p>&nbsp;</p>
<ol>
<li><span style="font-family: Arial,sans-serif;">In Eclipse create a new java project called “giftShop”. Click on Next button and click on the “Libraries” tab. Click on <strong>“Add External JARs”</strong> button. Select the testng and selenium server JAR files as below and click on finish button.</span></li>
</ol>
<p><a href="http://technologyandleadership.com/wp-content/uploads/2011/06/jar.png"><img class="alignnone size-full wp-image-849" title="jar" src="http://technologyandleadership.com/wp-content/uploads/2011/06/jar.png" alt="" width="694" height="503" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><span style="font-family: Arial,sans-serif;">2. </span><span style="font-family: Arial,sans-serif;">Now create a new TestNG class </span><span style="font-family: Arial,sans-serif;">inside the giftShop project</span><span style="font-family: Arial,sans-serif;">. In the source folder field, browse to /giftShop/src. Give the package name as giftShop and class name as giftBox. </span><span style="font-family: Arial,sans-serif;">Click on finish button.</span><span style="font-family: Arial,sans-serif;"><br />
</span></p>
<h2><span style="font-family: Arial,sans-serif; color: #800000;"><strong>Step 5. Enable testing in parallel mode in multiple browsers:</strong></span></h2>
<p><!-- p { margin-bottom: 0.08in; } --><br />
<span style="font-family: Arial,sans-serif;">Right click on </span><span style="font-family: Arial,sans-serif;">the </span><span style="font-family: Arial,sans-serif;">giftShop project. Click on “Convert into TestNG” option. </span><span style="font-family: Arial,sans-serif;"><strong>“Generate testng.xml” </strong>window will get displayed. </span><span style="font-family: Arial,sans-serif;">This option will be available only if the TestNG plugin for eclipse is installed. </span><strong><span style="font-family: Arial,sans-serif;">Select “tests” in parallel mode dropdown and click </span><span style="font-family: Arial,sans-serif;">on </span><span style="font-family: Arial,sans-serif;">Finish butto</span><span style="font-family: Arial,sans-serif;">n. </span></strong></p>
<p><a href="http://technologyandleadership.com/wp-content/uploads/2011/06/testng_xml.png"><img class="alignnone size-full wp-image-850" title="testng_xml" src="http://technologyandleadership.com/wp-content/uploads/2011/06/testng_xml.png" alt="" width="766" height="673" /></a></p>
<p>&nbsp;</p>
<p><!-- p { margin-bottom: 0.08in; } --><span style="font-family: Arial,sans-serif;">To organize the project structure create a folder called <strong>config</strong> and place the generated testng.xml file in it.</span></p>
<p><span style="font-family: Arial,sans-serif;">In the testng.xml file we just created, specify the browser and port names with which we have configured our selenium remote control as in the below piece of code.</span></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE suite SYSTEM &quot;http://testng.org/testng-1.0.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;suite</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Suite&quot;</span> <span style="color: #000066;">parallel</span>=<span style="color: #ff0000;">&quot;tests&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;test</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Chrome&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.host&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;localhost&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.port&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;5555&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.browser&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;*chrome&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.url&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;http://www.gifts.com/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;bdayLink&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;//li[@id='nav-oc']/div/ul[3]/li[3]/a/b&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;classes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;class</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;giftShop.giftBox&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/classes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/test<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;test</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Firefox&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.host&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;localhost&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.port&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;5556&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.browser&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;*firefox&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.url&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;http://www.gifts.com/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;bdayLink&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;//li[@id='nav-oc']/div/ul[3]/li[3]/a/b&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;classes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;class</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;giftShop.giftBox&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/classes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/test<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;test</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Opera&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.host&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;localhost&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.port&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;5557&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.browser&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;*opera&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selenium.url&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;http://www.gifts.com/&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;parameter</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;bdayLink&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;//li[@id='nav-oc']/div/ul[3]/li[3]/a/b&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;classes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;class</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;giftShop.giftBox&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/classes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/test<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/suite<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2><span style="font-family: Arial,sans-serif; color: #800000;"><strong>Step 6: Writing selenium grid program:</strong></span></h2>
<p style="text-align: justify;"><span style="font-family: Arial,sans-serif;">This selenium grid program will start selenium on chrome, firefox and opera. It would open up the <a href="http://www.gifts.com/">www.gifts.com</a> website and click on birthday as occasion. It asserts whether the landing page displays the birthday gifts in all the three browsers as expected.</span></p>
<p>&nbsp;</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">giftShop</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.Test</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.Assert</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.AfterClass</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.BeforeClass</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.Parameters</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.thoughtworks.selenium.DefaultSelenium</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">com.thoughtworks.selenium.Selenium</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> giftBox 
<span style="color: #009900;">&#123;</span>
	Selenium selenium<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//Declaration of variables used in this program</span>
	<span style="color: #003399;">String</span> strTimeout<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;30000&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> bdayTitle<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;Birthday Gifts - Birthday Gift Ideas from Gifts.com&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">int</span> intsleepTime<span style="color: #339933;">=</span><span style="color: #cc66cc;">15000</span><span style="color: #339933;">;</span>
&nbsp;
    @BeforeClass
    <span style="color: #666666; font-style: italic;">//Reads the values of host, port, browser and url &quot;www.gifts.com&quot; from testng.xml</span>
    @Parameters<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;selenium.host&quot;</span>, <span style="color: #0000ff;">&quot;selenium.port&quot;</span>, <span style="color: #0000ff;">&quot;selenium.browser&quot;</span>, <span style="color: #0000ff;">&quot;selenium.url&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> beforeClass<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> host, <span style="color: #003399;">String</span> port, <span style="color: #003399;">String</span> browser, <span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        selenium <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultSelenium<span style="color: #009900;">&#40;</span>host, <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>port<span style="color: #009900;">&#41;</span>,browser, url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        selenium.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        selenium.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        selenium.<span style="color: #006633;">windowMaximize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        selenium.<span style="color: #006633;">windowFocus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        selenium.<span style="color: #006633;">deleteAllVisibleCookies</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> 
&nbsp;
    @Test
    @Parameters<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;bdayLink&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testB<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> bDayGift<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">try</span>
        <span style="color: #009900;">&#123;</span>
        	<span style="color: #666666; font-style: italic;">//Click on birthday as occasion on www.gifts.com website</span>
        	selenium.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span>bDayGift<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        	selenium.<span style="color: #006633;">waitForPageToLoad</span><span style="color: #009900;">&#40;</span>strTimeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        	<span style="color: #666666; font-style: italic;">//Verify that the birthday gift items page is displayed</span>
        	<span style="color: #000000; font-weight: bold;">Assert</span>.<span style="color: #006633;">assertEquals</span><span style="color: #009900;">&#40;</span>bdayTitle, selenium.<span style="color: #006633;">getTitle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003399;">Thread</span>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span>intsleepTime<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// TODO Auto-generated catch block</span>
            e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</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;
    @AfterClass
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> afterClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
    <span style="color: #009900;">&#123;</span>
        selenium.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        selenium.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Running the test case</strong>:</p>
<p>Please do the following to run the selenium grid test case (after the hub and RCs are launched):<br />
1. Right click on the<strong> testng.xml</strong> file<br />
2. Click on Run as <strong>“TestNG Suite”</strong></p>
<p>Please feel free to post any comments or ask questions.</p>
]]></content:encoded>
			<wfw:commentRss>http://technologyandleadership.com/six-steps-for-complete-test-automation-with-selenium-grid/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Crucial aspects of browser compatibilty testing with Selenium Grid</title>
		<link>http://technologyandleadership.com/crucial-aspects-of-browser-compatibilty-testing-with-selenium-grid/</link>
		<comments>http://technologyandleadership.com/crucial-aspects-of-browser-compatibilty-testing-with-selenium-grid/#comments</comments>
		<pubDate>Thu, 26 May 2011 19:37:45 +0000</pubDate>
		<dc:creator>Aruna</dc:creator>
				<category><![CDATA[Selenium]]></category>
		<category><![CDATA[Software Testing]]></category>
		<category><![CDATA[Test Automation Tools]]></category>
		<category><![CDATA[active-x control]]></category>
		<category><![CDATA[architecture]]></category>
		<category><![CDATA[browser compatibility]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[misalignment]]></category>
		<category><![CDATA[multiple browser]]></category>
		<category><![CDATA[parallel test]]></category>
		<category><![CDATA[selenese]]></category>
		<category><![CDATA[selenium grid]]></category>
		<category><![CDATA[Selenium Hub]]></category>
		<category><![CDATA[Selenium Remote Control]]></category>
		<category><![CDATA[Test]]></category>

		<guid isPermaLink="false">http://technologyandleadership.com/?p=793</guid>
		<description><![CDATA[What is browser compatibility for software? In different browsers the same text, graphics and color can appear differently. Some of the browsers do not support Javascript or Active-X control which are required by the software to provide the desired functionality to the end-user. The critical areas of the software is expected to appear and function [...]]]></description>
			<content:encoded><![CDATA[<p><script src="http://apis.google.com/js/plusone.js" type="text/javascript"></script></p>
<p style="text-align: justify;"><strong>What is browser compatibility for software? </strong>In different browsers the same text, graphics and color can appear differently.  Some of the browsers do not support Javascript or Active-X control  which are required by the software to provide the desired functionality  to the end-user. The critical areas of the software is expected to appear and function as desired on all the commonly used browsers like safari, IE, firefox etc. This ensures that the code developed supports browser compatibility, one of the crucial aspects of software development.</p>
<p style="text-align: justify;">Examples of browser compatibility issues:<br />
1. The date input field is validated for incorrect date-formats using  javascript. If javascript is not supported by the browser, the software  will allow the customer to enter invalid date which is a defect</p>
<p style="text-align: justify;">2. A country drop-down is sorted alphabetically using a client-side javascript. The same rule applies as one. If it is not supported, the user finds it very difficult to select a country from the dropdown</p>
<p>3. Misalignment of controls on the web page which looks frustrating to the customer</p>
<p style="text-align: justify;">4. Web page looking cluttered on mobile browsers</p>
<p style="text-align: justify;">Having elaborated on browser compatibility, let us discuss a very popular tool called selenium grid that <strong>provides a very easy way to execute multiple tests in parallel on different browsers</strong>. By running the test suite concurrently on several browsers it reduces the cost for browser compatibility testing and also dramatically speeds up the feedback cycle. This article is a great head-start on how selenium grid makes browser compatibility testing fun and easy. It explores the boundless potential it offers when used in conjunction with Selenium RC. In the next article &#8220;<a href="http://technologyandleadership.com/six-steps-for-complete-test-automation-with-selenium-grid/">Six steps to complete test automation with selenium grid</a>&#8221; we will get our hands dirty with selenium grid programming and execution.</p>
<h2><span style="color: #800000;">Architecture of Selenium Grid:</span><br />
<a href="http://technologyandleadership.com/wp-content/uploads/2011/05/grid1.png"><img class="size-large wp-image-795 aligncenter" title="grid" src="http://technologyandleadership.com/wp-content/uploads/2011/05/grid1-527x620.png" alt="" width="527" height="620" /></a></h2>
<p><!-- p { margin-bottom: 0.08in; }a:link {  } --></p>
<p style="text-align: justify;">Here we can see three main components in the diagram, Test, Selenium Hub and Selenium Remote Control.</p>
<p style="text-align: justify;">The <strong>Test</strong> is a series of Selenium commands</p>
<p style="text-align: justify;">The <strong>Selenium hub</strong> routes the selenese requests from the Test to the appropriate Selenium Remote Control.</p>
<p style="text-align: justify;">The <strong>Selenium Remote Control</strong> is an instance of Selenium Server that registers itself to the hub when it starts describing the environment provided&#8230;&#8230;.for example chrome on ubuntu, IE on windows.</p>
<p style="text-align: justify;"><strong>Selenium grid is a distributed grid of Selenium Remote Controls.</strong> The Remote Control is an instance of Selenium Server that registers itself to the hub when it starts describing the environment provided. <strong>When the Selenium Remote Control is started we define which environment it provides to the hub.</strong> In the selenium test, when instantiating the Selenium driver, the hub environment is passed in the place of the browser string.</p>
<p style="text-align: justify;">The Remote Control instances that have been registered with the grid show up in <a href="http://localhost:4444/console">http://localhost:4444/console</a>. The Selenium hub routes the selenese requests to the appropriate Selenium Remote Control. The hub puts the request on hold if there is no available Remote Control on the grid. As soon as the suitable Remote Control becomes available the hub will serve the request. The hub parses the tests that target specific environments. We can specifically target a particular browser and a particular platform for testing the software.</p>
<p style="text-align: justify;">This is how Selenium grid works and it makes browser compatibility testing a breeze.</p>
]]></content:encoded>
			<wfw:commentRss>http://technologyandleadership.com/crucial-aspects-of-browser-compatibilty-testing-with-selenium-grid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>junit vs TestNG &#8211; core differences</title>
		<link>http://technologyandleadership.com/junit-vs-testng-core-differences/</link>
		<comments>http://technologyandleadership.com/junit-vs-testng-core-differences/#comments</comments>
		<pubDate>Fri, 20 May 2011 00:45:50 +0000</pubDate>
		<dc:creator>Aruna</dc:creator>
				<category><![CDATA[Software Testing]]></category>
		<category><![CDATA[Test Automation Tools]]></category>
		<category><![CDATA[TestNG]]></category>
		<category><![CDATA[categories]]></category>
		<category><![CDATA[choice]]></category>
		<category><![CDATA[data driven testing]]></category>
		<category><![CDATA[DataProvider]]></category>
		<category><![CDATA[define groups]]></category>
		<category><![CDATA[dependency]]></category>
		<category><![CDATA[dependency test]]></category>
		<category><![CDATA[differences between Junit and TestNG]]></category>
		<category><![CDATA[evaluate]]></category>
		<category><![CDATA[group]]></category>
		<category><![CDATA[Group test]]></category>
		<category><![CDATA[groups]]></category>
		<category><![CDATA[Junit]]></category>
		<category><![CDATA[Junit vs TestNG]]></category>
		<category><![CDATA[parameterize test data]]></category>
		<category><![CDATA[Parameterized object]]></category>
		<category><![CDATA[test data]]></category>
		<category><![CDATA[testing framework]]></category>
		<category><![CDATA[TestNG.xml]]></category>
		<category><![CDATA[unit testing]]></category>
		<category><![CDATA[vs]]></category>

		<guid isPermaLink="false">http://technologyandleadership.com/?p=771</guid>
		<description><![CDATA[Junit and TestNG differ in the core design. Junit is a unit testing framework while TestNG addresses testing at a higher level. This article discusses the three main differences between TestNG and Junit. 1.     In Junit, one test case failure can cause a bunch of test cases to fail in the test suite. [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Junit and TestNG differ in the core design. Junit is a unit testing framework while TestNG addresses testing at a higher level. This article discusses the three main differences between TestNG and Junit.</p>
<p style="text-align: justify;"><a href="http://technologyandleadership.com/wp-content/uploads/2011/05/junitvstestng.png"></a><a href="http://technologyandleadership.com/wp-content/uploads/2011/05/jnuitvstestng.png"><img class="alignnone size-large wp-image-787" title="jnuitvstestng" src="http://technologyandleadership.com/wp-content/uploads/2011/05/jnuitvstestng-620x363.png" alt="" width="620" height="363" /></a></p>
<p style="text-align: justify;">1.     In Junit, one test case failure can cause a bunch of test cases to fail in the test suite. There is no option of skipping the set of dependent test cases. The dependent test cases are also reported as failures. For example, suppose there is a test case to test login and the next 10 test cases need to perform a transaction after login. If the login test case fails the other 10 test cases  will also fail.</p>
<p style="text-align: justify;"><strong>TestNG handles dependency between test cases.</strong> If one test case failure causes the failure of a group of test cases it skips that group and executes the rest of the test suite. The group that has dependency on the failed test cases is reported as skipped NOT failed.</p>
<p style="text-align: justify;">2.     In TestNG groups can be defined. Groups are specific subsets of the test suite. <strong>We can choose to run only specific subset of the testsuite say database related test cases instead of running the entire test suite. </strong>This can be done as below:</p>
<p>In the test case we define two groups DBTestcase and deprecated as below:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@Test<span style="color: #009900;">&#40;</span>groups <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;DBTestcase&quot;</span>, <span style="color: #0000ff;">&quot;deprecated&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testMethod2<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In TestNG.xml config file we write the below piece of code to include only database related test cases and exclude the deprecated ones.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;test</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;Sample&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groups<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;run<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;DBTestcase&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclude</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;deprecated&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/run<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groups<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;classes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;class</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;example1.Test1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/classes<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/test<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p style="text-align: justify;">In Junit for a long time it was not possible to run a specific subset of the test cases. We can either run the entire suite or run each test case individually. Junit 4.8 introduced a new feature called &#8220;Categories&#8221; to overcome this limitation. However groups are much easier to configure in TestNG.</p>
<p><strong> </strong></p>
<p style="text-align: justify;">3.     <strong>TestNG supports parameterization for objects.</strong> For example I can execute a single test case for multiple test data sets through the parameterization of DataProvider object. This makes the implementation of data driven testing more flexible in TestNG as below:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@DataProvider<span style="color: #009900;">&#40;</span>name <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;DP1&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> testData<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
<span style="color: #009900;">&#123;</span>
<span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> sdataArray <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#123;</span><span style="color: #0000ff;">&quot;james&quot;</span>,<span style="color: #0000ff;">&quot;moosecat$&quot;</span>, <span style="color: #0000ff;">&quot;james@gmail.com&quot;</span>,<span style="color: #0000ff;">&quot;selenigr&quot;</span>,<span style="color: #0000ff;">&quot;selenigr1$&quot;</span>, <span style="color: #0000ff;">&quot;selenigr@yahoo.co.uk&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">return</span> sdataArray<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
@Test <span style="color: #009900;">&#40;</span>dataProvider <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;DP1&quot;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> evernoteSharing<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> user1, <span style="color: #003399;">String</span> password1, <span style="color: #003399;">String</span> email1, <span style="color: #003399;">String</span> user2, <span style="color: #003399;">String</span> password2, <span style="color: #003399;">String</span> email2<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In junit test data is not parameterized using a DataProvider hook. Data-driven testing is implemented differently and involves more coding.</p>
<div id="_mcePaste" class="mcePaste" style="position: absolute; left: -10000px; top: 503px; width: 1px; height: 1px; overflow: hidden;">In TestNG groups can be defined. Groups are specific subsets of the test suite. <strong>We can choose to run only specific groups instead of running the entire test suite.</strong></div>
]]></content:encoded>
			<wfw:commentRss>http://technologyandleadership.com/junit-vs-testng-core-differences/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Is your code fit for testing?</title>
		<link>http://technologyandleadership.com/is-your-code-fit-for-testing/</link>
		<comments>http://technologyandleadership.com/is-your-code-fit-for-testing/#comments</comments>
		<pubDate>Tue, 17 May 2011 02:30:34 +0000</pubDate>
		<dc:creator>Aruna</dc:creator>
				<category><![CDATA[Software Testing]]></category>
		<category><![CDATA[Testing practices]]></category>
		<category><![CDATA[decoupling]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[Law of Demeter]]></category>
		<category><![CDATA[loosely coupled]]></category>
		<category><![CDATA[Test Driven Development]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://technologyandleadership.com/?p=733</guid>
		<description><![CDATA[This article brainstorms how design choices for better code testability fits into the big picture of providing a continuous stream of business value to the customer. Exploring the possible software design options even before the coding starts enables decoupling and dependency injection which makes the software all the more robust and flexible to absorb future [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">This article brainstorms how design choices for better code testability fits into the big picture of providing a continuous stream of business value to the customer. Exploring the possible software design options even before the coding starts <strong>enables decoupling and dependency injection </strong>which makes the software all the more robust and flexible to absorb future changes in the customer requirements.</p>
<p style="text-align: justify;">What is a unit? A unit is the smallest testable part of an application. Unit tests are written from the specification (FSD/TDD) based on how the product would be used by the end customer. It should be tested in isolation without any dependency. All the dependencies should be mocked up using stubs so that the unit tests are simple and fast. These tests are supposed to focus only on a specific action without any coding for the dependencies.</p>
<p style="text-align: justify;">For example, the coder develops a method called validate_zip_code. When I enter  zip code as 00000 it should return false. This is a unit test.  As per the requirement spec, on the shipping form if the customer enters invalid zip code he should be re-directed to the help page that explains what is a zip code.  Imagine that this help page is yet to be developed by a different team called consumer team. <strong>Testing both the zip code field and the display of help page is not unit testing but functional/integration testing. This dependency on the help page display needs to be separated from the validation of zip code. This separation is called dependency injection and it decouples the code making it more robust. </strong>The dependencies could be mocked using tools like mockito or easymock. Thus the coder needs to create a mockup or a simulator to substitute for the dependency.</p>
<p style="text-align: justify;"><a href="http://technologyandleadership.com/wp-content/uploads/2011/05/unittest.png"><img class="alignnone size-large wp-image-735" title="unittest" src="http://technologyandleadership.com/wp-content/uploads/2011/05/unittest-620x387.png" alt="" width="620" height="387" /></a></p>
<p style="text-align: justify;"><strong>Why dependency injection can ease unit tests?</strong> With dependency injection writing unit tests becomes easy and the execution of unit tests becomes simple and fast. This is because the coders are not required to write test code for dependencies as well. Writing code for dependencies makes unit tests complicated and it is also unnecessary since we are not going to do any functional testing with it.</p>
<p style="text-align: justify;"><strong>Advantages of Dependency Injection:</strong><br />
1. Unit testing before coding adopts <strong>Test Driven Development</strong>. The coders can brainstorm the possible execution paths and corner cases that he had never thought of before. This results in a higher quality code<br />
2. Code with lots of dependencies violates the <strong>Law of Demeter or the Hollywood principle</strong>. With dependency injection the code becomes <strong>loosely coupled</strong><br />
3. Determines if the code is fit for testing and increases the testability of the code</p>
]]></content:encoded>
			<wfw:commentRss>http://technologyandleadership.com/is-your-code-fit-for-testing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hosting rails application on heroku</title>
		<link>http://technologyandleadership.com/hosting-rails-application-on-heroku/</link>
		<comments>http://technologyandleadership.com/hosting-rails-application-on-heroku/#comments</comments>
		<pubDate>Mon, 18 Apr 2011 00:46:21 +0000</pubDate>
		<dc:creator>Aruna</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[heroku]]></category>
		<category><![CDATA[keys:add]]></category>
		<category><![CDATA[libreadline5-dev]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[public key]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[readline]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[zlib]]></category>

		<guid isPermaLink="false">http://technologyandleadership.com/?p=719</guid>
		<description><![CDATA[Signup for a Heroku account at https://api.heroku.com/signup Then install heroku gem with the below command: sudo gem install heroku Remove ruby 1.9.2, install zlib and openssl package and then re-install ruby as follows: rvm remove 1.9.2 rvm package install zlib rvm package install openssl rvm install 1.9.2 -C --with-zlib-dir=$HOME/.rvm/usr --with-openssl-dir=$HOME/.rvm/usr rvm --default use 1.9.2@rails3tutorial Install [...]]]></description>
			<content:encoded><![CDATA[<p><!-- p { margin-bottom: 0.08in; }a:link {  } -->Signup for a Heroku account at <a href="https://api.heroku.com/signup">https://api.heroku.com/signup</a></p>
<p>Then install heroku gem with the below command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> heroku</pre></div></div>

<p>Remove ruby 1.9.2, install zlib and openssl package and then re-install ruby as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rvm remove 1.9.2
rvm package <span style="color: #c20cb9; font-weight: bold;">install</span> zlib
rvm package <span style="color: #c20cb9; font-weight: bold;">install</span> openssl
rvm <span style="color: #c20cb9; font-weight: bold;">install</span> 1.9.2 <span style="color: #660033;">-C</span> <span style="color: #660033;">--with-zlib-dir</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-openssl-dir</span>=<span style="color: #007800;">$HOME</span><span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>usr
rvm <span style="color: #660033;">--default</span> use 1.9.2<span style="color: #000000; font-weight: bold;">@</span>rails3tutorial</pre></div></div>

<p>Install and compile readline with the below commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libncurses5-dev
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libreadline5-dev
<span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>ruby-1.9.2-p180<span style="color: #000000; font-weight: bold;">/</span>ext<span style="color: #000000; font-weight: bold;">/</span>readline<span style="color: #000000; font-weight: bold;">/</span>
ruby extconf.rb
<span style="color: #c20cb9; font-weight: bold;">make</span>
<span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Associate your Heroku account with the public key.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">heroku keys:add</pre></div></div>

<p>Use create command to create a heroku subdomain for the app:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">heroku create</pre></div></div>

<p>Using git to push the application to the heroku server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> push heroku master</pre></div></div>

<p>The open command opens up the url in a new browser window.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">heroku open</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://technologyandleadership.com/hosting-rails-application-on-heroku/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RVM – Easy installation of &#8216;ruby on rails&#8217; on ubuntu</title>
		<link>http://technologyandleadership.com/rvm-%e2%80%93-easy-installation-of-ruby-on-rails-on-ubuntu/</link>
		<comments>http://technologyandleadership.com/rvm-%e2%80%93-easy-installation-of-ruby-on-rails-on-ubuntu/#comments</comments>
		<pubDate>Sun, 17 Apr 2011 15:50:00 +0000</pubDate>
		<dc:creator>Aruna</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Easiest rails setup]]></category>
		<category><![CDATA[easy]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rails setup]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[RubyGems]]></category>
		<category><![CDATA[rvm]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://technologyandleadership.com/?p=682</guid>
		<description><![CDATA[Ruby Version Manager (RVM) resolves versions conflicts when multiple versions of ruby is installed on the same system. It also enables quick and easy installation of ruby on rails on ubuntu. This article provides solution to the problems faced during the installation of ruby on rails on ubuntu using RVM. Installation of RVM: bash &#60; [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><strong>Ruby Version Manager (RVM)</strong> resolves versions conflicts when multiple versions of ruby is installed on the same system. It also enables quick and easy installation of ruby on rails on ubuntu. This article provides solution to the problems faced during the installation of ruby on rails on ubuntu using RVM.</p>
<p style="text-align: justify;"><strong>Installation of RVM:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">&lt;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>curl <span style="color: #660033;">-s</span> https:<span style="color: #000000; font-weight: bold;">//</span>rvm.beginrescueend.com<span style="color: #000000; font-weight: bold;">/</span>install<span style="color: #000000; font-weight: bold;">/</span>rvm<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">source</span> ~<span style="color: #000000; font-weight: bold;">/</span>.rvm<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>rvm
rvm reload</pre></div></div>

<p><strong>Install Ruby 1.9.2 with rvm:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rvm package <span style="color: #c20cb9; font-weight: bold;">install</span> zlib
rvm <span style="color: #c20cb9; font-weight: bold;">install</span> 1.9.2 <span style="color: #660033;">-C</span> <span style="color: #660033;">--with-zlib-dir</span>=<span style="color: #007800;">$rvm_path</span><span style="color: #000000; font-weight: bold;">/</span>usr
rvm <span style="color: #c20cb9; font-weight: bold;">install</span> 1.8.7-p174 <span style="color: #660033;">-C</span> –with-zlib-dir=<span style="color: #007800;">$rvm_path</span><span style="color: #000000; font-weight: bold;">/</span>usr</pre></div></div>

<p>To resolve version conflict, create separate gemsets for each of the two different versions:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rvm <span style="color: #660033;">--create</span> 1.8.7-p174<span style="color: #000000; font-weight: bold;">@</span>rails2tutorial
rvm <span style="color: #660033;">--create</span> use 1.9.2<span style="color: #000000; font-weight: bold;">@</span>rails3tutorial</pre></div></div>

<p>To use Ruby 1.9.2 by default and Rails 3.0 give the below command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rvm <span style="color: #660033;">--default</span> use 1.9.2<span style="color: #000000; font-weight: bold;">@</span>rails3tutorial</pre></div></div>

<p><strong>Install Rails:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">--no-ri</span> <span style="color: #660033;">--no-rdoc</span> <span style="color: #660033;">--version</span>=3.0.1 rails</pre></div></div>

<p>Confirm installation with the below command. This command will display the version of rails installed on the system.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rails <span style="color: #660033;">-v</span></pre></div></div>

<p><strong>Install RubyGems:</strong><br />
Installation of rvm automatically installs RubyGems<br />
Give the below command to confirm this. This command would display the path in which the gem has been installed.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">which</span> gem</pre></div></div>

<p>Update the system to the latest version with the below command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem update –system</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://technologyandleadership.com/rvm-%e2%80%93-easy-installation-of-ruby-on-rails-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux shell scripting using GNOME-Shell</title>
		<link>http://technologyandleadership.com/linux-shell-scirpting-using-gnome-shell/</link>
		<comments>http://technologyandleadership.com/linux-shell-scirpting-using-gnome-shell/#comments</comments>
		<pubDate>Fri, 11 Mar 2011 01:45:22 +0000</pubDate>
		<dc:creator>Aruna</dc:creator>
				<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[$USER]]></category>
		<category><![CDATA[chmod]]></category>
		<category><![CDATA[echo]]></category>
		<category><![CDATA[GNOME-shell]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[installation of GNOME-shell]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[shell scripting]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://technologyandleadership.com/?p=625</guid>
		<description><![CDATA[Shell Scripting for beginners Part1 covered the execution of a Shell Script on WINDOWS platform with a comprehensive illustration. In this article let us practice shell scripting on LINUX platform. This is done using GNOME-shell for scripting and vim editor for modification and saving of shell scripts. Open the terminal:  Go to Applications → Accessories [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;"><span style="color: #00ae00;"><strong><span style="color: #00ae00;"><a href="http://technologyandleadership.com/category/technology/shell-scripting/">Shell Scripting for beginners Part1</a></span></strong> </span>covered the execution of a Shell Script on WINDOWS platform with a comprehensive illustration. In this article let us practice shell scripting on LINUX platform. This is done using GNOME-shell for scripting and vim editor for modification and saving of shell scripts.</p>
<p><!-- p { margin-bottom: 0.08in; } -->Open the terminal:  <strong>Go to Applications → Accessories → Terminal</strong></p>
<p><strong><br />
</strong></p>
<h2><span style="color: #800000;">Pre-requisite: Installation of GNOME-shell</span></h2>
<p><!-- p { margin-bottom: 0.08in; } --><span style="color: #00ae00;">COMMAND:</span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> gnome-shell</pre></div></div>

<p><span style="color: #00ae00;"> </span></p>
<p><span style="color: #00ae00;">OUTPUT: It takes a few seconds<br />
</span></p>
<p><!-- p { margin-bottom: 0.08in; } -->[sudo] password for dell:</p>
<p>Reading package lists&#8230; Done</p>
<p>Building dependency tree&#8230;&#8230;&#8230;&#8230;..</p>
<p><!-- p { margin-bottom: 0.08in; } -->After this install the vim editor using the command</p>
<p><span style="color: #00ae00;"> </span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">vim</span></pre></div></div>

<p><span style="color: #00ae00;"><br />
</span></p>
<h2><span style="color: #00ae00;"><span style="color: #800000;">Creation and execution of a simple Shell Script</span></span></h2>
<p><span style="color: #00ae00;"><span style="color: #800000;"><span style="color: #000000;">Let us start by creating a directory called shellscripts using mkdir command and start working there</span></span></span></p>
<p><span style="color: #00ae00;"><span style="color: #800000;"><span style="color: #000000;">Navigate to home directory using cd ~ command</span></span></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> shellscripts
<span style="color: #7a0874; font-weight: bold;">cd</span> shellscripts</pre></div></div>

<p>Now we are inside the shellscripts directory. Now create a new shell script called test.sh using the command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">vim</span> test.sh</pre></div></div>

<p style="text-align: justify;">After giving vim command it creates a new file called test.sh. Press &#8220;INSERT&#8221; key to start scripting. The shell script starts with a &#8220;shabang&#8221;. In this program we display the username using $USER variable and echo command as below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #c20cb9; font-weight: bold;">clear</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Hello, <span style="color: #007800;">$USER</span>.&quot;</span></pre></div></div>

<p>The screen should look as below:</p>
<p><a href="http://technologyandleadership.com/wp-content/uploads/2011/03/test1.png"><img class="alignnone size-large wp-image-660" title="test" src="http://technologyandleadership.com/wp-content/uploads/2011/03/test1-620x432.png" alt="" width="620" height="432" /></a></p>
<p>Now save the file using ESC+w+q+! command</p>
<p>Grant permissions for execution of test.sh using the chmod command as below:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x test.sh</pre></div></div>

<p>Execute the shell script using:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>test.sh</pre></div></div>

<p>The output is as below:</p>
<p><a href="http://technologyandleadership.com/wp-content/uploads/2011/03/output.png"><img class="alignnone size-full wp-image-656" title="output" src="http://technologyandleadership.com/wp-content/uploads/2011/03/output.png" alt="" width="333" height="159" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://technologyandleadership.com/linux-shell-scirpting-using-gnome-shell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

