yeomanly

Coldfusion with Selenium ant script

2007 September 17
tags: Selenium · ColdFusion · Ant
by Mike Henke

I have been wanting to do a Selenium ant script since John Paul Ashenfelter's presentation on Testing CF applications @ CFUnited 2007.

Selenium is a test tool for web applications. It has a very simple html table structure for creating suites and tests. I use Selenenium IDE for Firefox to create initial scripts and save it as a cfm file. Then added the ColdFusion functionality such as random username generation for testing a new user process.

Please read Selenium Core documentation link. The links include installation, quick start, and concepts. The core needs to be placed somewhere under web root.

You will need the Selenium Remote Control for the selenium-server.jar but for convience I included it the zip. Within the jar, we will be accessing the SeleneseAntTask.

The seleniun_ant_task.zip includes the build.xml, selenium-server.jar, testsuite.cfm, and test.cfm

Note: I had to use selenium-remote-control-0.9.2-20070913.164243-129-dist.zip for the selenium-server.jar to solve the issues "Preparing Firefox profile…"

Directions and content of the zip:

seleniumTask folder contains build.xml and selenium-server.jar. This folder can be placed anywhere. Build.xml will need the seleiumDir and resultsDir set.

tests folder contains testSuite.cfm and test.cfm. This folder needs to be placed in the selenium core folder over the exisiting tests folder.

files:
build.xml – ant script to run Selenium test
testSuite.cfm – contains the html to reference test.cfm
test.cfm – tests http://henke.ws search

Please send me any enhancements and I'll add them to the zip.

Coldfusion with Selenium ant script

4 Responses leave one →
  1. P V
    P V PERMALINK *
    Oct 10, 2007 at 9:08 AM

    I really liked the article but I was wondering what entries should be there in the selenium-ant.properties. Also, the application I am creating the selenium scripts for run only with the Java version 1.4. What are the java requirements for the task that you have written here. If at all it uses 1.5 version can you please let me know of the change that has to be made to the task here. Help really appreciated.

  1. Mike
    Oct 10, 2007 at 12:10 PM

    Great question about Taskdef. I am learning ant but from my understanding the Taskdef command makes a task called selenium-ant.properties available to Ant thus allowing the command to work. I got the code from docs about Class SeleneseAntTask. I generally thought .properties files are used to set global variables. Example, you could have different server specifics configurations in a properties file instead of have several ants doing the same tasks with different hardcoded configurations. The jre I am using is 1.6.0_02 but I don't think this is critical.

  1. Joe FitzGerald
    Joe FitzGerald PERMALINK *
    Dec 8, 2007 at 1:23 PM

    A questions and a comment: When I tried to set this up, the tests parameter passed into the call to TestRunner ended up having the proxy address injected (http://localhost:4444/selenium-server/tests/testAll.cfm) This prevents the file from being parsed as a CFM. I can't seem to figure out how to change that anywhere. If I correct the url parameter manually (from the browser that is popped up), it all seems to work as expected. The test suite and test cases are processed by the CF engine into properly formatted HTML and then executed. And the comment...I think the first user comment may have related to Ant compatibility issues. If you are developing for JRE I must have something configured incorrectly because you seem to have other blog posts about using .cfm based tests successfully. I can only do that manually and not from within Eclipse via Ant because it won't parse the CF. Any ideas what I have configured incorrectly? In any case, thanks for contributing to the blogosphere!

  1. Shannon Holck
    Shannon Holck PERMALINK
    Jan 18, 2010 at 12:34 PM

    @PV, I don't believe you need to create/change the selenium-ant.properties. It is included in the selenium server jar. Mike's sample points the task "selenese" to the class contained in this properties file. Once it knows where to find the task, it can execute the task in ant using There's an official example here: http://release.seleniumhq.org/selenium-remote-control/0.9.0/doc/server/org/openqa/selenium/server/ant/SeleneseAntTask.html For non-Java folks, you might find it interesting to extract some of the Selenium jars (you can use any zip utility to extract the contents ... many times the javadocs are included and may be helpful).

Leave a Reply

Leave this field empty: