Tuesday, August 28, 2007

Tolerance to partial data

Yonatan and I were discussing one of our new projects today, when we had an interesting realization. One of the primary differences between the old desktop application approach and the newer "web 2.0" approach is the application's "tolerance to partial data".

In the old days, the approach was "all or nothing". Programmers would assume that the user will have patience to provide the application with a complete set of details. The application designers assumed that their application lives in a perfect world where all required data is available, and constructed their algorithms accordingly. If the user entered all the required details, she'd get a result. But the application wouldn't output anything meaningful before all the right data was entered. Bad applications would crash. Better applications would ask politely for the missing details, or provide some graphical hint that further action is required. It's not surprising that most applications were (or actually - still are) built this way, because programmers are really really used to this (e.g., try forgetting a } somewhere in your code...).

New applications - especially web applications - require a different approach. Most of today's computer users don't have the patience to provide the application with all the data it needs for a perfect result. People want results quickly, and they don't want to enter a lot of data. The good news is that people will often settle for less-than-perfect results in such cases. This means that the application can provide some of the functionality in return for some of the data. If the user really wants full results, the user will enter all the data. But the application shouldn't make this mandatory.

Why has this become especially important with web applications? Because many applications are "nice to have" - they're not crucial. In the days of the desktop, computers were mostly used for business-related applications. They were critical to the operation of the business, and people were willing to invest a lot of time providing them with data. But the web has made it possible to provide users with applications that are neat - but not critical. If users don't get to see some results quickly - they'll move over to another web site. For a "nice to have" application to be successful - it must be tolerant to partial data.

Thursday, March 8, 2007

Selenium IDE - format for CakePHP Selenium helper

This is a companion post to Daniel Hofstetter's (author of cakebaker blog), about cakephp selenium helper.

OpenQA Selenium Core is a testing framework for web applications.
Cakephp is a MVC framework for php.
SeleniumIDE is a firefox extension that allows recording and running of selenium test cases within the browser.

The Cakephp Selenium helper allows writing test cases for selenium in php code, instead of the annoying html table style "selenese". I was using it for a while before I tried out the SeleniumIDE firefox extension. I found out that it had an export capability that created code for different languages like ruby and perl, but no cakephp :(. Luckily writing a new formatter is fairly easy.

Here is the code for an implementation of a cakephp formatter. It's not perfect, and doesn't add a line for creating the testCase name, but that should be pretty easy to add:

* Parse source and update TestCase. Throw an exception if any error occurs.
* @param testCase TestCase to update
* @param source The source to parse

function parse(testCase, source) {

* Format TestCase and return the source.
* @param testCase TestCase to format
* @param name The name of the test case, if any. It may be used to
embed title into the source.

function format(testCase, name) {
var result = '<?php\n';

var commands = testCase.commands;
result += formatCommands(commands);
result += '?>';

return result;

* Format an array of commands to the snippet of source.
* Used to copy the source into the clipboard.
* @param The array of commands to sort.

function formatCommands(commands) {
var result = '';
for (var i = 0; i < commands.length; i++) {
var command = commands[i];
if (command.type == 'command') {
if (command.value !== "") {
result += '$selenium->' + command.command
+ '(\'' + command.target + '\',\'' + command.value + '\');\n';
else {
result += '$selenium->' + command.command
'(\'' + command.target + '\');\n';

return result;

* Optional: The customizable option that can be used in
format/parse functions.

//options = {nameOfTheOption: 'The Default Value'}

* Optional: XUL XML String for the UI of the options dialog

//configForm = '<textbox id="options_nameOfTheOption"/>'

To add a formatter to SeleniumIDE follow the following tutorial:

1. Open the SeleniumIDE extension, and choose options in the menu

2. Click the "add" button

3. Paste the code presented above in the textarea

4. Record your test, and then you can choose "File/Export Test As/cakephp"

And something like

$selenium->clickAndWait('link=test problem');

is generated.

If you would like to open an existing cakephp test in SeleniumIDE, you don't need to write a parser, just "open" the url for your test, for example "http://localhost/pages/tests/test1" and your testcase will generate the table that is parsed by SeleniumIDE, you can make your changes, and export it back to cakephp.

Tags: ,

Selenium Core 0.8.2 testing framework - fixing bug of pause/continue button not working properly

I was using this nifty web application testing framework (opensource) for a while before the following bug became intolerable, and I searched for a solution on google. Hopefully this blog post will save you some trouble:

After pressing the pause button, pressing continue doesn't actually resume the run, but only does a single "step" and stops again!

How to solve this bug? Edit the file /scripts/selenium-testrunner.js and find the function reset extending the object HtmlTestRunnerControlPanel, around line 345.

Remove the comment on the line:

// this.runInterval = this.speedController.value;


this.runInterval = this.speedController.value;

Voila! Pressing continue should now run smoothly.


1. Apparently they already fixed this in the trunk:

2. This is the entry in the openqa forum where I found the solution: http://forums.openqa.org/thread.jspa?threadID=6163


Sunday, March 4, 2007

The best HTML editor I have found so far (at least for Firefox)


Important update: it appears Firebug leaks memory. You'd probably wanna disable it when you're not using it.

I've been using Firebug as a problem-solving tool for quite a while. The latest release has also made it an awesome tool for getting immediate feedback on changes to the HTML.

Want to edit a page?

1) Bring up firebug (F12) and select the element you want to modify:

2) Click the new "Edit" button on Firebug's toolbar. The element's outerHtml will be loaded into the editor:

3) Edit freely. The browser will be updated as you type!


Tuesday, February 13, 2007

My SciTE settings

Wandering between computers, I often find myself downloading and configuring SciTE.

So to make life easier (for myself, at least), here are my preferred SciTE.user settings:


PHP=C:\[path to php...]\php.exe