Automating Content-based Systems
In the last 2 months I’ve managed to help a team automate a Drupal based website and done training for newspaper company that has their own setup using a combination of RoR and Perl. Even though both these systems are very different technology wise, the mindset you need to be in to automate it is exactly the same.
Step One – Identify the business driver
In both these situations, the business was generating ad views, but that is driven entirely based upon content delivery. With that figured out…
Step Two – Its all about the content
One trap I have seen sites like this fall into is that they have scripts along the lines of check that there are four headlines on the home page. That’s great and all, but remember, its the content that matter. What you want is scripts that are like check that there are four headlines on the home page and the correct headlines are displayed. This means we’re into Oracle territory.
All Selenium does is drive the browser. Everything else is up to the framework you surround it with. Which means that the framework can (should) reach into the underlying CMS to find out exactly what should be displayed. That is your scripts Oracle, not some hard-coded value embedded deep in the script.
How many headlines should be there? Well, thats easy
<pre lang="ruby">headlines = @cms.get_headlines
@selenium.get_css_count("css=ul#headlines li").should == headlines.length
And the content itself…
<pre lang="ruby">for i in (1..headlines.length)
@selenium.get_text("css=ul#headlines li:nth(#{i - 1})").should == headlines[i - 1]
end
(Or something like that.)
How do you get the content? That depends entirely on the system you are working with. For example, Drupal has the Node Export module. But it is important to have this Oracle available when doing automation, otherwise you are just doing automation for automation sake; not as a way of driving business value.