<?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>cakebaker &#187; selenium</title>
	<atom:link href="http://cakebaker.42dh.com/tags/selenium/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Mon, 08 Mar 2010 15:24:52 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Formats for the Selenium IDE</title>
		<link>http://cakebaker.42dh.com/2007/03/11/formats-for-the-selenium-ide/</link>
		<comments>http://cakebaker.42dh.com/2007/03/11/formats-for-the-selenium-ide/#comments</comments>
		<pubDate>Sun, 11 Mar 2007 10:42:50 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/03/11/formats-for-the-selenium-ide/</guid>
		<description><![CDATA[The Selenium IDE (a plug-in for Firefox) allows you to record tests. A guy called &#8220;wishcow&#8221; published now a format which makes it possible to export those tests for the Selenium helper. Based on his format I wrote a format for creating test cases for the Selenium test suite. You can find it (plus the [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://openqa.org/selenium-ide/">Selenium IDE</a> (a plug-in for Firefox) allows you to record tests. A guy called &#8220;wishcow&#8221; published now a <a href="http://wallsoft.blogspot.com/2007/03/selenium-ide-format-for-cakephp.html">format</a> which makes it possible to export those tests for the Selenium helper. Based on his format I wrote a format for creating test cases for the Selenium test suite. You can find it (plus the helper and the test suite) in the <a href="http://cakebaker.42dh.com/downloads">downloads section</a>,</p>
<p>The installation is simple (you can find a graphical installation guide on &#8220;wishcow&#8221;&#8217;s blog):</p>
<ul>
<li>Open the Selenium IDE</li>
<li>Select &#8220;Options&#8221;/&#8221;Options&#8230;&#8221;</li>
<li>Switch to &#8220;Formats&#8221;</li>
<li>Choose &#8220;Add&#8221;</li>
<li>Define a name and copy&#038;paste the format in the text area</li>
<li>Click on &#8220;Ok&#8221; to save it</li>
</ul>
<p>Happy testing :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/03/11/formats-for-the-selenium-ide/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Integrating OpenID into your testing environment</title>
		<link>http://cakebaker.42dh.com/2007/01/15/integrating-openid-into-your-testing-environment/</link>
		<comments>http://cakebaker.42dh.com/2007/01/15/integrating-openid-into-your-testing-environment/#comments</comments>
		<pubDate>Mon, 15 Jan 2007 14:55:55 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[openid]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/01/15/integrating-openid-into-your-testing-environment/</guid>
		<description><![CDATA[In my previous article I wrote about OpenID and CakePHP. What I didn&#8217;t knew at that time was how to integrate OpenID into my Selenium tests. 
My first approach was to create an account on http://www.myopenid.com and to define the login sequence with Selenium. It worked the first time I tried to login. But as [...]]]></description>
			<content:encoded><![CDATA[<p>In my previous <a href="http://cakebaker.42dh.com/2007/01/11/cakephp-and-openid/">article</a> I wrote about OpenID and CakePHP. What I didn&#8217;t knew at that time was how to integrate OpenID into my <a href="http://www.openqa.org/selenium/">Selenium</a> tests. </p>
<p>My first approach was to create an account on <a href="MyOpenID">http://www.myopenid.com</a> and to define the login sequence with Selenium. It worked the first time I tried to login. But as MyOpenID sets a cookie after the login, the login form was no longer shown in subsequent login approaches, and so the Selenium test failed&#8230; Maybe I could have solved this problem with Selenium, but as the entire process was rather slow I decided to look for another solution.</p>
<p>And so I found <a href="http://siege.org/projects/phpMyID/">phpMyID</a>, a single user OpenID Identity Provider. It uses HTTP digest authentication, which is a bit of a problem as you cannot fill out the login dialog shown by the browser with JavaScript (which is used by Selenium). To avoid this dialog you have to add the following snippet to the &#8220;authorize_mode&#8221; function in the MyID.php file (thanks to CJ Niemira for this tip):</p>
<pre>
// add this snippet after user_session();
$_SESSION['auth_username'] = $profile['auth_username'];
$_SESSION['auth_url'] = $profile['idp_url'];
wrap_refresh($_SESSION['post_auth_url']);
</pre>
<p>To use this script with CakePHP I put it into app/webroot and use the following snippet in my Selenium test case to log into my application:</p>
<pre>
$this-&gt;open('http://myproject.localhost/users/login');
$this-&gt;type('name=data[User][openid]', 'http://myproject.localhost/MyID.php');
$this-&gt;click('submit');
$this-&gt;waitForCondition('parent.myiframe.location.href == "http://myproject.localhost/projects"', '10000');
</pre>
<p>You can also rename the MyID.php file if you want a more descriptive name, and if you want to use multiple IDs simply copy MyID.php as often as you need. </p>
<p>Happy testing :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2007/01/15/integrating-openid-into-your-testing-environment/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preview of a new Selenium test suite</title>
		<link>http://cakebaker.42dh.com/2006/12/07/preview-of-a-new-selenium-test-suite/</link>
		<comments>http://cakebaker.42dh.com/2006/12/07/preview-of-a-new-selenium-test-suite/#comments</comments>
		<pubDate>Thu, 07 Dec 2006 17:46:19 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2006/12/07/preview-of-a-new-selenium-test-suite/</guid>
		<description><![CDATA[Some time ago I wrote about using Selenium with SimpleTest. It is a nice solution, but after working with it I had to experience that it doesn&#8217;t fit to my working style. I often forgot to start the Selenium server before running the tests, and as it is rather slow, it is not the ideal [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I wrote about using <a href="http://cakebaker.42dh.com/2006/11/16/how-to-use-selenium-with-simpletest/">Selenium with SimpleTest</a>. It is a nice solution, but after working with it I had to experience that it doesn&#8217;t fit to my working style. I often forgot to start the Selenium server before running the tests, and as it is rather slow, it is not the ideal tool for doing TDD ;-)</p>
<p>So I had to go back to the Selenium helper. But somehow it felt no longer right to place the tests in app/views/pages/tests and to write them as thtml files. And so I wrote the Selenium test suite, which uses a different approach as you will see.</p>
<p>Let&#8217;s have a look at a simple example. Before we can start with the example, we have to install the test suite (please be aware that the test suite only works with the not yet released CakePHP 1.2):</p>
<ul>
<li><a href="http://cakebaker.42dh.com/downloads">Download</a> the Zip file from the download section</li>
<li>Unpack the Zip file</li>
<li>Add the following route to app/config/routes.php:
<pre>Router::connect('/selenium/*', array('controller' =&gt; 'selenium', 'action' =&gt; 'display'));</pre>
</li>
</ul>
<p>With that we are ready to start with the example. As the tests are organized in test suites, we start with such a test suite:</p>
<pre>
// app/tests/selenium/my_test_suite.php
class MyTestSuite extends SeleniumTestSuite {
    var $title = 'My tests';

    function execute() {
        $this-&gt;addTestCase('Login', 'cases/LoginTest');
    }
}
</pre>
<p>Each file placed in app/tests/selenium is considered to be a test suite, and must extend the class SeleniumTestSuite and implement the execute() function. This function is very simple: you just add the tests to the test suite.</p>
<p>The next step is to create our test case. A test case must extend SeleniumTestCase and, as a test suite, implement the execute() function. This function contains the test logic.</p>
<pre>
// app/tests/selenium/cases/login_test.php
class LoginTest extends SeleniumTestCase {
    var $title = 'Login';
    var $fixtures = array('Users');

    function setUp() {
        echo 'setUp';
    }

    function tearDown() {
        echo 'tearDown';
    }

    function execute() {
        $this-&gt;open('http://myproject.localhost');
        $this-&gt;type('name=data[User][username]', $this-&gt;dho['username']);
        $this-&gt;type('name=data[User][password]', $this-&gt;dho['password']);
        $this-&gt;clickAndWait('submit');
        $this-&gt;verifyLocation('http://myproject.localhost/projects');
    }
}
</pre>
<p>You probably noticed the $fixtures array. It allows you to write some records to the database before the test case is executed. These records are also available in the test case (see $this-&gt;dho). Each fixture is a simple class with the same name as the database table:</p>
<pre>
// app/tests/fixtures/users.php
class Users {
    var $columns = array('id', 'username', 'password');
    var $dho = array(1, 'dho', 'geheim');
}
</pre>
<p>With that we are ready to execute the test suite. As I use the <a href="http://www.openqa.org/selenium-ide/">Selenium IDE</a>, I just have to enter the following url in Firefox to load the test suite: </p>
<pre>
chrome://selenium-ide/content/selenium/TestRunner.html?test=http://myproject.localhost/selenium/MyTestSuite
</pre>
<p>And the tests can be executed :)</p>
<p>Please keep in mind that it is just a preview, so it is possible that some things will change in future versions. As always your feedback is welcome :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/12/07/preview-of-a-new-selenium-test-suite/feed/</wfw:commentRss>
		<slash:comments>66</slash:comments>
		</item>
		<item>
		<title>How to use Selenium with SimpleTest</title>
		<link>http://cakebaker.42dh.com/2006/11/16/how-to-use-selenium-with-simpletest/</link>
		<comments>http://cakebaker.42dh.com/2006/11/16/how-to-use-selenium-with-simpletest/#comments</comments>
		<pubDate>Thu, 16 Nov 2006 09:39:52 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[simpletest]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2006/11/16/how-to-use-selenium-with-simpletest/</guid>
		<description><![CDATA[Up to now there was no PHP support for Selenium Remote Control, i.e. you couldn&#8217;t integrate your Selenium tests with a testing framework like SimpleTest. On PEAR there is now a package called Testing_Selenium which makes it easy to use PHP and Selenium Remote Control together. To use them you need PHP5 and a JRE [...]]]></description>
			<content:encoded><![CDATA[<p>Up to now there was no PHP support for <a href="http://www.openqa.org/selenium-rc/">Selenium Remote Control</a>, i.e. you couldn&#8217;t integrate your Selenium tests with a testing framework like <a href="http://www.lastcraft.com/simple_test.php">SimpleTest</a>. On PEAR there is now a package called <a href="http://pear.php.net/package/Testing_Selenium">Testing_Selenium</a> which makes it easy to use PHP and Selenium Remote Control together. To use them you need PHP5 and a JRE (Java Runtime Environment) version 1.5 or higher. The installation itself is simple. Here the installation instructions for CakePHP:</p>
<ul>
<li><a href="http://pear.php.net/package/Testing_Selenium/download">Download</a> the package</li>
<li>Put Selenium.php to your &#8220;vendors&#8221; folder</li>
<li>Create a folder &#8220;Testing&#8221; in your &#8220;vendors&#8221; folder</li>
<li>Put the &#8220;Selenium&#8221; folder from the archive to the &#8220;Testing&#8221; folder</li>
<li>Put selenium-server.jar to a folder of your choice</li>
</ul>
<p>Ok, as the installation is done, let&#8217;s write a simple testcase. We want to verify that the title of the cake website is correct.</p>
<pre>
vendor('Selenium');

class SeleniumTest extends UnitTestCase
{
    function setUp()
    {
        $this-&gt;selenium = new Testing_Selenium("*firefox /usr/lib/firefox/firefox-bin", "http://cakephp.org");
        $result = $this-&gt;selenium-&gt;start();
    }

    function tearDown()
    {
        $this-&gt;selenium-&gt;stop();
    }

    function testCakePHPTitle()
    {
        $this-&gt;selenium-&gt;open("/");
        $this-&gt;assertEqual('CakePHP : the rapid development php framework', $this-&gt;selenium-&gt;getTitle());
    }
}
</pre>
<p>What does this do? In the setUp() function we start a Firefox browser (we could also use a different browser). With that browser we open in the test function the cake homepage and get the page title. And in tearDown() we close the browser.</p>
<p>Before we can run this test, we have to start the Selenium server with:</p>
<pre>
java -jar selenium-server.jar
</pre>
<p>Now, we should get a green bar when we run the test. </p>
<p>Happy testing :)</p>
<p>Update (2006-11-29): If you don&#8217;t want to put the exception class to the vendors folder, you can replace in Selenium.php </p>
<pre>
require_once 'Testing/Selenium/Exception.php';
</pre>
<p>with</p>
<pre>
class Testing_Selenium_Exception extends Exception {}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/11/16/how-to-use-selenium-with-simpletest/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>New Selenium helper</title>
		<link>http://cakebaker.42dh.com/2006/10/04/new-selenium-helper/</link>
		<comments>http://cakebaker.42dh.com/2006/10/04/new-selenium-helper/#comments</comments>
		<pubDate>Wed, 04 Oct 2006 08:58:24 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[helper]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://cakebaker.42dh.com/2006/10/04/new-selenium-helper/</guid>
		<description><![CDATA[Some days ago I wrote about writing an overloadable helper. If you want to see a real-world helper which uses that approach, check out the new Selenium helper for Selenium 0.8. It uses that approach because I am too lazy to define all the assert, assertNot, verify, verifyNot, waitFor and waitForNot functions ;-) And it [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago I wrote about <a href="http://cakebaker.42dh.com/2006/10/01/writing-an-overloadable-helper/">writing an overloadable helper</a>. If you want to see a real-world helper which uses that approach, check out the new <a href="http://bakery.cakephp.org/articles/view/80">Selenium helper</a> for <a href="http://www.openqa.org/selenium-core/">Selenium 0.8</a>. It uses that approach because I am too lazy to define all the assert, assertNot, verify, verifyNot, waitFor and waitForNot functions ;-) And it makes the helper more &#8220;compact&#8221; (with still more than 60 functions).</p>
<p>All new functions of the Selenium helper are marked with &#8220;@since 0.8&#8243;. There are also functions which were removed (including the related assert, assertNot, etc. functions): </p>
<ul>
<li>storeAbsoluteLocation</li>
<li>storeSelected</li>
<li>storeSelectedOptions</li>
</ul>
<p>If you encounter any problems with that helper, please let me know. Otherwise, happy testing :)</p>
<p>Related posts: <a href="http://cakebaker.42dh.com/tags/selenium">http://cakebaker.42dh.com/tags/selenium</a></p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/10/04/new-selenium-helper/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Overcoming the limitations of Selenium Core</title>
		<link>http://cakebaker.42dh.com/2006/07/29/overcoming-the-limitations-of-selenium-core/</link>
		<comments>http://cakebaker.42dh.com/2006/07/29/overcoming-the-limitations-of-selenium-core/#comments</comments>
		<pubDate>Sat, 29 Jul 2006 13:02:25 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=235</guid>
		<description><![CDATA[While working with Selenium Core I encountered a limitation as I tried to do a payment with PayPal: it is not possible to visit another domain from within your tests. The reason is the &#8220;Same Origin Policy&#8221; which applies to Selenium Core according to &#8220;Which Selenium Tool Should I Use?&#8221;:

Selenium Core needs to be installed [...]]]></description>
			<content:encoded><![CDATA[<p>While working with <a href="http://www.openqa.org/selenium-core/">Selenium Core</a> I encountered a limitation as I tried to do a payment with PayPal: it is not possible to visit another domain from within your tests. The reason is the <a href="http://www.mozilla.org/projects/security/components/same-origin.html">&#8220;Same Origin Policy&#8221;</a> which applies to Selenium Core according to <a href="http://wiki.openqa.org/pages/viewpage.action?pageId=763">&#8220;Which Selenium Tool Should I Use?&#8221;</a>:</p>
<blockquote><p>
Selenium Core needs to be installed on the same website as the Application Under Test (AUT), because of the Same Origin Policy, a security policy which prevents cross-site scripting. That means that you can&#8217;t just sit down and write a Selenium Core test that runs on google.com; to do that, you&#8217;d need to install Selenium Core on google.com. If you can&#8217;t/won&#8217;t install Selenium Core into your AUT, making it publicly visible on the same server as the AUT, then Selenium Core may not be right for you.
</p></blockquote>
<p>On <a href="http://wiki.openqa.org/pages/viewpage.action?pageId=763">&#8220;Which Selenium Tool Should I Use?&#8221;</a> we find an alternative, which allows us to visit another domain from within our tests: <a href="http://www.openqa.org/selenium-ide/">Selenium IDE</a>, a plug-in for Firefox. The only thing that changes is the way the tests are called. Instead of calling</p>
<pre>

http://project1.localhost/selenium/TestRunner.html?

test=/pages/tests/testsuite-all
</pre>
<p>we have to call in Firefox</p>
<pre>
chrome://selenium-ide/content/selenium/TestRunner.html?
test=http://project1.localhost/pages/tests/testsuite-all
</pre>
<p>to run the tests.</p>
<p>You find more information about CakePHP and Selenium on <a href="http://cakebaker.wordpress.com/tag/selenium">http://cakebaker.wordpress.com/tag/selenium</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/07/29/overcoming-the-limitations-of-selenium-core/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New versions of the Selenium helper</title>
		<link>http://cakebaker.42dh.com/2006/05/22/new-versions-of-the-selenium-helper/</link>
		<comments>http://cakebaker.42dh.com/2006/05/22/new-versions-of-the-selenium-helper/#comments</comments>
		<pubDate>Mon, 22 May 2006 13:49:05 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=194</guid>
		<description><![CDATA[There are two new versions of the Selenium helper available.
Version 0.2 is a bug fix release. It was created by Felix Geisendörfer, and fixes a XPath problem with Internet Explorer. Thanks Felix!
Version 0.3 supports the new release of Selenium (version 0.7.0). A lot of new functions have been added (such functions are marked with &#8220;@since [...]]]></description>
			<content:encoded><![CDATA[<p>There are two new versions of the <a href="http://www.openqa.org/selenium/">Selenium</a> helper available.</p>
<p><a href="http://cakeforge.org/snippet/detail.php?type=packagever&amp;id=20">Version 0.2</a> is a bug fix release. It was created by <a href="http://thinkingphp.org">Felix Geisendörfer</a>, and fixes a XPath problem with Internet Explorer. Thanks Felix!</p>
<p><a href="http://cakeforge.org/snippet/detail.php?type=packagever&amp;id=22">Version 0.3</a> supports the new release of Selenium (version 0.7.0). A lot of new functions have been added (such functions are marked with &#8220;@since 0.7&#8243; in the source code of the helper). Especially the testing of Ajax functionality has become easier with all the new waitFor functions. </p>
<p>If you update to the new version of Selenium, please be aware that the functions store() and pause() have been removed!</p>
<p>The update process is simple (if you are new to Selenium, see also <a href="http://cakebaker.wordpress.com/2006/03/22/selenium/">http://cakebaker.wordpress.com/2006/03/22/selenium/</a>):</p>
<ol>
<li><a href="http://www.openqa.org/selenium-core/download.action">Download</a> Selenium</li>
<li>Copy the content of the core folder in the zip file to app/webroot/selenium</li>
<li>Replace the helper</li>
<li>Execute your tests</li>
</ol>
<p>Happy testing :)</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/05/22/new-versions-of-the-selenium-helper/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>File upload with Selenium</title>
		<link>http://cakebaker.42dh.com/2006/03/29/file-upload-with-selenium/</link>
		<comments>http://cakebaker.42dh.com/2006/03/29/file-upload-with-selenium/#comments</comments>
		<pubDate>Wed, 29 Mar 2006 12:22:56 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tip]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=154</guid>
		<description><![CDATA[In my Selenium tests I want to upload some files. However, due to security restrictions in the browser a JavaScript cannot fill in a path in the respective file input field by default. Fortunately, there exists a workaround (originally from http://lists.public.thoughtworks.org/pipermail/selenium-users/2005-March/000213.html).
In FireFox enter &#8220;about:config&#8221; in the address bar, and set the value of &#8220;signed.applets.codebase_principal_support&#8221; to [...]]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://seleniumhq.org/">Selenium</a> tests I want to upload some files. However, due to security restrictions in the browser a JavaScript cannot fill in a path in the respective file input field by default. Fortunately, there exists a workaround (originally from http://lists.public.thoughtworks.org/pipermail/selenium-users/2005-March/000213.html).</p>
<p>In FireFox enter &#8220;about:config&#8221; in the address bar, and set the value of &#8220;signed.applets.codebase_principal_support&#8221; to &#8220;true&#8221;. This allows non-signed scripts to request higher privileges. </p>
<p>In Selenium we then have to request the privilege to upload local files by adding the following JavaScript snippet to the function &#8220;Selenium.prototype.doType&#8221; in the file &#8220;selenium-api.js&#8221;:</p>
<pre>
<code>netscape.security.PrivilegeManager.enablePrivilege('UniversalFileRead');</code>
</pre>
<p>Update 2009-01-04: Fixing links, fixing problem with quotes which got messed up by WordPress.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/03/29/file-upload-with-selenium/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Selenium</title>
		<link>http://cakebaker.42dh.com/2006/03/22/selenium/</link>
		<comments>http://cakebaker.42dh.com/2006/03/22/selenium/#comments</comments>
		<pubDate>Wed, 22 Mar 2006 18:20:34 +0000</pubDate>
		<dc:creator>cakebaker</dc:creator>
				<category><![CDATA[cakephp]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.cakebaker.42dh.com/?p=148</guid>
		<description><![CDATA[In the last days I experimented with Selenium (thanks to knoebi for the hint). What is Selenium? Here the description from the website:

Selenium is a test tool for web applications. Selenium tests run directly in a browser, just as real users do.

I have to admit that I like Selenium, and so I will describe in [...]]]></description>
			<content:encoded><![CDATA[<p>In the last days I experimented with Selenium</a> (thanks to knoebi for the hint). What is Selenium? Here the description from the website:</p>
<blockquote><p>
Selenium is a test tool for web applications. Selenium tests run directly in a browser, just as real users do.
</p></blockquote>
<p>I have to admit that I like Selenium, and so I will describe in this post how to use it with CakePHP. </p>
<p>First the installation:</p>
<ul>
<li>Download Selenium from <a href="http://www.openqa.org/selenium-core/download.action">http://www.openqa.org/selenium-core/download.action</a> (I recommend to download the newest version)</li>
<li>If you downloaded version 0.6 of Selenium: Copy the &#8220;selenium&#8221; folder from the zip to your &#8220;app/webroot&#8221; folder</li>
<li>If you downloaded version 0.7.0 of Selenium: Copy the content of the &#8220;core&#8221; folder from the zip to &#8220;app/webroot/selenium&#8221;</li>
<li>Download the code snippets from the <a href="http://cakebaker.42dh.com/downloads">download section</a> and put the files in the correct folders</li>
</ul>
<p>So, with that we are ready to write our first, very simple Selenium test case. </p>
<p>Test cases are organized in test suites, so we create first such a test suite in &#8220;app/views/pages/tests/&#8221;. You may wonder why we create the test suite in a subfolder of &#8220;views&#8221;. The reason is simple: Selenium tests are written in plain html. Here is our test suite:</p>
<pre>
&lt;?php
// testsuite-login.thtml
    $selenium-&gt;suiteTitle('My first testsuite');
    $selenium-&gt;addTestCase('Login', 'test_login');
?&gt;
</pre>
<p>Let us write our test case. We want to test if we can login into our application and if we are redirected to the correct page. The code should be self-explanatory (if not, please write a comment or have a look in the <a href="http://www.openqa.org/selenium/seleniumReference.html">Selenium reference</a>)</p>
<pre>
&lt;?php
// test_login.thtml
	$selenium-&gt;caseTitle('Login'); 

	$selenium-&gt;open('/login');
	$selenium-&gt;type('name=data[User][username]', 'dho');
	$selenium-&gt;type('name=data[User][password]', 'test');
	$selenium-&gt;clickAndWait('submit');
	$selenium-&gt;assertLocation('/users/dho');
	$selenium-&gt;assertTextPresent('Daniel Hofstetter');
?&gt;
</pre>
<p>That&#8217;s it, we are ready to run our test suite. For doing that, we have to switch to our browser and type http://localhost/selenium/TestRunner.html?test=/pages/tests/testsuite-login (if you have several test suites and you do not want to remember such long urls you can edit &#8220;app/webroot/selenium/index.html&#8221; and add the urls there. The only url you have to remember in this case is http://localhost/selenium). On the right side we have to click on the &#8220;All&#8221; button and the test starts. Yeah, everything is green, at least here ;-)</p>
<p>Update (2006-05-26): Download link for Selenium modified, added instructions for Selenium 0.7.</p>
<p>Update (2006-11-06): For Selenium 0.8 you can find instructions at <a href="http://cakebaker.42dh.com/2006/10/04/new-selenium-helper/">http://cakebaker.42dh.com/2006/10/04/new-selenium-helper/</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://cakebaker.42dh.com/2006/03/22/selenium/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
	</channel>
</rss>
