Photo from Chile

My Adobe ColdFusion Developer Week Session on ORM

I was very pleased that my CF Dev Week presentation was so well attended and received. I am attaching a PDF of the presentation materials to this post. Once the recording is available, you'll be able to find it at www.adobe.com/devnet/coldfusion/events.html.

CFSelenium 1.6 - Upgrades for Selenium 2.2 and Firefox 5

A new version of CFSelenium was recently released which upgrades the bundled version of Selenium Server to version 2.2.0, and also provides Firefox 5 compatibility for the bundled Firefox plugin.

As always, the latest version is available via the CFSelenium RIAForge page and via the CFSelenium GitHub Project. The latter also includes a detailed Readme file which can help you get started using CFSelenium.

CFSelenium 1.5 - With Some Handy Helper Methods

A new version of CFSelenium was recently released which includes a few helper methods that I've found useful. First off, I'd like to thank the fine folks on the Mozilla Web QA team, from whom I borrowed the idea for these methods. I wrote a couple of tests for them in Python, and their Python base page object contains these methods. While I agree that it makes sense to include these methods in a base page object, not everyone using CFSelenium is using the Page Object Model, and as the creator and co-maintainer of CFSelenium I figured I'd just make everyone's life simpler and include them directly in the client library.

The three methods, which are waitForElementPresent, waitForElementVisible, and waitForElementNotVisible, are helpful when testing applications that make use of AJAX, or even just simple JavaScript. When you want to check that a page has responded to a user interaction, and the response is generated by JavaScript, you can often run into timing issues in your Selenium tests. If you issue a click command and then immediately include an assert with a getText command in it, it may be that the element that you are attempting to get hasn't been created by the browser yet. The same can be true when elements are shown or hidden. To address this issue the three methods mentioned above can be used, each of which is described in more detail below.

Arguments

Each of these methods accepts one required and one optional argument. The first argument, locator, is just that; the locator of the element that you want to wait for. The second, optional, argument is timeout, which is a number, in milliseconds, that you want CFSelenium to wait for the element before it throws an exception. The default value for timeout is 30000 (or 30 seconds), and this can be overridden in one of two ways. You can override the default for your entire test case by passing a value into the waitTimeout argument of CFSelenium's init method. You can also override the default on any call to any of these methods by passing a value into the second argument of the methods, which is timeout.

waitFor Methods

In case it isn't completely obvious, here is what the waitFor methods do:

  • waitForElementPresent - Waits for the specified element to be added to the DOM. If the element is not present by the end of the timeout interval an exception is thrown.
  • waitForElementVisible - Waits for the specified element to become visible. If the element is not visible by the end of the timeout interval an exception is thrown. Note that the element must be present in the DOM or the Selenium server will throw an exception immediately.
  • waitForElementNotVisible - Waits for the specified element to become hidden. If the element is still visible by the end of the timeout interval an exception is thrown.

As always, the latest version is available via the CFSelenium RIAForge page and via the CFSelenium GitHub Project. The latter also includes a detailed Readme file which can help you get started using CFSelenium.

CFSelenium 1.4 - Starts and Stops Selenium-RC Java Server For You

A new version of CFSelenium was recently released which includes an enhancement contributed by Marc Esher. In previous versions you had to manually start and stop the Selenium-RC Java server, but in this latest version CFSelenium is smart enough to start it for you, in the background, if it is not already started. You can also shut down the java server by calling the stopServer() method on the selenium.cfc component. This will only stop the Java server if CFSelenium was the one that started it.

Marc also added a base test case for MXUnit which includes code to start and stop the server. The base test case is called CFSeleniumTestCase.cfc and the code to both start the Selenium Java server, and to start a browser session is in the beforeTests() method. There is also code to stop the browser and stop the server in the afterTests() method. This will allow all of your tests to run using the same browser session, which is much faster that starting a new browser session for each individual test.

To create a test case which is based on this new base test case, just extend it and add your own beforeTests() method which sets a variable for the base url for your tests and then calls the beforeTests() method in the parent. It will look something like this:

view plain print about
1component extends="cfselenium.CFSeleniumTestCase" {
2
3    function beforeTests(){
4        // set the base url for your tests
5        browserURL = "http://github.com/";
6        super.beforeTests();
7    }
8
9    function myTest() {
10        // note that the variable selenium is available to you which refers to an instance of CFSelenium
11        selenium.open("/bobsilverberg/CFSelenium");
12        assertEquals("bobsilverberg/CFSelenium - GitHub", selenium.getTitle());
13        selenium.click("link=readme.md");
14        selenium.waitForPageToLoad("30000");
15        assertEquals("readme.md at master from bobsilverberg/cfselenium - github", selenium.getTitle());
16    }
17    
18}

If you want to use a browser other than the default (which is Firefox), you can also specify a value for the variable browserCommand which will control which browser is used.

The latest version is available via the CFSelenium RIAForge page and via the CFSelenium GitHub Project. The latter also includes a detailed Readme file which can help you get started using CFSelenium.

Slides for Introduction to Browser Automation and Testing with Selenium

cf.Objective() 2011 has come and gone, and by all accounts it was an awesome conference. I presented an Introduction to Browser Automation and Testing with Selenium, and I'm making my slides available via this blog post. You can download the PDF here.

The real meat of the session consisted of demos of Selenium-IDE, Selenium-RC and CFSelenium, so I'm not sure that you'll get much from the slides alone. If you're interested in using Selenium via ColdFusion, please visit the CFSelenium project and look over the readme file. It should give you all you need to get started writing your own functional tests with ColdFusion and Selenium.

Vitamin Sweet with Bob and Brian to Debut on CodeBass Radio Next Friday

That's right, your heard it correctly, I will be starting my second show on CodeBass Radio next week, along with my partner in crime, Brian Rinaldi.

As the name so obviously implies, Vitamin Sweet is all about new releases. Every other week we'll bring you an hour packed with songs that have recently been released. Here's your chance to keep on top of what's new and cool out there (according to Brian and me, of course). We'll be featuring the latest releases, hand-picked by one of us, from bands both new to the scene and longtime favorites. I'll be playing tunes that I like and Brian will be doing likewise, and perhaps we'll have a few tunes that get the double-B seal of approval.

So, if you love music, and are keen to hear some of the newest stuff out there, join us on Friday, April 1st at 10:00am Eastern time, on CodeBass Radio for our maiden voyage, and then tune in every other Friday at the same time. You can listen in at bit.ly/codebass or by using the awesomely cool MediaSlurp AIR app which comes bundled with a bunch of other great community streams and podcasts.

I hope to see you online next Friday morning.

CFSelenium Now Supports ColdFusion 7 and 8

Just a quick note to let you know that Brian Swartzfager has added support for ColdFusion 7 and 8 to the CFSelenium project by adding a tag-based cfc. This is now included in the latest version (1.2), which can be downloaded from the CFSelenium RIAForge page.

Brian, who will be maintaining the tag-based version, has written up a blog post about this addition to the CFSelenium project.

More Entries