<?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>Wiffu &#187; javascript</title>
	<atom:link href="http://wiffu.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://wiffu.com</link>
	<description>sam keen&#039;s corner of the web</description>
	<lastBuildDate>Wed, 08 Sep 2010 16:50:28 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Some Experiments with Canvas Drag and Drop</title>
		<link>http://wiffu.com/some-experiments-with-canvas-drag-and-drop/</link>
		<comments>http://wiffu.com/some-experiments-with-canvas-drag-and-drop/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 06:06:00 +0000</pubDate>
		<dc:creator>sam keen</dc:creator>
				<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://releasethecodes.com/?p=305</guid>
		<description><![CDATA[I&#8217;ve been toying around with canvas tag and learning the ins and outs of Drag and Drop
I created a little proof of concept app that allows you to add markers to an image.  The meta about the markers (relative location, marker symbol, desc, color, etc) are stored in a DB on another server using JSONP [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been toying around with canvas tag and learning the ins and outs of Drag and Drop</p>
<p>I created a little proof of concept app that allows you to add markers to an image.  The meta about the markers (relative location, marker symbol, desc, color, etc) are stored in a DB on another server using JSONP requests.</p>
<p>See the demo <a href="http://confab.releasethecodes.com/">here</a> (FF3+ recommended)</p>
<p>The code repo is currently on <a href="http://code.google.com/p/confabulate/">google code</a></p>
<p><a href="http://confab.releasethecodes.com/"><img class="alignnone size-full wp-image-308" title="confab-screenshot1" src="http://releasethecodes.com/wp-content/uploads/2010/01/confab-screenshot1.png" alt="" width="785" height="308" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://wiffu.com/some-experiments-with-canvas-drag-and-drop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Administration Interfaces with XUL</title>
		<link>http://wiffu.com/building-administration-interfaces-with-xul/</link>
		<comments>http://wiffu.com/building-administration-interfaces-with-xul/#comments</comments>
		<pubDate>Tue, 03 Jul 2007 15:54:00 +0000</pubDate>
		<dc:creator>sam keen</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://dabbling.in/uncategorized/building-administration-interfaces-with-xul</guid>
		<description><![CDATA[I’m starting to work with mozilla and XUL again. I’ll be posting that work soon, But in the meantime I found this presentation I did back in 2005. [original post] I remember that is when I first stumbled across this strange but useful XmlHTTPRequest object and wondered if it’s use would find its way to [...]]]></description>
			<content:encoded><![CDATA[<p>I’m starting to work with mozilla and XUL again. I’ll be posting that work soon, But in the meantime I found this presentation I did back in 2005. [<a href="http://pdxphp.org/meetings/2005/febuary" title="pdxphp">original post</a>] I remember that is when I first stumbled across this strange but useful XmlHTTPRequest object and wondered if it’s use would find its way to the mainstream.</p>
<p>Took a traditional HTML admin interface for a PHP web application and transformed it into a Mozilla XUL interface. Goal is to demonstrate the benefits of using XUL to create Rich Client Application interfaces into your web apps when you have the ability to mandate the browser used (such as an admin interface).</p>
<p>Links and resources:</p>
<ul>
<li><a href="http://xul.codeelements.com/pdxphp/src/php/" target="_blank">Working Demo</a> (mozilla browsers only)</li>
<li><a href="http://xul.codeelements.com/pdxphp/phpdoc/index.html" target="_blank">Documentation and Source Code</a> (didn’t go too crazy on the docs, but you can see all the source code by viewing the files section of the tree on the left).</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://wiffu.com/building-administration-interfaces-with-xul/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenQA Selenium</title>
		<link>http://wiffu.com/openqa-selenium/</link>
		<comments>http://wiffu.com/openqa-selenium/#comments</comments>
		<pubDate>Mon, 05 Mar 2007 23:51:00 +0000</pubDate>
		<dc:creator>sam keen</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://dabbling.in/uncategorized/openqa-selenium</guid>
		<description><![CDATA[ Selenium
is a functional/acceptance testing tool for web applications.  It in in the same space as tools like

Winrunner
Quick Test Pro
Mercury TestDirector

Selenium Advantages

The core is written in javascript so it runs directly in a browser, just as real users do
Supported on OS X, Linux, and Windows
Very simple to learn and use
Open Source (Apache License 2.0)
Selenium [...]]]></description>
			<content:encoded><![CDATA[<p> <strong>Selenium</strong></p>
<p>is a functional/acceptance testing tool for web applications.  It in in the same space as tools like</p>
<ul>
<li><a href="http://www.mercury.com/us/products/quality-center/functional-testing/winrunner/">Winrunner</a></li>
<li><a href="http://www.mercury.com/us/products/quality-center/functional-testing/quicktest-professional/">Quick Test Pro</a></li>
<li><a href="http://www.mercury.com/us/products/quality-center/testdirector/works.html">Mercury TestDirector</a></li>
</ul>
<p>Selenium Advantages</p>
<ul>
<li>The core is written in javascript so it runs directly in a browser, just as real users do</li>
<li>Supported on OS X, Linux, and Windows</li>
<li>Very simple to learn and use</li>
<li>Open Source (<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>)</li>
<li><strong>Selenium Remote Control</strong>!!!</li>
</ul>
<h2 class="title">Key Components</h2>
<ul>
<li><strong>Selenium Core</strong> &#8211; The core of Selenium written in pure JavaScript/DHTML.  This is all that is required in order to start using Selenium</li>
<li><strong>Selenium IDE</strong> (Firefox Addon) &#8211; Integrated development environment for recording and playing tests.</li>
<li><strong>Selenium RC</strong> (Remote Control) &#8211; Allows you to write automated web functional/acceptance tests in any programming language.</li>
</ul>
<h1 class="title">Selenium Core</h1>
<h3>Installation</h3>
<ul>
<li><a href="http://www.openqa.org/selenium-core/download.action">Download</a> the latest release</li>
<li>Place the downloaded folder (i.e. selenium-core-0.8.2) in the webroot of the webserver with the app to be tested. This is a JavaScript security requirement, &#8216;<a href="http://www.mozilla.org/projects/security/components/same-origin.html">same origin</a>&#8216; policy.  (<em>Later in this talk we&#8217;ll explain how to get around this</em>).</li>
</ul>
<h1 class="title">Writing your First Test</h1>
<h2>Where to put the tests</h2>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_-U2xCN0FOWI/SG5cmIzDeTI/AAAAAAAAABc/l8UWloYW488/s1600-h/test-app-structure.png"><img style="margin: 0pt 10px 10px 0pt; float: left; cursor: pointer;" src="http://bp3.blogger.com/_-U2xCN0FOWI/SG5cmIzDeTI/AAAAAAAAABc/l8UWloYW488/s320/test-app-structure.png" alt="" id="BLOGGER_PHOTO_ID_5219210828435388722" border="0" /></a>The tests can really reside anywhere on the web server (just need to accessable from same domain of the app you are testing). So, just place them in the area that makes most sense for you organization wise.<br />For this example we will place them in the web app to be tested in a &#8216;tests&#8217; folder.</p>
<h2></h2>
<h2>What we will be testing</h2>
<p>For this talk I have written a VERY tiny PHP application with a simple login page. We&#8217;ll use this to test some of the aspets of Selenium.</p>
<p> <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_-U2xCN0FOWI/SG5c1dOZD7I/AAAAAAAAABk/Ou0-yyxXL3I/s1600-h/test-app-login-page.png"><img style="cursor: pointer;" src="http://bp2.blogger.com/_-U2xCN0FOWI/SG5c1dOZD7I/AAAAAAAAABk/Ou0-yyxXL3I/s320/test-app-login-page.png" alt="" id="BLOGGER_PHOTO_ID_5219211091616796594" border="0" /></a><br />
<h2>How test cases are constructed</h2>
<p>OpenQA used a very <a href="http://en.wikipedia.org/wiki/KISS_principle">KISS</a> method for creating a test case. You simply take your favorite HTML editor and create an HTML table with 3 columns (). Then add a row () for each test step (called a command).</p>
<p>The general pattern for these  command rows are <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_-U2xCN0FOWI/SG5dFRpMPrI/AAAAAAAAABs/rLcC7sm65EM/s1600-h/command-structure.png"><img style="cursor: pointer;" src="http://bp1.blogger.com/_-U2xCN0FOWI/SG5dFRpMPrI/AAAAAAAAABs/rLcC7sm65EM/s320/command-structure.png" alt="" id="BLOGGER_PHOTO_ID_5219211363385884338" border="0" /></a></p>
<p>Depending on the command, target or value can be optional or required.  (<em>more about this later</em>).</p>
<p>Below is about the simplest test possible.  It just useses the <em>open</em> <strong>command</strong> to load the browser with a <strong>value</strong> of the Login page and then uses the <em>assertTitle</em> <strong>command</strong> to verify that the title element (&lt;title&gt;) for the page has the <strong>value</strong> &#8220;Selenium Demo: login&#8221;.</p>
<p><em>Note that any table row with <> 3 columns is ignored so it can be use for commenting your tests as we do in row 1 below</em>.</p>
<p> <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_-U2xCN0FOWI/SG5dRri5NaI/AAAAAAAAAB0/XAGJk-wdJ4E/s1600-h/test-1.png"><img style="cursor: pointer;" src="http://bp3.blogger.com/_-U2xCN0FOWI/SG5dRri5NaI/AAAAAAAAAB0/XAGJk-wdJ4E/s320/test-1.png" alt="" id="BLOGGER_PHOTO_ID_5219211576497223074" border="0" /></a>
<p>This test writing syntax is refered to as &#8216;HTML <strong><em>Selenese&#8217;</em></strong></p>
<p>This file is saved in the tests folder of the app as TestLoginPageLoads.html</p>
<h1 class="title">Running Your First Test</h1>
<h2>First, need a Test Suite to house the Test Case(s)</h2>
<p><strong>Test Cases</strong> are organized into collections using <strong>Test Suites</strong>.<br />Again, in the spirit of keeping things simple, a Test Suite is an HTML<br />file with a 1 column table.  In each row of that table you put a<br />hyper-link pointing to the test you want to run.<span style="text-decoration: underline;"><br /></span></p>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_-U2xCN0FOWI/SG5dqplfh9I/AAAAAAAAAB8/_KwVVQmmsEc/s1600-h/test-suite-1.png"><img style="cursor: pointer;" src="http://bp1.blogger.com/_-U2xCN0FOWI/SG5dqplfh9I/AAAAAAAAAB8/_KwVVQmmsEc/s320/test-suite-1.png" alt="" id="BLOGGER_PHOTO_ID_5219212005467981778" border="0" /></a><span style="text-decoration: underline;"></span></p>
<p>This file is also saved in the tests directory with the name TestSuite.html</p>
<h2>Now to actually run it&#8230;</h2>
<p>Open a browser and navigate to the TestRunner file in Selenium core that you installed locally.  It is located at&#8230;</p>
<pre>{selenium-install-dir}/core/TestRunner.html</pre>
<p>You should see something simmilar to this</p>
<p> <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_-U2xCN0FOWI/SG5d8HfGaJI/AAAAAAAAACE/NHw1O_Lrhw8/s1600-h/test-runner-1.png"><img style="cursor: pointer;" src="http://bp2.blogger.com/_-U2xCN0FOWI/SG5d8HfGaJI/AAAAAAAAACE/NHw1O_Lrhw8/s400/test-runner-1.png" alt="" id="BLOGGER_PHOTO_ID_5219212305552009362" border="0" /></a>
<p>In the upper left &#8220;Test Suite:&#8221; text box, type the relative path to the &#8230;/tests/TestSuite.html file created above (/selenium-talk/tests/selenium/TestSuite.html in this case) and click the Go button</p>
<p>The Test Suite should load in the left frame and the middle frame will list the Test Cases along with their individual steps</p>
<p> <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_-U2xCN0FOWI/SG5eFCVRJPI/AAAAAAAAACM/R3VjyoHoLCU/s1600-h/test-runner-suite-loaded.png"><img style="cursor: pointer;" src="http://bp1.blogger.com/_-U2xCN0FOWI/SG5eFCVRJPI/AAAAAAAAACM/R3VjyoHoLCU/s400/test-runner-suite-loaded.png" alt="" id="BLOGGER_PHOTO_ID_5219212458787415282" border="0" /></a>
<p>Click the <img src="http://codeelements.com/sites/files/run-selected-test.png" alt="Run selected test" /> button to run this test.</p>
<p>This is a very simple test so things happen very quicly but the web app reference in the suite will load in the bottom frame and the test will interact with it there. The summary section will show the passed/failed stats for the Test Suite run and the Test Suite and Test Cases lists will colorize depending on the test outcome (green=pass / red=fail)<span style="text-decoration: underline;"><br /></span></p>
<p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_-U2xCN0FOWI/SG5eRkY4TkI/AAAAAAAAACU/_dO9wk4n3tM/s1600-h/test-runner-results.png"><img style="cursor: pointer;" src="http://bp2.blogger.com/_-U2xCN0FOWI/SG5eRkY4TkI/AAAAAAAAACU/_dO9wk4n3tM/s400/test-runner-results.png" alt="" id="BLOGGER_PHOTO_ID_5219212674087800386" border="0" /></a><span style="text-decoration: underline;"></span></p>
<p>Some examples of tests</p>
<ul>
<li><a href="http://www.openqa.org/selenium-core/selenium/TestRunner.html?test=../ajaxdemo/TestSuite.html">OpenQA AJAX tests</a></li>
<li>Selenium Tests of the <a href="http://awesnob.com/zen/">Zen Koans</a></li>
</ul>
<h1 class="title">A Closer Look at Test Cases</h1>
<h2>Commands</h2>
<p>There are 3 types of commands</p>
<h3>1 Actions</h3>
<p>example actions are click(locator), goBack(), setCursorPosition(locator,position), keyPress(locator,keySequence), dragdrop(locator,movementsString), &#8230;</p>
<p>Selenium Actions mimic the actions the user would take in interacting with the web app.</p>
<h3>2 Accessors</h3>
<p>Accessors examine the state of the applications and store the result in variables. Examples would be storeElementWidth(locator, variableName), storeBodyText(variableName), storeSelectedId(selectLocator,variableName), &#8230;</p>
<h3>3 Assertions</h3>
<p>For any given <strong>Accessor</strong> there are typically one or more related Assertions. Assertions, like Accessors, are able to examine the state of the application but instead of storing the value they retrieve, they verify that it meets a pre-defined expected value.</p>
<p>Assertions themselves com in 3 versions</p>
<ul>
<li><strong>assert</strong> &#8211; If this fails, the test is aborted</li>
<li><strong>verify</strong> &#8211; If this fails, the test will log the failure, but continue</li>
<li><strong>waitFor</strong> &#8211; These wait for the tested condition to become true. They will fail and hault the test after the the value for current timeout setting expires (see the setTimeout(timeout) Action)</li>
</ul>
<p>For example the <strong>Accessor</strong> &#8211; <strong><em>storeLocation(storageVariable) </em></strong>retrieves the absolute URL of the current page and stores it in the variable, <em>storageVariable.<br /></em>its (automatically generated) assertions are</p>
<ul>
<li><strong>assert</strong>Location ( pattern )</li>
<li><strong>assert</strong>NotLocation ( pattern )</li>
<li><strong>verify</strong>Location ( pattern )</li>
<li><strong>verify</strong>NotLocation ( pattern )</li>
<li><strong>waitFor</strong>Location ( pattern )</li>
<li><strong>waitFor</strong>NotLocation ( pattern )</li>
</ul>
<p>Note: You do not need to use an <strong>Accessor</strong> prior to using one of its related <strong>Assertions</strong>. As in our example Test Case, TestLoginPageLoads, we simply used <em>assertTitle</em> directly after the <em>open</em> command (and never used <em>storeTitle</em>).</p>
<p>There are many, many Actions, Accessors, and Assertions (and you can also easily define your own) so be sure to give the Selenium <a href="http://www.openqa.org/selenium-core/reference.html">reference</a> a good read as it details them all.</p>
<h1 class="title">Element Locators and Patterns</h1>
<p>On the previous page for the Action, Accessor, and Assertion commands, you may have noticed the references to &#8216;<em>locator</em>&#8216; and/or &#8216;<em>pattern</em>&#8216; in the parameters for those Commands.</p>
<h2>(Element) Locators</h2>
<p>The Element Locator concerns the Target that a given Command uses. They tell Selenium which HTML element a Command refers to. There are quite a few techniques the Locator can use so you are sure to find one that works for you.</p>
<p>ElementLocators are in the form: <strong><em>{locator-prefix}={locator-string}</em></strong></p>
<p>ex.</p>
<p><strong>command</strong>           <strong>target</strong>                     <strong>value</strong></p>
<p><em>verifyText</em>       <em>id=koan_body</em>       <em>*mary had a little lamb*</em></p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p><<em>following descriptions are</em> <em>from the OpenQA site</em>></p>
<ul>
<li><strong>identifier=id</strong>: Select the element with the specified @id attribute. If no match is found, select the first element whose @name attribute is id. (This is normally the default; see below.)</li>
</ul>
<ul>
<li><strong>id=id</strong>: Select the element with the specified @id attribute.</li>
</ul>
<ul>
<li><strong>name=name</strong>: Select the first element with the specified @name attribute.
<ul>
<li>username</li>
<li>name=username</li>
</ul>
</li>
</ul>
<p><em> The name may optionally be followed by one or more element-filters, separated from the name by whitespace. If the filterType is not specified, value is assumed.</em></p>
<ul>
<li>
<ul>
<li>name=flavour value=chocolate  (<em>useful for check-boxes and radio-buttons</em>)</li>
</ul>
</li>
</ul>
<ul>
<li><strong>dom=javascriptExpression</strong>: Find an element by evaluating the specified string. This allows you to traverse the HTML Document Object Model using JavaScript. Note that you must not return a value in this string; simply make it the last expression in the block.
<ul>
<li>dom=document.forms['myForm'].myDropdown</li>
<li>dom=document.images[56]</li>
<li>dom=function foo() { return document.links[1]; }; foo();</li>
</ul>
</li>
</ul>
<ul>
<li><strong>xpath=xpathExpression</strong>: Locate an element using an XPath expression.
<ul>
<li>xpath=//img[@alt='The image alt text']</li>
<li>xpath=//table[@id='table1']//tr[4]/td[2]</li>
<li>xpath=//a[contains(@href,'#id1')]</li>
<li>xpath=//a[contains(@href,'#id1')]/@class</li>
<li>xpath=(//table[@class='stylee'])//th[text()='theHeaderText']/../td</li>
<li>xpath=//input[@name='name2' and @value='yes']</li>
<li>xpath=//*[text()="right"]</li>
</ul>
</li>
</ul>
<ul>
<li><strong>link=textPattern</strong>: Select the link (anchor) element which contains text matching the specified pattern.
<ul>
<li>link=The link text</li>
</ul>
</li>
</ul>
<ul>
<li><strong>css=cssSelectorSyntax</strong>: Select the element using css selectors. Please refer to CSS2 selectors, CSS3 selectors for more information. You can also check the TestCssLocators test in the selenium test suite for an example of usage, which is included in the downloaded selenium core package.
<ul>
<li>css=a[href="#id3"]</li>
<li>css=span#firstChild + span</li>
</ul>
</li>
</ul>
<p><em>Currently the css selector locator supports all css1, css2 and css3 selectors except namespace in css3, some pseudo classes(:nth-of-type, :nth-last-of-type, :first-of-type, :last-of-type, <img src='http://wiffu.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> nly-of-type, :visited, :hover, :active, :focus, :indeterminate) and pseudo elements(::first-line, ::first-letter, ::selection, ::before, ::after).</em></p>
<p>Without an explicit locator-prefix, Selenium uses the following default strategies:</p>
<ul>
<li><strong>dom</strong>, for locators starting with &#8220;document.&#8221;</li>
<li><strong>xpath</strong>, for locators starting with &#8220;//&#8221;</li>
<li><strong>identifier</strong>, otherwise</li>
</ul>
<h2>Patterns</h2>
<p>Patterns concern the Value that a given Command is looking for.<br />Patterns are in the form <em><strong>{pattern-prefix}:{pattern}</strong></em><br />The Pattern techniques are:</p>
<ul>
<li><strong>glob</strong>:{<em>pattern</em>}
<ul>
<li>globs are simple pattern matchers.  &#8216;<strong>*</strong>&#8216; matches any sequence of characters and &#8216;<strong>?</strong>&#8216; matches any single character.</li>
</ul>
</li>
<li><strong>regex</strong>:{<em>regular-expression</em>}
<ul>
<li>The pattern matcher we know and love.  See your javascript engine for the specifics of the regex engine in use.</li>
</ul>
</li>
<li><strong>exact</strong>:{<em>literal-sting</em>}
<ul>
<li>self explanitory.</li>
</ul>
</li>
</ul>
<p>If no pattern-prefix is given then Selenium defaults to <strong>glob</strong></p>
<p>Often for simple ElementLocators you can get away with id=locator-string. For more complex locators I would recoment you get aquanted with xpath. You can go <a href="http://www.zvon.org/xxl/XPathTutorial/General/examples.html">here</a> for a good xpath tutorial and <a href="https://addons.mozilla.org/firefox/5688/author/">Viktor Zigo</a>  has written an excellent xpath <a href="https://addons.mozilla.org/firefox/1192/">firefox plugin</a>.  For Patterns use globs for simple matches and regex when you need a bit more sophisticated match.<br />You can go <a href="http://www.zvon.org/xxl/XPathTutorial/General/examples.html">here</a> for a good xpath tutorial</p>
<h1 class="title">Selenium IDE</h1>
<p>This is implemented as a Firefox add-on.  It is a graphical tool you can use to quickly record edit and debug tests.</p>
<p>It installs like any other FF plugin so go to OpenQA&#8217;s <a href="http://www.openqa.org/selenium-ide/download.action">site</a> and download and install.  Once you restart Firefox, SeleniumIDE should be listed under the tools menu.</p>
<p>To use it, simple navigate to the page in the application where you want to start testing, then go to Tools -> SeleniumIDE to launch the tool.</p>
<p> <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_-U2xCN0FOWI/SG5elZtbJmI/AAAAAAAAACc/PrqrAgJzobY/s1600-h/selenium-ide-1.png"><img style="cursor: pointer;" src="http://bp0.blogger.com/_-U2xCN0FOWI/SG5elZtbJmI/AAAAAAAAACc/PrqrAgJzobY/s400/selenium-ide-1.png" alt="" id="BLOGGER_PHOTO_ID_5219213014818563682" border="0" /></a>
<p>Selenium IDE starts in record mode so you can jsut start interacting with the browser and your actions will be recorded in the IDE. A movie is worth (a bunch) of words, so see this <a href="http://wiki.openqa.org/display/SIDE/Recording+a+Test">screen cast</a> on OpenQA&#8217;s site for a quick walk through.</p>
<p>So essentially to use the IDE to record a test</p>
<ul>
<li>After determining an <em>interaction</em> with the web application to test.</li>
<li>Navaigate (in FF) to the first page of the <em>interaction</em></li>
<li>Start the Selenium IDE</li>
<li>Follow the steps of the <em>interaction</em></li>
<li>Click the stop recored button of the IDE</li>
<li>In the Selenium Menu, go to File -> Save Test and save the test into your web app&#8217;s tests directory.</li>
<li>Add the saved test to the approprieate Test Suite.</li>
</ul>
<p>note: During the test recording, you can right-click elements in the page and get a menu showing all the available Commands for the element.</p>
<p> <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_-U2xCN0FOWI/SG5e0HJG41I/AAAAAAAAACk/PD8cTM7mq4U/s1600-h/selenium-ide-menu1.png"><img style="cursor: pointer;" src="http://bp2.blogger.com/_-U2xCN0FOWI/SG5e0HJG41I/AAAAAAAAACk/PD8cTM7mq4U/s400/selenium-ide-menu1.png" alt="" id="BLOGGER_PHOTO_ID_5219213267532440402" border="0" /></a><br />
<h1 class="title">Selenium Remote Control</h1>
<p>This quote for the OpenQA site pretty much sums up the power of Selenium RC</p>
<blockquote><p> &#8220;Selenium Remote Control is a test tool that allows you to write automated web application UI tests in <strong>any programming language</strong> against <strong>any HTTP website</strong> using <strong>any mainstream JavaScript-enabled browser</strong>.&#8221;</p>
</blockquote>
<h1 class="title">Installing SeleniumRC</h1>
<h2>Install Using PEAR</h2>
<p>On my first atempt to install the PHP client driver with PEAR I got this</p>
<pre>sudo pear install Testing_Selenium</pre>
<pre>Failed to download pear/Testing_Selenium within preferred state"stable", latest release is version 0.3.0, stability "beta",

use "channel://pear.php.net/Testing_Selenium-0.3.0" to install</pre>
<pre>Cannot initialize 'Testing_Selenium', invalid or missing package file</pre>
<pre>Package "Testing_Selenium" is not valid</pre>
<pre>install failed</pre>
<p>Selenium is still in Beta, no problem&#8230; using the suggested command worked fine.  If you have any trouble here see PEAR&#8217;s <a href="http://www.go-pear.org/manual/en/installation.cli.php">docs</a></p>
<pre>sudo pear install channel://pear.php.net/Testing_Selenium-0.3.0</pre>
<pre>downloading Testing_Selenium-0.3.0.tgz ...</pre>
<pre>Starting to download Testing_Selenium-0.3.0.tgz (2,414,300 bytes)</pre>
<pre>...........................................done: 2,414,300 bytes</pre>
<pre>install ok: channel://pear.php.net/Testing_Selenium-0.3.0</pre>
<p>Then just be sure that your PEAR directory is in your PHP <a href="http://us2.php.net/manual/en/ini.core.php#ini.include-path">include</a> path and you are good to go.</p>
<h2>Install Manually</h2>
<p>Just grab the package from <a href="http://pear.php.net/package/Testing_Selenium/download">PEAR</a> and place the Testing_Selenium-0.3.0 directory where it will be found in the PHP include_path. Also it is noted on the OpenQA site that the PHP client will be included in future releases of the SeleniumRC download ( >= 0.9.1) so that will be a second way to manually install.</p>
<h2>Source</h2>
<p>If you want to view or check out the source, you can do that&#8230;</p>
<p>you can check ou the source for SeleniumRC at</p>
<pre>svn co https://svn.openqa.org/svn/selenium-rc/trunk</pre>
<p>you can view the source at</p>
<pre>http://svn.openqa.org/fisheye/viewrep/selenium-rc/trunk</pre>
<h1 class="title">Writing the test in PHP</h1>
<p>The Code</p>
<p><textarea name="code" class="php"><br />// load the Selenium PHP client coderequire_once &#8216;Testing/Selenium.php&#8217;;<br />// Create a new Server object with Firefox as its browser type, and<br />// the given domain where the tests will occur.<br />$selenium = new Testing_Selenium(&#8220;*firefox&#8221;, &#8220;http://localhost/selenium-talk/login.php&#8221;);<br />// start the Selenium Server (This will also open the Browser)<br />$browser_session_id = $selenium->start();<br />// Open the url to start the test at<br />$selenium->open(&#8220;http://localhost/selenium-talk/login.php&#8221;);<br />// verify the Page title is &#8216;Selenium Demo App: login&#8217;<br />$page_title = $selenium->getTitle();<br />if ($page_title == &#8220;Selenium Demo App: login&#8221;) {<br />print &#8220;Title Equal: &#8216;Selenium Demo App: login&#8217;\n&#8221;;<br />} else {<br />print &#8220;Title Not Equal: &#8216;Selenium Demo App: login&#8217;\n&#8221;;<br />print &#8220;Found Title Equal: &#8221; . $page_title . &#8220;\n&#8221;;<br />}<br />// stop the server (this will also close the browser)<br />$selenium->stop();<br />?><br /></textarea><br />
<h1 class="title">The Selenium Server</h1>
<h2>Selenium Server</h2>
<p>To run your test using the PHP client (or any of the clients) you need to have the <strong>Selenium Server</strong> running in a separate process.</p>
<p>Selenium Server is a Java program and requires a JRE >= 1.5.0. You can check your version by typing java -version on the commandline.</p>
<pre>$ java -versionjava version "1.5.0_07"Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164)Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing)</pre>
<p>If you get something like &#8216;java: command not found&#8217; or your version is < href="http://java.sun.com/javase/downloads/index_jdk5.jsp">Java Runtime Environment (JRE) 5.0.</p>
<h2>Compatible Browser</h2>
<p>Best supported is Firefox and IE. If you have these installed in their default locations you should be good. If not place their corresponding executables in your OS&#8217;s PATH environment variable.</p>
<h2>Starting The Server</h2>
<p>The command to start the server is in the form java -jar {path to selenium-server.jar}. If you installed the server with PEAR, the jar file should be in your {pear install dir}/data/Testing_Selenium/</p>
<pre>$ java -jar /usr/local/php/lib/php/data/Testing_Selenium/selenium-server.jarapplication/xhtml+xmlMar 5, 2007 8:53:50 PM org.mortbay.http.HttpServer doStartINFO: Version Jetty/0.9.0Mar 5, 2007 8:53:50 PM org.mortbay.util.Container startINFO: Started HttpContext[/,/]Mar 5, 2007 8:53:50 PM org.mortbay.util.Container startINFO: Started HttpContext[/selenium-server,/selenium-server]Mar 5, 2007 8:53:50 PM org.mortbay.util.Container startINFO: Started HttpContext[/selenium-server/driver,/selenium-server/driver]Mar 5, 2007 8:53:50 PM org.mortbay.http.SocketListener startINFO: Started SocketListener on 0.0.0.0:4444Mar 5, 2007 8:53:50 PM org.mortbay.util.Container start</pre>
<pre>INFO: Started org.mortbay.jetty.Server@6672d6</pre>
<p>Just leave this server running during your tests.  There is no need to stop/start it between test runs.</p>
<h1 class="title">Running Your First PHP Test</h1>
<p>In a terminal window other than the on the server is running in. Navigate to the directory in the web app holding the test written in PHP.</p>
<p>When you run the PHP file&#8230;</p>
<pre>$ php test-login.php</pre>
<p>In the Selenium Server window you should see something like&#8230;</p>
<pre>Got result: OK,Selenium Demo App: login on session 218697GET: cmd=testComplete&amp;sessionId=218697Killing Firefox...Got result: OK on session 218697</pre>
<p>Then you should see the output of the PHP file.</p>
<pre>Title Equal: 'Selenium Demo App: login'</pre>
<p>know bug on OS X : <a href="http://jira.openqa.org/browse/SRC-225">launching FireFox</a></p>
<h1 class="title">Using SeleniumRC with xUnit Frameworks</h1>
<h2>Stitching SeleniumRC into your Testing Framework</h2>
<p>In order to make SeleniumRC more maintainable and scalable you can leverage your language&#8217;s xUnit framework (<a href="http://www.phpunit.de/">PHPUnit</a>) in this case.</p>
<p>Example PHPUint/SeleniumRC Test (from the OpenQA) site.  Notice that we are overcoming the Javascript&#8217;s &#8220;<a href="http://www.mozilla.org/projects/security/components/same-origin.html">Same Origin Policy</a>&#8220;.</p>
<p><textarea name="code" class="php"><br />selenium = new Testing_Selenium(&#8220;*firefox&#8221;, &#8220;http://www.google.com&#8221;);<br />$this->selenium->start();</p>
<p>public function tearDown()<br />{<br />  $this->selenium->stop();<br />}<br />public function testGoogle()<br />{<br />  $this->selenium->open(&#8220;/&#8221;);<br />  $this->selenium->type(&#8220;q&#8221;, &#8220;hello world&#8221;);<br />  $this->selenium->click(&#8220;btnG&#8221;);<br />  $this->selenium->waitForPageToLoad(10000);<br />  $this->assertRegExp(&#8220;/Google Search/&#8221;, $this->selenium->getTitle());<br />}<br /></textarea>
<p>With this setup, you SeleniumRC tests can easily be incorperated into an existing Unit Testing framework. The SeleniumRC test benefit from all the ease of use and scalability of the xUnit frameworks.</p>
<p>One more note, to get a headstart on building SeleniumRC tests you can use the export option of SeleniumIDE</p>
<p> <a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_-U2xCN0FOWI/SG5hiSQdXtI/AAAAAAAAACs/5sLaFt-5yiw/s1600-h/selenium-ide-export.png"><img style="cursor: pointer;" src="http://bp2.blogger.com/_-U2xCN0FOWI/SG5hiSQdXtI/AAAAAAAAACs/5sLaFt-5yiw/s400/selenium-ide-export.png" alt="" id="BLOGGER_PHOTO_ID_5219216259813301970" border="0" /></a><br />
<h1 class="title">Selenium: Further Reading, Examples</h1>
<ul>
<li>    The <a href="http://www.openqa.org/selenium/">OpenQA</a> site</li>
<li>The PHPUnit <a href="http://www.phpunit.de/pocket_guide/index.en.php">Pocket Guide</a></li>
<li>Selenium <a href="http://wiki.openqa.org/display/SEL/Publications+and+Presentations">Presentations</a></li>
<li><a href="http://www-128.ibm.com/developerworks/web/library/wa-selenium-ajax/">IBM writup</a> on Selenium</li>
<li><a href="http://www.sitepoint.com/forums/showthread.php?t=308727&amp;goto=nextnewest">Selenium + Simpletest</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://wiffu.com/openqa-selenium/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
