<?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>SeleniumExamples</title>
	<atom:link href="http://seleniumexamples.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://seleniumexamples.com/blog</link>
	<description>Examples and tips for Selenium</description>
	<lastBuildDate>Mon, 23 Aug 2010 09:28:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Checking Wedding Gifts with Selenium</title>
		<link>http://seleniumexamples.com/blog/examples/checking-wedding-gifts-with-selenium/</link>
		<comments>http://seleniumexamples.com/blog/examples/checking-wedding-gifts-with-selenium/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 09:28:33 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[gift list]]></category>
		<category><![CDATA[selenium 2]]></category>
		<category><![CDATA[webdriver]]></category>
		<category><![CDATA[wedding]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=249</guid>
		<description><![CDATA[Admittedly this one is unlikely to be useful to many, but it could still serve as a useful example for Selenium 2. Also, I haven&#8217;t posted an example since alpha 5 was released. I&#8217;m getting married in a few short weeks, and our gift list has now opened for any guests that would like to [...]]]></description>
			<content:encoded><![CDATA[<p>Admittedly this one is unlikely to be useful to many, but it could still serve as a useful example for Selenium 2. Also, I haven&#8217;t posted an example since <a href="http://seleniumhq.wordpress.com/2010/07/14/selenium-2-0a5-released/">alpha 5</a> was released.</p>
<p>I&#8217;m getting married in a few short weeks, and our gift list has now opened for any guests that would like to buy us something for the occasion. We debated over having a list in the first place, but in the end decided that it was probably for the best. One of our hesitations was that we didn&#8217;t want to know what people had bought for us before the day, and having an online gift list makes it possible to &#8216;spoil&#8217; the surprise.</p>
<p>With the list only having been open a couple of days, the temptation was already pretty difficult to resist and we decided that it was okay to see what has been bought just so long as we don&#8217;t find out who&#8217;s bought what. Unfortunately this isn&#8217;t easy on the site as they&#8217;re listed together, so I was sneakily able to construct an XPath that extracted the necessary information. I&#8217;ve now combined into a Selenium 2 example using Java, which can be found below.</p>
<p><strong>GiftList.java</strong></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;">giftlist</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.concurrent.TimeUnit</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.By</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.WebDriver</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.WebElement</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.firefox.FirefoxDriver</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> GiftList <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> WebDriver driver<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> GIFT_LIST_NUMBER <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;123546&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> GIFT_LIST_PASSWORD <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #339933;">;</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;">//open browser</span>
		driver <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FirefoxDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//set implicit wait</span>
		driver.<span style="color: #006633;">manage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">timeouts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">implicitlyWait</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">20</span>, TimeUnit.<span style="color: #006633;">SECONDS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//login</span>
		driver.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;https://www.johnlewisgiftlist.com/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Manage your list&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;giftListNumber&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">sendKeys</span><span style="color: #009900;">&#40;</span>GIFT_LIST_NUMBER<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">name</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;listPassword&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">sendKeys</span><span style="color: #009900;">&#40;</span>GIFT_LIST_PASSWORD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Display List&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//get purchased items</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Gifts purchased&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//h1[text()='Gifts purchased by guests']&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		List<span style="color: #339933;">&lt;</span>WebElement<span style="color: #339933;">&gt;</span> purchasedItems <span style="color: #339933;">=</span> driver.<span style="color: #006633;">findElements</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//tr[td[2] and @class='item']&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//output purchased items</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>WebElement item <span style="color: #339933;">:</span> purchasedItems<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</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>item.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/td[1]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</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: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//log out</span>
		driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">linkText</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Log out&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//close browser</span>
		driver.<span style="color: #006633;">close</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: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/examples/checking-wedding-gifts-with-selenium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Proposal for new Selenium Q&amp;A site</title>
		<link>http://seleniumexamples.com/blog/proposals/proposal-for-new-selenium-qa-site/</link>
		<comments>http://seleniumexamples.com/blog/proposals/proposal-for-new-selenium-qa-site/#comments</comments>
		<pubDate>Thu, 08 Jul 2010 08:57:27 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Proposals]]></category>
		<category><![CDATA[q&a]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[stackexchange]]></category>
		<category><![CDATA[stackoverflow]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=237</guid>
		<description><![CDATA[If you&#8217;re not already aware of the dedicated Selenium Q&#38;A site that I have proposed, then it&#8217;s definitely worth checking it out. If you&#8217;re interested in supporting the proposal, and helping it to reach beta then please commit. By committing you are stating that you are prepared to both ask and answer questions on the [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re not already aware of the <a href="http://area51.stackexchange.com/proposals/4693/selenium">dedicated Selenium Q&amp;A site</a> that I have proposed, then it&#8217;s definitely worth checking it out. If you&#8217;re interested in supporting the proposal, and helping it to reach beta then please <a href="http://area51.stackexchange.com/proposals/4693/selenium?referrer=l3hVtTWVlCTWgagw76fBpg2">commit</a>. By committing you are stating that you are prepared to both ask and answer questions on the proposed site.</p>
<p><strong>So why does Selenium need a new site for Q&amp;A?</strong></p>
<p>Well, first let me give you some history of the official Selenium forums. When I first started to get involved in the Selenium community there was the <a href="http://seleniumhq.org/clearspace.html">Clearspace forums</a>, which provided a good structure, a pretty good interface, and a basic reward system. The main problems I had with Clearspace was searching the content, identifying unanswered questions, and the alarming regularity of certain basic (but very suitable) questions. Another issue turned out to be spam, which I believe was the main reason the content was migrated &#8211; after much discussion &#8211; to <a href="http://groups.google.com/group/selenium-users/">Google Groups</a>.</p>
<p><span id="more-237"></span></p>
<p>I was 100% for this move, however with hindsight I believe it wasn&#8217;t the best decision. Google Groups is great for discussions but not a suitable place for Q&amp;A. It might be powerful in terms of search, but the format of text and structure of conversations makes it very difficult to identify questions, and there&#8217;s little or no incentive in answering them. Whenever I&#8217;ve taken time to read the posts in the group I&#8217;ve almost always lost interest after reading just one or two &#8211; there&#8217;s just so much text!</p>
<p>At this time the StackOverflow site was already becoming a popular place to ask Selenium questions &#8211; there are now over <a href="http://stackoverflow.com/questions/tagged/selenium">600 questions tagged &#8216;selenium&#8217;</a>. Once I&#8217;d asked and answered a handful of questions myself I was hooked. StackOverflow&#8217;s mission is to solve the common problems found in other forum solutions, and they do it very well. Their &#8216;ask a question&#8217; system makes it very obvious if you&#8217;re asking a question that has already been answered, therefore filtering out repetition questions but at the same time providing those users with quality answers. Their rewards system works well to encourage good quality questions and answers. The only problem is that StackOverflow is for asking programming questions, and although Selenium does have programming aspects to it, it&#8217;s not the perfect fit.</p>
<p>Along comes <a href="http://stackexchange.com/">StackExchange</a>, which provides the same underlying solution from StackOverflow to fit an audience other than programmers. Unfortunately StackExchange was a commercial solution, and as Selenium is free and open source there wasn&#8217;t the cash to get something running. It&#8217;s also difficult to determine if the cost would be worthwhile, as without community interested the site would get nowhere.</p>
<p>When StackExchange <a href="http://blog.stackoverflow.com/2010/04/changes-to-stack-exchange/">announced that they would be redesigning their model</a> so that community powered Q&amp;A sites would be provided free of charge if they can prove they have enough committed users, I decided to put forward the Selenium proposal. After 29 days I&#8217;m impressed that the proposal has over <strong>100</strong> followers, and now has over <strong>80</strong> committed users!</p>
<p>If you&#8217;ve already committed then thank you &#8211; I&#8217;m really looking forward to participating with you on the new site!</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/proposals/proposal-for-new-selenium-qa-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Selenium 2 in .NET framework</title>
		<link>http://seleniumexamples.com/blog/examples/selenium2-in-net-framework/</link>
		<comments>http://seleniumexamples.com/blog/examples/selenium2-in-net-framework/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 16:05:02 +0000</pubDate>
		<dc:creator>zacc</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[NUnit]]></category>
		<category><![CDATA[Page Object]]></category>
		<category><![CDATA[selenium 2]]></category>
		<category><![CDATA[webdriver]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=180</guid>
		<description><![CDATA[I&#8217;m not Dave but you might have met me at one of the London Selenium meets. My name is Zac and I have several years of automated testing experience with Selenium RC in Java and C# and am now intending to be one of the early adopters of Selenium 2 using the .NET version. Selenium [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not Dave but you might have met me at one of the London Selenium meets. My name is Zac and I have several years of automated testing experience with Selenium RC in Java and C# and am now intending to be one of the early adopters of Selenium 2 using the .NET version.</p>
<p>Selenium 2 and .NET are up to alpha4 already but thorough examples of code on the internet are a bit thin on the ground so far compared to the Java equivalent. In my time using Selenium RC and now Selenium 2 I have built up a framework to support it.</p>
<p>I consider it to be an intermediate-level framework for using Selenium 2, NUnit and the Page Object model together so some advanced users might find it a bit basic. You may have even seen some of these concepts as snippets on testing blogs around the place. But overall it offers a framework from which to develop an easily maintainable suite of tests using the Page Object model (which is now considered to be the best practice for Selenium 2). If you already have a suite of Selenium tests in flat files that is spiralling in size and you are looking to make it more durable and more efficient then this could suit you.</p>
<p>With this blog post I intend to step through and get you started with this framework.</p>
<p><span id="more-180"></span></p>
<div id="attachment_187" class="wp-caption aligncenter" style="width: 262px"><img class="size-full wp-image-187" src="http://seleniumexamples.com/blog/wp-content/uploads/2010/07/solutionexplore2.jpg" alt="The solution explorer for this example" width="252" height="585" /><p class="wp-caption-text">The solution explorer for this example</p></div>
<p><strong>The Visual Studio solution</strong></p>
<p>Exactly as we did with a Selenium RC project in Visual Studio, we need to create a new &#8216;Class Library&#8217; solution to work with. To get the same naming layout I have, in the Name field type &#8220;Selenium2&#8243; and in the Solution Name field type &#8220;Automated Test Suite&#8221;.</p>
<p>The solution now needs references to both Selenium 2 and NUnit before we get started so if you haven&#8217;t already downloaded them then scurry off and do that now.</p>
<p>Unzip the NUnit and Selenium 2 folders into your solution directory and add the references to the files from inside VS so it looks like the screenshot. Even though Selenium 2 is called Selenium 2, the reference files you need are confusingly prefixed with WebDriver (WebDriver.common, etc)! But they definitely are the ones you&#8217;re after.</p>
<p><strong>SeleniumTestBase class</strong></p>
<p>The class titled Selenium2TestBase.cs is used to setup and deliver the Selenium 2 driver to the test.</p>
<p>It&#8217;s a good chance to set up your driver with any profile extensions or configuration changes like bumping up the default timeout.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Configuration</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">OpenQA.Selenium</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">OpenQA.Selenium.Firefox</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">OpenQA.Selenium.IE</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">OpenQA.Selenium.Chrome</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Selenium2
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Selenium2TestBase
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> FirefoxProfile _ffp<span style="color: #008000;">;</span>
        <span style="color: #0600FF;">private</span> IWebDriver _driver<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> IWebDriver StartBrowser<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            Common.<span style="color: #0000FF;">WebBrowser</span> <span style="color: #008000;">=</span> ConfigurationManager.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;Selenium2Browser&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">switch</span> <span style="color: #000000;">&#40;</span>Common.<span style="color: #0000FF;">WebBrowser</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                <span style="color: #0600FF;">case</span> <span style="color: #666666;">&quot;firefox&quot;</span><span style="color: #008000;">:</span>
                    _ffp <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> FirefoxProfile<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    _ffp.<span style="color: #0000FF;">AcceptUntrustedCertificates</span> <span style="color: #008000;">=</span> true<span style="color: #008000;">;</span>
                    _driver <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> FirefoxDriver<span style="color: #000000;">&#40;</span>_ffp<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    break<span style="color: #008000;">;</span>
                <span style="color: #0600FF;">case</span> <span style="color: #666666;">&quot;iexplore&quot;</span><span style="color: #008000;">:</span>
                    _driver <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> InternetExplorerDriver<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    break<span style="color: #008000;">;</span>
                <span style="color: #0600FF;">case</span> <span style="color: #666666;">&quot;chrome&quot;</span><span style="color: #008000;">:</span>
                    _driver <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> ChromeDriver<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                    break<span style="color: #008000;">;</span>
            <span style="color: #000000;">&#125;</span>
&nbsp;
            <span style="color: #0600FF;">return</span> _driver<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Page Object GoogleHome.cs</strong><br />
The Page Object class contains all of the driver actions on that page as methods. The aim is to keep each method concise and true to their purpose and cut down on duplicated code. The Selenium2 driver is passed in from the test when the class is instantiated. I have used static page objects that do not return the driver. Alternatively you can use <a href="http://code.google.com/p/selenium/wiki/PageObjects">the technique covered here</a>. Also, <a href="http://www.theautomatedtester.co.uk/tutorials/selenium/page-object-pattern.htm">here&#8217;s a Selenium RC example.</a></p>
<p>To keep this example simple I have created only one Page Object but a typical application will have several. I have also stored the Object&#8217;s Xpath locators as private readonly strings inside the Page Object in order to keep it simple and concise but if you have a large amount of them to juggle you may want to use a separate static class.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">OpenQA.Selenium</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Selenium2.<span style="color: #0000FF;">Google</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #FF0000;">class</span> GoogleHome
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> <span style="color: #FF0000;">string</span> _inputFieldSearch <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;//input[@name='q']&quot;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> <span style="color: #FF0000;">string</span> _inputbuttonSearch <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;//input[@name='btnG']&quot;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> <span style="color: #FF0000;">string</span> _inputButtonLucky <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;//input[@name='btnI']&quot;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">readonly</span> IWebDriver googlehome<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> GoogleHome<span style="color: #000000;">&#40;</span>IWebDriver driver<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            googlehome <span style="color: #008000;">=</span> driver<span style="color: #008000;">;</span>
            googlehome.<span style="color: #0000FF;">Navigate</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">GoToUrl</span><span style="color: #000000;">&#40;</span>Google_Common.<span style="color: #0000FF;">GoogleTestSite</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> TypeSearchString<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span> search<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#123;</span>
&nbsp;
            googlehome.<span style="color: #0000FF;">FindElement</span><span style="color: #000000;">&#40;</span>By.<span style="color: #0000FF;">XPath</span><span style="color: #000000;">&#40;</span>_inputFieldSearch<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">SendKeys</span><span style="color: #000000;">&#40;</span>search<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> PressEnterOnSearchField<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            googlehome.<span style="color: #0000FF;">FindElement</span><span style="color: #000000;">&#40;</span>By.<span style="color: #0000FF;">XPath</span><span style="color: #000000;">&#40;</span>_inputFieldSearch<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Submit</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
         <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>NUnit SetupFixture</strong><br />
This SetupFixture class (denoted by the NUnit tag [SetUpFixture]) runs before the tests themselves. I mainly use this feature to configure Common variables that are specific to this project. There is more information about how these are managed further on in the post.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">NUnit.Framework</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Selenium2.<span style="color: #0000FF;">Google</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#91;</span>SetUpFixture<span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Google_Setup_Fixture
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// Runs before all tests</span>
&nbsp;
        <span style="color: #000000;">&#91;</span>SetUp<span style="color: #000000;">&#93;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> SetUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #FF0000;">string</span> environment <span style="color: #008000;">=</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Configuration</span></span>.<span style="color: #0000FF;">ConfigurationManager</span>.<span style="color: #0000FF;">AppSettings</span><span style="color: #000000;">&#91;</span><span style="color: #666666;">&quot;GoogleTestEnvironment&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #008000;">;</span>
            Google_Common.<span style="color: #0000FF;">GoogleTestSite</span> <span style="color: #008000;">=</span> environment<span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// For example sometimes an environment is really slow</span>
            <span style="color: #008080; font-style: italic;">// so we can raise the driver timeout for that env</span>
            <span style="color: #008080; font-style: italic;">//if(environment == &quot;dev&quot;)</span>
            <span style="color: #008080; font-style: italic;">//    Common.DriverTimeout = new TimeSpan(0, 0, 90);</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #000000;">&#91;</span>TearDown<span style="color: #000000;">&#93;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> TearDown<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            Google_Common.<span style="color: #0000FF;">GoogleTestSite</span> <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
            Common.<span style="color: #0000FF;">DriverTimeout</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TimeSpan<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">30</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            Common.<span style="color: #0000FF;">WebBrowser</span> <span style="color: #008000;">=</span> null<span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Finally, the test itself!</strong><br />
Now that we have the page actions (in Page Objects) and driver management abstracted (split up) into their own classes we can actually write the test!</p>
<p>The TestFixture which contains the test keeps the familiar NUnit TestFixtureSetUp and TestFixtureTearDown that you would have used in Selenium RC to setup and teardown the browser, meaning that a new browser will be built for each test. Note that my example inherits Selenium2TestBase, but you could easily instantiate the class if you prefer.</p>
<p>The test itself uses the GoogleHome Page Object to do a basic search. The details of the search are not important &#8211; I will presume that you know how to write a test already.</p>
<p>But don&#8217;t despair, we&#8217;ll post more advanced uses of Selenium 2 in tests on the SeleniumExamples blog as we use it more and more!</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">OpenQA.Selenium</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">NUnit.Framework</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Selenium2.<span style="color: #0000FF;">Google</span>.<span style="color: #0000FF;">Tests</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #000000;">&#91;</span>TestFixture<span style="color: #000000;">&#93;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Search_Tests <span style="color: #008000;">:</span> Selenium2TestBase
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> IWebDriver driver<span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #000000;">&#91;</span>TestFixtureSetUp<span style="color: #000000;">&#93;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> TestFixtureSetUp<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            driver <span style="color: #008000;">=</span> StartBrowser<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #000000;">&#91;</span>TestFixtureTearDown<span style="color: #000000;">&#93;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> TestFixtureTearDown<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            driver.<span style="color: #0000FF;">Quit</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #000000;">&#91;</span>Test<span style="color: #000000;">&#93;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> SearchForSeleniumExamples<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #FF0000;">string</span> _expectedresult <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;Selenium Examples&quot;</span><span style="color: #008000;">;</span>
&nbsp;
            GoogleHome googlehome <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> GoogleHome<span style="color: #000000;">&#40;</span>driver<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            googlehome.<span style="color: #0000FF;">TypeSearchString</span><span style="color: #000000;">&#40;</span>_expectedresult<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            googlehome.<span style="color: #0000FF;">PressEnterOnSearchField</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">//Assert that the title contains the search string</span>
            Assert.<span style="color: #0000FF;">That</span><span style="color: #000000;">&#40;</span>driver.<span style="color: #0000FF;">Title</span>, <span style="color: #008000;">Is</span>.<span style="color: #0000FF;">StringMatching</span><span style="color: #000000;">&#40;</span>_expectedresult<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #008080; font-style: italic;">// Check that we're still on the correct domain using the Google_Common class!</span>
            Assert.<span style="color: #0000FF;">That</span><span style="color: #000000;">&#40;</span>driver.<span style="color: #0000FF;">Url</span>, <span style="color: #008000;">Is</span>.<span style="color: #0000FF;">StringMatching</span><span style="color: #000000;">&#40;</span>Google_Common.<span style="color: #0000FF;">GoogleTestSite</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Getting around an NUnit limitation</strong><br />
One thing that bothers me about NUnit is that I can&#8217;t change the browser or test environment from the NUnit GUI without having to rebuild the project. I guess this is not a requirement for a unit test. Perhaps we&#8217;re pushing the boundaries using NUnit for cross browser functional testing.</p>
<p>However we can use a simple config file to call in variables, commonly the browser, environment or whitelabel details of a site. In the XML config example below I have key value pairs for both the browser and the base URL for the test environment (ie dev, stage, live).</p>
<p>NUnit can be a bit sensitive to the config file&#8217;s directory location. You can see from the Solution Explorer screenshot that it is placed in the top folder and named &#8220;Automated Test Suite.config&#8221;. The settings in NUnit &gt; Project &gt; Edit&#8230; must reflect the config file&#8217;s location and name.</p>
<p>When you update the config file between tests you will need to reload the project in the GUI (Ctrl-P) to use the config changes.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #ddbb00;">&amp;lt;</span>?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?<span style="color: #ddbb00;">&amp;gt;</span>
&nbsp;
<span style="color: #ddbb00;">&amp;lt;</span>configuration<span style="color: #ddbb00;">&amp;gt;</span>
  <span style="color: #ddbb00;">&amp;lt;</span>configSections<span style="color: #ddbb00;">&amp;gt;</span>
  <span style="color: #ddbb00;">&amp;lt;</span>/configSections<span style="color: #ddbb00;">&amp;gt;</span>
&nbsp;
  <span style="color: #ddbb00;">&amp;lt;</span>appSettings<span style="color: #ddbb00;">&amp;gt;</span>
    <span style="color: #ddbb00;">&amp;lt;</span>!--<span style="color: #ddbb00;">&amp;lt;</span>add key=&quot;Selenium2Browser&quot; value=&quot;chrome&quot;/<span style="color: #ddbb00;">&amp;gt;</span>--<span style="color: #ddbb00;">&amp;gt;</span>
    <span style="color: #ddbb00;">&amp;lt;</span>add key=&quot;Selenium2Browser&quot; value=&quot;iexplore&quot;/<span style="color: #ddbb00;">&amp;gt;</span>
    <span style="color: #ddbb00;">&amp;lt;</span>!--<span style="color: #ddbb00;">&amp;lt;</span>add key=&quot;Selenium2Browser&quot; value=&quot;firefox&quot;/<span style="color: #ddbb00;">&amp;gt;</span>--<span style="color: #ddbb00;">&amp;gt;</span>
&nbsp;
    <span style="color: #ddbb00;">&amp;lt;</span>add key=&quot;GoogleTestEnvironment&quot; value=&quot;http://www.google.com/&quot;/<span style="color: #ddbb00;">&amp;gt;</span>
    <span style="color: #ddbb00;">&amp;lt;</span>!--<span style="color: #ddbb00;">&amp;lt;</span>add key=&quot;GoogleTestEnvironment&quot; value=&quot;http://www.google.co.uk/&quot;/<span style="color: #ddbb00;">&amp;gt;</span>--<span style="color: #ddbb00;">&amp;gt;</span>
  <span style="color: #ddbb00;">&amp;lt;</span>/appSettings<span style="color: #ddbb00;">&amp;gt;</span>
<span style="color: #ddbb00;">&amp;lt;</span>/configuration<span style="color: #ddbb00;">&amp;gt;</span></pre></div></div>

<p><strong>The Common classes</strong><br />
You may have noticed that the project references two &#8216;Common&#8217; classes in various places.</p>
<p>In the (static) Common class I store variables that are shared across the whole Selenium2 namespace. For example here the TimeSpan value for timeouts is kept and I can reference it from elsewhere. This way the driver and any custom methods I have written will all use the same timeout value from the Common class.</p>
<p>In other cases I might include the Common variables as part of the expected criteria in assertions which cuts down on hard coded criteria.</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> Selenium2
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">class</span> Common
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">static</span> TimeSpan _defaultTimeSpan <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> TimeSpan<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">0</span>, <span style="color: #FF0000;">30</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">string</span> WebBrowser <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> TimeSpan DriverTimeout
        <span style="color: #000000;">&#123;</span>
            get <span style="color: #000000;">&#123;</span> <span style="color: #0600FF;">return</span> _defaultTimeSpan<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
            set <span style="color: #000000;">&#123;</span> _defaultTimeSpan <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">namespace</span> Selenium2.<span style="color: #0000FF;">Google</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">class</span> Google_Common
    <span style="color: #000000;">&#123;</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">string</span> GoogleTestSite <span style="color: #000000;">&#123;</span> get<span style="color: #008000;">;</span> set<span style="color: #008000;">;</span> <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Extending IWebDriver</strong><br />
Often you will find yourself writing tedious bits of code over and over again. By adding an extension to IWebDriver you can call methods in the same manner, keeping the code clean and readable:<br />
<code> driver.WaitForElementNotPresent(By.Xpath("")); </code></p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">NUnit.Framework</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">Selenium2</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">using</span> <span style="color: #008080;">System.Threading</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF;">namespace</span> OpenQA.<span style="color: #0000FF;">Selenium</span>
<span style="color: #000000;">&#123;</span>
    <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #FF0000;">class</span> IWebDriverExtensions
    <span style="color: #000000;">&#123;</span>
        <span style="color: #008080; font-style: italic;">// This method finds a select element and then selects</span>
        <span style="color: #008080; font-style: italic;">// the option element using the visible text</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> FindSelectElement<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span> IWebDriver driver, By bylocatorForSelectElement, <span style="color: #FF0000;">String</span> text<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            IWebElement selectElement <span style="color: #008000;">=</span> driver.<span style="color: #0000FF;">FindElement</span><span style="color: #000000;">&#40;</span>bylocatorForSelectElement<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
            selectElement.<span style="color: #0000FF;">FindElement</span><span style="color: #000000;">&#40;</span>By.<span style="color: #0000FF;">XPath</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;//option[contains(text(), '&quot;</span> <span style="color: #008000;">+</span> text <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;')]&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0000FF;">Select</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #000000;">&#125;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">// This is a basic wait for element not present a'la Selenium RC</span>
        <span style="color: #008080; font-style: italic;">// but sharing the same timeout value as the driver</span>
        <span style="color: #0600FF;">public</span> <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> WaitForElementNotPresent<span style="color: #000000;">&#40;</span><span style="color: #0600FF;">this</span> IWebDriver driver, By bylocator<span style="color: #000000;">&#41;</span>
        <span style="color: #000000;">&#123;</span>
            <span style="color: #FF0000;">int</span> timeoutinteger <span style="color: #008000;">=</span> Common.<span style="color: #0000FF;">DriverTimeout</span>.<span style="color: #0000FF;">Seconds</span><span style="color: #008000;">;</span>
&nbsp;
            <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> second <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> <span style="color: #008000;">;</span> second<span style="color: #008000;">++</span><span style="color: #000000;">&#41;</span>
            <span style="color: #000000;">&#123;</span>
                Thread.<span style="color: #0000FF;">Sleep</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">1000</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
                <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>second <span style="color: #008000;">&amp;</span>gt<span style="color: #008000;">;=</span> timeoutinteger<span style="color: #000000;">&#41;</span> Assert.<span style="color: #0000FF;">Fail</span><span style="color: #000000;">&#40;</span><span style="color: #666666;">&quot;Timeout: Element still visible at: &quot;</span> <span style="color: #008000;">+</span> bylocator<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #0600FF;">try</span>
                <span style="color: #000000;">&#123;</span>
                    IWebElement element <span style="color: #008000;">=</span> driver.<span style="color: #0000FF;">FindElement</span><span style="color: #000000;">&#40;</span>bylocator<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
                <span style="color: #0600FF;">catch</span> <span style="color: #000000;">&#40;</span>NoSuchElementException<span style="color: #000000;">&#41;</span>
                <span style="color: #000000;">&#123;</span>
                    break<span style="color: #008000;">;</span>
                <span style="color: #000000;">&#125;</span>
            <span style="color: #000000;">&#125;</span>
        <span style="color: #000000;">&#125;</span>
    <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p><strong>Scaling Up!</strong><br />
With this solution it is quite easy to set up tests for numerous web apps within the solution.</p>
<p>Add a new folder at the same level as the Google folder in my example and add the Page Objects and tests inside it. Follow the same structure as the Google example and both applications can share the Selenium2TestBase, WebDriverExtensions, config and Common classes that you have already written.</p>
<p>Cutting down on duplicated code will save you tons of time in both writing and maintaining your tests!</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/examples/selenium2-in-net-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introducing Zac</title>
		<link>http://seleniumexamples.com/blog/introduction/introducing-zac/</link>
		<comments>http://seleniumexamples.com/blog/introduction/introducing-zac/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 14:30:11 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Introduction]]></category>
		<category><![CDATA[new author]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=214</guid>
		<description><![CDATA[As he&#8217;s preparing his first post for SeleniumExamples, it&#8217;s probably a good time to introduce Zac! I have worked with Zac in the past and he recently mentioned having some suitable content for this blog. I thought it&#8217;d be easiest to just give him an account. I suspect most of Zac&#8217;s contributions will be .Net [...]]]></description>
			<content:encoded><![CDATA[<p>As he&#8217;s preparing his first post for SeleniumExamples, it&#8217;s probably a good time to introduce Zac! I have worked with Zac in the past and he recently mentioned having some suitable content for this blog. I thought it&#8217;d be easiest to just give him an account.</p>
<p>I suspect most of Zac&#8217;s contributions will be .Net or C# examples, which is something I have little experience of myself. If you&#8217;re also interested in submitting content to the blog, get in touch with details of what you&#8217;d like to contribute and a bit about yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/introduction/introducing-zac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improving Selenium IDE</title>
		<link>http://seleniumexamples.com/blog/improvements/improving-selenium-ide/</link>
		<comments>http://seleniumexamples.com/blog/improvements/improving-selenium-ide/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 11:57:12 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Improvements]]></category>
		<category><![CDATA[selenium ide]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=188</guid>
		<description><![CDATA[I&#8217;ve been working on a new formatter plugin for Selenium IDE, and along the way I discovered some quirks (not necessarily bugs) in the code. After a few discussions with some of the Selenium community, I decided to get stuck in and see if I couldn&#8217;t make some improvements. In the interest of sharing my [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a new formatter plugin for Selenium IDE, and along the way I discovered some quirks (not necessarily bugs) in the code. After a few discussions with some of the Selenium community, I decided to get stuck in and see if I couldn&#8217;t make some improvements. In the interest of sharing my experiences, here is what I did.</p>
<p><strong>Format header/footer caching</strong><br />
For some reason (still not clear to me) the Selenium IDE formatter headers &#038; footers were cached in two places, the TestCase itself, and also within the Format. I was finding that when switching between my new format and the default HTML, whichever I used first was persisting as the header/footer for the other. This could be fixed by using the Formatter cached header/footer but as I couldn&#8217;t see any advantage of caching this content, it seems like an unnecessary and overcomplicated solution. So I <a href="http://code.google.com/p/selenium/source/detail?r=9275">removed the caching entirely</a>.</p>
<p><strong>Updating variables in format source</strong><br />
The other main issue I had was when updating the base URL in Selenium IDE the format source is not updated. By removing the caching I&#8217;d partially solved this, but it still required the user to switch to another format and back again. Also, changes to variables from the format options pane also need to update the format source. I was able to find the appropriate place to <a href="http://code.google.com/p/selenium/source/detail?r=9276">initiate a refresh of the format source</a>.</p>
<p><strong>Setting the initial base URL</strong><br />
Finally, I had an issue where the initial base URL in the format source was not correct. When I tracked down the right place to put this minor fix I found the line I needed was already there but commented out! After a quick check, it appears that the change may have been a mistake, so I <a href="http://code.google.com/p/selenium/source/detail?r=9277">brought it back in</a> and ran a few successful tests.</p>
<p>Obviously these changes are fairly significant, so the next release of Selenium IDE (1.0.8) will need to be well tested. At this time there isn&#8217;t a build available with these changes, but if you are confident with running a potentially unstable version you can <a href="http://code.google.com/p/selenium/source/checkout">check out from SVN</a> and <a href="http://code.google.com/p/selenium/wiki/BuildingSeIDE">build Selenium IDE yourself</a>.</p>
<p>Please get in touch if you have any feedback. You can raise any issues you find in the <a href="http://code.google.com/p/selenium/issues/list">official issue tracker</a>. Please label them as &#8216;ide&#8217;.</p>
<p>Stay tuned for more details on my new formatter &#8211; I have a few more issues to work through before I&#8217;m ready to release it, and some of these may even involve further improvements to Selenium IDE.</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/improvements/improving-selenium-ide/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get a new iPhone with help from Selenium</title>
		<link>http://seleniumexamples.com/blog/examples/get-a-new-iphone-with-help-from-selenium/</link>
		<comments>http://seleniumexamples.com/blog/examples/get-a-new-iphone-with-help-from-selenium/#comments</comments>
		<pubDate>Wed, 30 Jun 2010 11:59:08 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[iphone 4]]></category>
		<category><![CDATA[o2]]></category>
		<category><![CDATA[selenium 2]]></category>
		<category><![CDATA[testng]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=171</guid>
		<description><![CDATA[I&#8217;ve been looking forward to the iPhone 4 ever since the 3GS was released, as I was in contract at the time and decided to wait another year for whatever Apple decided to release next. Due to unexpected (but very cool) circumstances, I was out of the country on the day Apple released the iPhone [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been looking forward to the iPhone 4 ever since the 3GS was released, as I was in contract at the time and decided to wait another year for whatever Apple decided to release next. Due to unexpected (<a href="http://www.meetup.com/seleniumsanfrancisco/calendar/13674328/">but very cool</a>) circumstances, I was out of the country on the day Apple released the iPhone 4 and so was unable to queue up for one of the devices, and now due to the demand it&#8217;s very difficult to get hold of one. Since getting back to the UK I have been visiting my two nearest O2 stores to check if they have had a delivery, and today they pointed me towards their online stock checker&#8230;</p>
<p>So rather than check this manually, I decided to write a couple of small Selenium 2 scripts to check the stock levels at my &#8216;local&#8217; stores, and to find out all stores that do have the devices. These examples use Java with TestNG (for dataproviders), and Selenium 2.</p>
<p><span id="more-171"></span></p>
<p><strong>WebDriverTestBase.java</strong></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;">o2stock</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.concurrent.TimeUnit</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.WebDriver</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.firefox.FirefoxDriver</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.support.ui.Wait</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.support.ui.WebDriverWait</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.AfterMethod</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.BeforeMethod</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> WebDriverTestBase <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> FirefoxDriver driver<span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> Wait wait<span style="color: #339933;">;</span>
&nbsp;
    @BeforeMethod<span style="color: #009900;">&#40;</span>alwaysRun <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> startWebDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    	driver <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FirefoxDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	wait <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WebDriverWait<span style="color: #009900;">&#40;</span>driver, <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    	driver.<span style="color: #006633;">manage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">timeouts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">implicitlyWait</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span>, TimeUnit.<span style="color: #006633;">SECONDS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @AfterMethod<span style="color: #009900;">&#40;</span>alwaysRun <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> closeSession<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        driver.<span style="color: #006633;">close</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: #009900;">&#125;</span></pre></div></div>

<p><strong>O2Stock.java</strong></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;">o2stock</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.By</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.WebElement</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.support.ui.Select</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.DataProvider</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.testng.annotations.Test</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> O2Stock <span style="color: #000000; font-weight: bold;">extends</span> WebDriverTestBase <span style="color: #009900;">&#123;</span>
&nbsp;
    @SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unused&quot;</span><span style="color: #009900;">&#41;</span>
    @DataProvider
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Object</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> stores<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</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> <span style="color: #009900;">&#123;</span>
            <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;London&quot;</span>, <span style="color: #0000ff;">&quot;London&quot;</span> <span style="color: #009900;">&#125;</span>,
            <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;South East&quot;</span>, <span style="color: #0000ff;">&quot;Bluewater&quot;</span> <span style="color: #009900;">&#125;</span>,
            <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;South East&quot;</span>, <span style="color: #0000ff;">&quot;Dartford&quot;</span> <span style="color: #009900;">&#125;</span>,
        <span style="color: #009900;">&#125;</span><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;stores&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> checkStock<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> region, <span style="color: #003399;">String</span> city<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">String</span> modelTitle <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;iPhone 4 32GB : Black&quot;</span><span style="color: #339933;">;</span>
        driver.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://stock.o2.co.uk/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//input[following-sibling::label[@title='&quot;</span> <span style="color: #339933;">+</span> modelTitle <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;']]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;locRet&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Select<span style="color: #009900;">&#40;</span>driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ukregions&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">selectByValue</span><span style="color: #009900;">&#40;</span>region<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Select<span style="color: #009900;">&#40;</span>driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;citySel&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">selectByValue</span><span style="color: #009900;">&#40;</span>city<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//div[@class='sfSubmit']/input&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">className</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;timeStamp&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
&nbsp;
        <span style="color: #000066; font-weight: bold;">int</span> stores <span style="color: #339933;">=</span> driver.<span style="color: #006633;">findElements</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id('tblStyleRetail')/tbody/tr&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;=</span> stores<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            WebElement store <span style="color: #339933;">=</span> driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;id('tblStyleRetail')/tbody/tr[&quot;</span> <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">int</span> withStock <span style="color: #339933;">=</span> store.<span style="color: #006633;">findElements</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.//img[@alt='In stock']&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</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>withStock <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; in stock at &quot;</span> <span style="color: #339933;">+</span> store.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;./td[1]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</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: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @SuppressWarnings<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;unused&quot;</span><span style="color: #009900;">&#41;</span>
    @DataProvider
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Object</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> models<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Object</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> <span style="color: #009900;">&#123;</span>
            <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;iPhone 4&quot;</span>, <span style="color: #0000ff;">&quot;16GB&quot;</span>, <span style="color: #0000ff;">&quot;Black&quot;</span> <span style="color: #009900;">&#125;</span>,
<span style="color: #666666; font-style: italic;">//          { &quot;iPhone 4&quot;, &quot;16GB&quot;, &quot;White&quot; },</span>
            <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;iPhone 4&quot;</span>, <span style="color: #0000ff;">&quot;32GB&quot;</span>, <span style="color: #0000ff;">&quot;Black&quot;</span> <span style="color: #009900;">&#125;</span>,
<span style="color: #666666; font-style: italic;">//          { &quot;iPhone 4&quot;, &quot;32GB&quot;, &quot;White&quot; },</span>
            <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;iPhone 3GS&quot;</span>, <span style="color: #0000ff;">&quot;8GB&quot;</span>, <span style="color: #0000ff;">&quot;Black&quot;</span> <span style="color: #009900;">&#125;</span>,
            <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;iPhone 3GS&quot;</span>, <span style="color: #0000ff;">&quot;16GB&quot;</span>, <span style="color: #0000ff;">&quot;Black&quot;</span> <span style="color: #009900;">&#125;</span>,
            <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;iPhone 3GS&quot;</span>, <span style="color: #0000ff;">&quot;16GB&quot;</span>, <span style="color: #0000ff;">&quot;White&quot;</span> <span style="color: #009900;">&#125;</span>,
            <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;iPhone 3GS&quot;</span>, <span style="color: #0000ff;">&quot;32GB&quot;</span>, <span style="color: #0000ff;">&quot;Black&quot;</span> <span style="color: #009900;">&#125;</span>,
            <span style="color: #009900;">&#123;</span> <span style="color: #0000ff;">&quot;iPhone 3GS&quot;</span>, <span style="color: #0000ff;">&quot;32GB&quot;</span>, <span style="color: #0000ff;">&quot;White&quot;</span> <span style="color: #009900;">&#125;</span>,
        <span style="color: #009900;">&#125;</span><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;models&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> findStock<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> model, <span style="color: #003399;">String</span> capacity, <span style="color: #003399;">String</span> colour<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">String</span> modelTitle <span style="color: #339933;">=</span> model <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> capacity <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; : &quot;</span> <span style="color: #339933;">+</span> colour<span style="color: #339933;">;</span>
        <span style="color: #003399;">String</span> modelName <span style="color: #339933;">=</span> model <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">+</span> capacity <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; (&quot;</span> <span style="color: #339933;">+</span> colour <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;)&quot;</span><span style="color: #339933;">;</span>
        driver.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://stock.o2.co.uk/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//input[following-sibling::label[@title='&quot;</span> <span style="color: #339933;">+</span> modelTitle <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;']]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;locRet&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Select<span style="color: #009900;">&#40;</span>driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;ukregions&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">selectByValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;All&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">new</span> Select<span style="color: #009900;">&#40;</span>driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;citySel&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">selectByValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;All&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//div[@class='sfSubmit']/input&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">click</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">className</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;timeStamp&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
&nbsp;
        <span style="color: #003399;">List</span> storesWithStock <span style="color: #339933;">=</span> driver.<span style="color: #006633;">findElements</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;//img[@alt='In stock']/ancestor::tr&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>storesWithStock.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>modelName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; is not in stock anywhere!<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>modelName <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; is in stock at the following &quot;</span> <span style="color: #339933;">+</span> storesWithStock.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; O2 stores:&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>WebElement store <span style="color: #339933;">:</span> storesWithStock<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</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>store.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">xpath</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;./td[1]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getText</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: #009900;">&#125;</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The current output of the <code>findStock</code> method for iPhone 4 is below:</p>
<pre>Last update 01 Jul 2010 @ 13:00 - next update due around 17:00

iPhone 4 16GB (Black) is in stock at the following 5 O2 stores:
24 The Cascades, Cascade Centre, PORTSMOUTH, Hampshire, PO1 4RJ
98 Union Street, ABERDEEN, Scotland, AB11 6BD
Unit 3 Bon Accord Centre, George Street, ABERDEEN, Scotland, AB25 1HZ
219 Union Street, ABERDEEN, Scotland, AB11 6BA
26 South Walk, CWMBRAN, Wales, NP44 1PU</pre>
<pre>Last update 01 Jul 2010 @ 13:00 - next update due around 17:00

iPhone 4 32GB (Black) is in stock at the following 5 O2 stores:
24 The Cascades, Cascade Centre, PORTSMOUTH, Hampshire, PO1 4RJ
98 Union Street, ABERDEEN, Scotland, AB11 6BD
Unit 3 Bon Accord Centre, George Street, ABERDEEN, Scotland, AB25 1HZ
219 Union Street, ABERDEEN, Scotland, AB11 6BA
26 South Walk, CWMBRAN, Wales, NP44 1PU</pre>
<p>Have fun!</p>
<p><strong>Update 1:</strong><br />
Some changes to the output, also including the datestamp of the latest update. I have also made this available here <a href="http://svn.blargon7.com/public/o2stock/">from my public svn repository</a>.</p>
<p><strong>Update 2:</strong><br />
Also available on <a href="http://github.com/davehunt/o2stock">github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/examples/get-a-new-iphone-with-help-from-selenium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Play Pacman with Selenium 2</title>
		<link>http://seleniumexamples.com/blog/examples/play-pacman-with-selenium-2/</link>
		<comments>http://seleniumexamples.com/blog/examples/play-pacman-with-selenium-2/#comments</comments>
		<pubDate>Tue, 25 May 2010 16:09:19 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Challenges]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[challenge]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[selenium 2]]></category>
		<category><![CDATA[webdriver]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=163</guid>
		<description><![CDATA[When I saw Google&#8217;s recent interactive Pacman doodle to celebrate the game&#8217;s 30th anniversary, my first thought was &#8216;Wouldn&#8217;t it be cool to automate playing Pacman using Selenium&#8217;. I know &#8211; I&#8217;m a geek! Anyway, below is my quick proof of concept using Selenium 2 alpha 4 &#8211; the latest version of Selenium 2 is [...]]]></description>
			<content:encoded><![CDATA[<p>When I saw Google&#8217;s recent <a href="http://www.google.com/pacman/">interactive Pacman doodle</a> to celebrate the game&#8217;s 30th anniversary, my first thought was &#8216;Wouldn&#8217;t it be cool to automate playing Pacman using Selenium&#8217;. I know &#8211; I&#8217;m a geek!</p>
<p><a href="http://seleniumexamples.com/blog/wp-content/uploads/2010/05/pacman10-hp.png"><img class="aligncenter size-medium wp-image-168" title="Google's Pacman Doodle" src="http://seleniumexamples.com/blog/wp-content/uploads/2010/05/pacman10-hp-300x100.png" alt="Google's Pacman Doodle" width="300" height="100" /></a></p>
<p>Anyway, below is my quick proof of concept using Selenium 2 alpha 4  &#8211; the latest version of Selenium 2 is available for download <a href="http://code.google.com/p/selenium/downloads/list">here</a>.</p>
<p><span id="more-163"></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;">tests</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.concurrent.TimeUnit</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.By</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.Keys</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.WebDriver</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.WebElement</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.openqa.selenium.firefox.FirefoxDriver</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> WebDriverScratchPad <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> PAUSE <span style="color: #339933;">=</span> <span style="color: #cc66cc;">2000</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Keys UP <span style="color: #339933;">=</span> Keys.<span style="color: #006633;">ARROW_UP</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Keys DOWN <span style="color: #339933;">=</span> Keys.<span style="color: #006633;">ARROW_DOWN</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Keys LEFT <span style="color: #339933;">=</span> Keys.<span style="color: #006633;">ARROW_LEFT</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> Keys RIGHT <span style="color: #339933;">=</span> Keys.<span style="color: #006633;">ARROW_RIGHT</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> WebElement controls<span style="color: #339933;">;</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: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">InterruptedException</span> <span style="color: #009900;">&#123;</span>
		WebDriver driver <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> FirefoxDriver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">manage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">timeouts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">implicitlyWait</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">20</span>, TimeUnit.<span style="color: #006633;">SECONDS</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		driver.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.google.com/pacman/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		controls <span style="color: #339933;">=</span> driver.<span style="color: #006633;">findElement</span><span style="color: #009900;">&#40;</span>By.<span style="color: #006633;">id</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;pcm-c&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		move<span style="color: #009900;">&#40;</span>LEFT, UP, LEFT, DOWN, LEFT, UP, LEFT, DOWN, RIGHT<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;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> move<span style="color: #009900;">&#40;</span>Keys... <span style="color: #006633;">directions</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Keys direction <span style="color: #339933;">:</span> directions<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			controls.<span style="color: #006633;">sendKeys</span><span style="color: #009900;">&#40;</span>direction<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #003399;">Thread</span>.<span style="color: #006633;">sleep</span><span style="color: #009900;">&#40;</span>PAUSE<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;">InterruptedException</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>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Try it out for yourselves, and I extend these challenges to you:</p>
<ol>
<li>Specify a distance for Pacman to travel rather than using an arbitrary pause</li>
<li>Detect if Pacman dies in his quest to eat all the pills</li>
<li>Work out the score at the end of the game</li>
</ol>
<p>All of the above should be achievable&#8230; let me know how you get on. Also let me know what high scores you achieve playing Pacman with Selenium 2!</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/examples/play-pacman-with-selenium-2/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Mozilla &amp; LinkedIn using Selenium</title>
		<link>http://seleniumexamples.com/blog/events/mozilla-linkedin-using-selenium/</link>
		<comments>http://seleniumexamples.com/blog/events/mozilla-linkedin-using-selenium/#comments</comments>
		<pubDate>Thu, 20 May 2010 08:37:45 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[meetup]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=161</guid>
		<description><![CDATA[Last night was the May Selenium Users meeting in San Francisco, where Mozilla and LinkedIn presented their use of Selenium. Adam Goucher (Selenium IDE maintainer) was there, and has provided his notes on his blog. It sounds like it was a great event, hopefully there&#8217;ll be some videos online soon!]]></description>
			<content:encoded><![CDATA[<p>Last night was the <a href="http://www.meetup.com/seleniumsanfrancisco/calendar/13311788/">May Selenium Users meeting in San Francisco</a>, where <a href="http://www.mozilla.org/">Mozilla</a> and <a href="http://www.linkedin.com/">LinkedIn</a> presented their use of Selenium. <a href="http://adam.goucher.ca/">Adam Goucher</a> (Selenium IDE maintainer) was there, and has <a href="http://adam.goucher.ca/?p=1466">provided his notes on his blog</a>. It sounds like it was a great event, hopefully there&#8217;ll be some videos online soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/events/mozilla-linkedin-using-selenium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GTAC 2010 Announced</title>
		<link>http://seleniumexamples.com/blog/events/gtac-2010-announced/</link>
		<comments>http://seleniumexamples.com/blog/events/gtac-2010-announced/#comments</comments>
		<pubDate>Fri, 23 Apr 2010 08:18:13 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[gtac]]></category>
		<category><![CDATA[meetup]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=158</guid>
		<description><![CDATA[The Google Test Automation Conference (GTAC) for 2010 has now been announced on the Google Testing Blog. This year the event will be at the Novotel in Hyderabad, India. More details can be found by following updates on the official GTAC website.]]></description>
			<content:encoded><![CDATA[<p>The Google Test Automation Conference (GTAC) for 2010 has <a href="http://googletesting.blogspot.com/2010/04/google-test-automation-conference-2010.html">now been announced on the Google Testing Blog</a>. This year the event will be at the <a href="http://www.novotelhyderabad.com/">Novotel in Hyderabad, India</a>. More details can be found by following updates on the <a href="http://www.gtac.biz/">official GTAC website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/events/gtac-2010-announced/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Survey Results from London Selenium Users</title>
		<link>http://seleniumexamples.com/blog/events/survey-results-from-london-selenium-users/</link>
		<comments>http://seleniumexamples.com/blog/events/survey-results-from-london-selenium-users/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 12:44:39 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[feedback]]></category>
		<category><![CDATA[london]]></category>
		<category><![CDATA[meetup]]></category>
		<category><![CDATA[selenium 2]]></category>
		<category><![CDATA[slides]]></category>

		<guid isPermaLink="false">http://seleniumexamples.com/blog/?p=152</guid>
		<description><![CDATA[Before holding the second London Selenium Users meetup we asked several questions of the Selenium users in London: What is your level of experience with Selenium? What do you want to know about Selenium 2? What language would you like to see Selenium 2 demos in? Below are the slides that I didn&#8217;t get time [...]]]></description>
			<content:encoded><![CDATA[<p>Before holding the second London Selenium Users meetup we asked several questions of the Selenium users in London:</p>
<ol>
<li>What is your level of experience with Selenium?</li>
<li>What do you want to know about Selenium 2?</li>
<li>What language would you like to see Selenium 2 demos in?</li>
</ol>
<p>Below are the slides that I didn&#8217;t get time to show at the event.</p>
<div style="width:425px" id="__ss_3812595"><object width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=ldnse2-survey-results-100422015012-phpapp02&#038;stripped_title=survey-results-3812595" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=ldnse2-survey-results-100422015012-phpapp02&#038;stripped_title=survey-results-3812595" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/davehunt82">davehunt82</a>.</div>
</div>
<p>In case you can&#8217;t see the slides above, the results are repeated below:</p>
<p><strong>What is your level of experience with Selenium?</strong></p>
<ol>
<li>Beginner: 44%</li>
<li>Intermediate: 46%</li>
<li>Advanced: 10%</li>
</ol>
<p><strong>What do you want to know about Selenium 2?</strong></p>
<ol>
<li>New Features: 50%</li>
<li>Migration: 20%</li>
<li>Everything: 20%</li>
<li>Grid: 10%</li>
</ol>
<p><strong>What language would you like to see Selenium 2 demos in?</strong></p>
<ol>
<li>Java: 55%</li>
<li>.NET: 26%</li>
<li>Python: 10%</li>
<li>Ruby: 3%</li>
<li>JavaScript: 3%</li>
<li>PHP: 3%</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://seleniumexamples.com/blog/events/survey-results-from-london-selenium-users/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
