Photo from Chile

Export Selenium-IDE Scripts in CFSelenium (ColdFusion) Format

Hot on the heels of the release of CFSelenium, I have created a Firefox plugin that will allow you to export scripts from Selenium-IDE in CFSelenium format, wrapped inside an MXUnit test case. The plugin is dead simple to use, simply add the extension to your installation of Firefox and you'll see a new menu item in Selenium-IDE under File - Export Test Case As..., Options - Format and Options - Clipboard Format. The menu item is labelled CFML (ColdFusion) Selenium RC (MXUnit). Choosing this menu item will translate your current test case into CFSelenium format, wrapped in an MXUnit test case.

The Firefox extension is available in the distribution at both GitHub and RIAForge, and will hopefully be made available at SeleniumHQ once it's found to be stable. I'm sure it could use some improvements, so please give it a try and let me know what you think of it.

I was able to create the Firefox extension by basically copying and modifying the source code for the Grails Formatters created by Rob Fletcher, so a big thank you goes out to him for making the job simple and painless.

TweetBacks
Comments
When I install the plugin, Firefox says it "Requires additional items". I already have Selenium IDE installed. What else does it need?
# Posted By Tyler Wright | 2/25/11 1:55 PM
That's strange. It does require the Selenium-IDE plugin but that's it, and I've heard no other reports of installation issues. What version of the Selenium-IDE plugin do you have?
# Posted By Bob Silverberg | 2/25/11 8:01 PM
Aha! That was it. I had Selenium IDE 1.0.4 still installed. I upgraded to 1.0.10 and everything is working great! Thanks for all your work on this.
# Posted By Tyler Wright | 2/28/11 11:42 AM
Thanks for writing this, Bob. We're working on testing an existing app and happen to be getting into both Selenium and MXUnit, so this fits perfectly with what we're learning.

There was one thing I noticed initially: when I exported some existing tests to CFCs, I noticed that waitForTextPresent gets converted to a for loop, but it seems as though the for loop is coded in Java rather than CFScript (or at least I recognize the syntax from Java). The loop starts with

for( int second=0;; second++ ) {

but the int keyword is invalid there. Removing it gave me a valid script function.
# Posted By Dave DuPlantis | 6/20/11 1:16 PM
Good catch, Dave! I really just took an existing plugin and attempted to make it with with CFSelenium. There are likely cases that I didn't encounter that could be problems for others, such as this. I'll look to fix this in the next release.
# Posted By Bob Silverberg | 6/20/11 1:35 PM
FYI: A new version of CFSelenium was released that should address the problem Dave found with the Firefox formatter plugin.
# Posted By Bob Silverberg | 6/27/11 10:50 AM
Just FYI, I have not yet updated CFSelenium, but I did update Firefox 3 to version 5, without any other changes. I have an ANT script that kicks everything off, and the CF log shows "Starting HTTP Request..." followed by the URL to selenium-server/driver (as normal). The Selenium driver window opens as a new FF5 window, but then it just hangs with a white screen. No tests get run as selenium is not sending any commands. Bummer. I'll be banging my head against this one for a while.
# Posted By Steven Erat | 7/9/11 11:08 PM
Is there a timeline of when the extension may be updated to work with Firefox 5?
# Posted By Scott Stroz | 7/27/11 4:02 PM
I thought I updated my last comment, but seems I didn't.

At test runtime, Firefox 5 support is provided with Selenium 2.0, so I had to upgrade Selenium 1.3 to 2.0.

Also, I upgraded CFSelenium to 1.5 and found I had to change how I initialize selenium.cfc by passing the browseURL and browserStartCommand to selenium.start() instead of relying on the init().

Once both those changes were made, all my tests passed as normal with a few exceptions. It seems that some selectWindow("name=theWindowName") started failing. I attributed it to Selenium because when I swapped in Selenium 1.3 again the tests passed. So I coded in a workaround and all was good.

As far as the CFML Formatter for Firefox 5, presently I'm just recording in Firefox 3, then running my automation suite with Firefox 5.

Also for my fully automated QA server, I used the JavaService tool to install Selenium RC as a Windows Service so that I could leave it running unattended without being logged in. I followed this http://bit.ly/pWS7yR to create a custom bat file to perform the installation.

Jenkins is now running tests every day at 6am by kicking off the ANT file I created for each of our test suites. One job stops the SeleniumRC and CF Services, runs svnupdate, then restarts the servers, and begins the first test suite. SUPER happy with it!
# Posted By Steven Erat | 7/27/11 4:58 PM
Sorry for the delay. A new version has just been released which supports Firefox 5. You can get it at http://cfselenium.riaforge.org/.
# Posted By Bob Silverberg | 7/27/11 9:06 PM
Thanks for the very useful info Steven. I'm glad to hear it's all working well.
# Posted By Bob Silverberg | 7/27/11 9:08 PM
Thanks, this is exactly what I was looking for - I needed a way to customise the Test exporter to suite my needs, as the default WebDriver exporter makes the tests firefox-specific.

Do you perhaps know how to mass-export hundreds of tests without going through each and every one of them?
# Posted By Emanuele Ciriachi | 8/15/11 5:00 AM
I don't know of an easy way to do that, but the Firefox plugin uses some regular expressions to do some text replacing, so I imagine you could do something similar in any programming language.
# Posted By Bob Silverberg | 8/18/11 9:33 AM
I get a Selenium IDE: CFML Formatter could not be installed because it is not compatible with Firefox 7.0.1" Any idea when an updated version will come out?
# Posted By Glen Raines | 10/17/11 7:20 PM
This is an awesome tool (along with CFSelenium), but I've just downloaded FireFox and the plugin wont work with the current version (8.0.1). Not sure what needs to be done to make it compatible.
# Posted By Jon Hartmann | 12/15/11 10:58 AM
I found out how to fix the plugin: make a copy of the existing .xpi file, change the extension to .zip and open it. inside you'll find an install.rdf file. Open that in Wordpad and find the value that specifies "max version" or something like that. In my file it was set to 5.0.*, so I hacked that up to 10.0.* and saved the file. Convert the extension back and install.
# Posted By Jon Hartmann | 12/15/11 11:04 AM
I am using selenium ide, i have been successful handling pop ups in other components of my application except one.
How do i identify a pop up window opened by server?
When i click on submit button a php file validates the form and then opens pop up initiated by the server. Selenium is unable to identify the pop up, returns window doesn not exist. i have tried using different commands but unable to tackle this pop up.
# Posted By Deepak | 4/24/12 7:48 AM
@Deepak: A more appropriate place to ask that question is at http://groups.google.com/group/selenium-users.
# Posted By Bob Silverberg | 4/24/12 12:49 PM
Hi Bob,
I have posted in google groups but no reply. Issue is critical.
http://groups.google.com/group/selenium-users/brow...
# Posted By Deepak | 4/25/12 2:46 AM
i want to connect selenium ide with excel fie.
i.e i want to driven data in selenium with the help of selenium
# Posted By CCOMPAQQ | 7/9/12 3:26 AM