I received an interesting e-mail from a person who is currently trying to test a SproutCore app he built using the Selenium framework. For those not familiar with Selenium, it is an open source test automation framework for web-based applications. Selenium has tools that allow you to record or program a set of actions that can be replayed in most of the popular browsers either through a Mozilla IDE plug-in or using a remote control framework. In any case, Selenium is great for automated feature and integration testing and can be extended for your own needs.

The issue raised by the gentleman was that he got quickly stuck when trying to perform a simple click action. If you are familiar with typical JavaScript programming in a web browser, you know that there is a set of standard events that can be invoked on a given DOM element, such as onclick, onmousedown, onmouseup and so on. You can also programmatically invoke those events using JavaScript. In the case of Selenium, when you want to click something, the framework is invoking those common events. So if you want to click on a DIV element, then that element’s click method will be invoked.

So why does the standard clicking not work in a SproutCore application? Because clicking is actually two actions: mouse down and then mouse up. Why? It’s because of the way SproutCore likes to handle events, and in order to do things like double clicking and dragging, SproutCore has to be aware of when the user first moused down and then moused up. That is why when you create a new view (custom or extended) and you want to handle events on that view, there is no click method that you can override, but you can override mouseUp and mouseDown.

Currently I’m starting to use the Selenium framework to do a lot of automated testing on a large, complex application. Because there are things that SproutCore likes to do that don’t follow the normal course of action in a typical web-based app, I’ll be capturing those hurdles and write posts about it as I go along.

In the mean time, have fun programming in SproutCore!