Selenium test for computedStyle

I wanted to write some automated tests for CSS changes and bugs, these type of issues are quite prone to regression so re-running the tests has a large benefit.

It is possible to add new assertions to selenium via the user-extensions.js file

The following adds a test for computed style, this only works in firefox as far as I know - but some automation is better than none


//only works in firefox
Selenium.prototype.assertStyle = function(locator, text) {
var params = text.split('=', 2);

var propertyName = params[0];
var expectedValue = params[1];

Read more

Selenium UI-Elements Rollups

I wasn't 100% clear from the docs how to implement rollup rules in selenium ui-elements and searching the web didn't return much - so here's an example in case it's helpful to others.

Add this to the user-extensions.js file


var manager = new RollupManager();

manager.addRollupRule({
name: 'compare_product'
, description: 'gets to the reults on a compare product page'
, args: [
{
name: 'term'
, description: 'the aliased term name of the category'
}
, {
name: 'provider'

Read more

Selenium UI-Elements

While playing around with selenium IDE I discovered a fantatsic tool that makes test (and results) more readable while making the suite of tests easier to adapt to layout changes.

What it does is to allow you to centrally define most of the xpath (and related) statements and give page elements meaningful names.

So instead of testing for some element like

//form[@id='search-block-form']//input[@type='text']

You can test for

ui=allPages::mainSearchField()

Read more

Integrating Selenium and Hudson

Hudson http://hudson-ci.org/ is a continuous integration server - it runs and monitors 'jobs' in a way that is useful to regularly build software and report on any errors.

Selenium http://seleniumhq.org/ is a suite of tools specifically for testing web
applications - it tests the full website by automating the running of one or more browsers (so you can test all that pointy clicky ajaxy stuff)

Read more

Drupal Wishlist

Drupal has a lot of great strengths and some weaknesses

The following are the key areas of Drupal that (as a programmer) I would like to see improved.

Negative testing 

Drupal only seems to test the positive path, that is that given the right inputs you get the right results and apart from security nothing else matters.

The result of this is that incorrect inputs result in silent failures that can be very hard to debug.

Read more

Testing PHP

I had fun this weekend at the PHP London Test Fest, it was a great opportunity to learn something new and meet some great programmers.

Read more

simpletest vs phpunit

There are two main options for unit testing PHP: simpletest and phpunit

They both do a lot of the same stuff, both have the ability to run suites of tests and create mock objects.

Simpletest has a built in webTestCase which allows you to perform some integration as well as unit testing.

Read more

How sure are you that your code doesn't have bugs?

There are times you really really want to be sure your code doesn't have any bugs at all.

This is one of those times.

Read more

The Perils of virtualisation

I just read an interesting article about Windows 7 - it will include a virtual machine to run windows XP for backwards compatibility.

http://www.computerworld.com/action/article.do?command=viewArticleBasic&...

The article points out that this has the drawback of extra maintenance.

I'd have to agree with this - it's one of the big downsides of using virtual machines for testing -  with three virtual Windows' I find myslef constantly having to run updates.

Read more

Selenium IDE exports to PHP

Oh cool :-)

I just noticed that selenium IDE has the option to export tests as PHP unit tests.

This is great - the IDE is a good way to interactively build up tests by recording a set of actions and tweaking what it records. 

And being able to save them as unit tests makes it easy to integrate this with automated testing.

Interestingly they are created as PHPunit tests - not simpletest tests.

Read more