Archive for May, 2010

Automated testing and dynamic ID’s

May 5, 2010

First off, if you’ve never used the testing tools Selenium or WebTest, you should give them a try.  Each of these tools is used to generate and run scripted interaction with your Web site (i.e. Web app functional testing).

As I built a regression test for a bug I found, I needed to automate selecting an option from a drop-down. Usually the test recorders handle this for me, and I give it no thought.  The catch is, the ‘id’ of the select element could be different on any given test run.  What I really needed was to choose a select element based on its label rather than its ‘id.’

Consider this (dynamically generated) HTML fragment:

<label for="arbitraryElementId">Product</label>
<select name="productX_another_arbitrary_id" id="arbitraryElementId">
   <option>foo</option>
   <option>fizzle</option>
</select>

<label for="somethingElse">Qty</label>
<select name="qtyX_another_arbitrary_id" id="somethingElse">
   <option>10</option>
   <option>20</option>
</select>

How can I locate the correct select element without referencing them by ID?

//select[@id='???']

That would work great if I knew the ID ahead of time.  That’s where the ‘for’ attribute comes in handy:

//label[text()='Product']/@for

That will get me the for attribute of the “Product” label.  Putting it all together, it looks like this:

//select[@id=//label[text()='Product']/@for]

A Java/Ruby Developer Appreciates ColdFusion?

May 4, 2010

When I moved my family 2,500 miles to join Dave Ramsey’s web team two years ago, I joined because of my passion to help Dave reach more financially distressed people through technology. I didn’t join because his web site used ColdFusion. With more than 15 years of development experience, primarily as a Java, ActionScript, and Ruby developer, I had a relatively low opinion of ColdFusion.

However, as a member of Dave’s web team and the ColdFusion developer community, I’ve seen the truly world-class work that is being done with ColdFusion. I’ve come to appreciate ColdFusion as a worthy peer of other modern development platforms.

What changed my mind? Here are some of the contributing factors:

  • Results. As a very practical person, I observed our very successful website. It serves more than 1M unique visitors, with over 10M page views per month. A company of nearly 300 team members generates a large amount of its income from our site. As a Java developer with my nose in the air, I had never worked on a site that had even close to this much of an impact.
  • Java. ColdFusion applications compile down to Java and run as a standard Java web-app, deployable as a .war file on any Java app server. All of the scalability, flexibility, and power I was used to in my Java web-app development is available in a well-executed ColdFusion app.
  • Mach-II. We have been a Mach-II shop for several years, but we recently rebuilt our primary web site, daveramsey.com, into a 50 module Mach-II 1.8 application. We’ve found Mach-II to be an extremely powerful Model-View-Controller framework that enables us to support our growing number of users. It provides a foundation we can build on that has helped us to roll out new features quickly, without compromising a strong MVC design. (I also had the honor of meeting team Mach-II at BFusion, and found Peter, Kurt, and Matt to be an outstanding group of committed, brilliant developers. We reviewed their work on Mach-II 1.8 while we were developing our new website, and found their code to be among the best ColdFusion code around. They set the bar for outstanding quality and community support.)
  • Libraries. ColdFusion 9 added Hibernate, providing access to the same proven ORM used by leading Java and Groovy apps. The ColdSpring framework provides IoC support on par with Spring. Several automated testing libraries are available; we use MxUnit. RiaForge has 700+ additional open source ColdFusion projects. And, since ColdFusion is Java, thousands more Java libraries are available. We used the Java Topology Suite for a large internal Flex/CF/Java Map mashup application.
  • Productivity. ColdFusion is a dynamic language that runs on a JVM, offering productivity improvements over traditional Java development. From simple things like cffile, cfhttp, cfquery, and cfdump (!), to integration with the frameworks I mentioned above, I’ve found ColdFusion development to be more agile than Struts or Spring MVC.
  • Competition. I’m a huge fan of the Railo and Open BlueDragon efforts, because they provide very healthy competition to Adobe and encourage innovation. They also open CFML up to the open source community, so that developers can deploy ColdFusion applications on a completely open stack. We don’t use them here yet, but may in the future.

ColdFusion isn’t perfect — any experienced developer knows that there is no such thing. Every technology has pluses and minuses. However: real, enterprise-class, powerful, and successful applications are being built on ColdFusion. If you are like I was a couple years ago, and have a low opinion of ColdFusion based on poorly written apps or experience years ago, I’d encourage you to take a second look. You may be pleasantly surprised by what you find.