Coldfusion with Selenium ant script
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.




Posted under: 


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.
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.
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!
@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 <selenese ... />
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).
This post seems to refer to an older version of Selenium. I don't believe there is any "Selenium Core" any more.
I haven't used selenium in awhile but here is the link for Selenium Core. http://seleniumhq.org/projects/core/
It is also listed here. http://seleniumhq.org/projects/
This example refers to an older version. Also, the Ant task ("selenese") only works with Selenese HTML tests. Misleadingly, the test file has an cfm extension although it technically isn't. If you want to run RC using coldfusion (java) you need a framework. Last but not least, redistributing the selenium-server.jar file without including the Apache 2.0 license is a license violation.
@Jim this post is 3 years old so it might be out of date. The file is coldfusion generating the HTML test for selenium if I remember. Nothing misleading about that. In case you wanted to generate comprensive tests for different scenerios using cf. Thanks for the info regarding the license.
Jim, you are wrong with your statement "If you want to run RC using coldfusion (java) you need a framework." I was showing how to do it with ColdFusion via HTML.
Selenium-RC allows the test automation developer to use a programming language for maximum flexibility and extensibility in developing test logic...
Selenium-RC provides an API (Application Programming Interface) and library for each of its supported languages: HTML, Java, C#, Perl, PHP, Python, and Ruby. This ability to use Selenium-RC with a high-level programming language to develop test cases also allows the automated testing to be integrated with a project’s automated build environment.
http://seleniumhq.org/docs/01_introducing_selenium.html
I'm not wrong. "I was showing how to do it with ColdFusion via HTML". Your example shows how to do it with HTML; there is not one line of CF in either file. it would be better if you called them test.html and testsuite.html because it would be less confusing. This is what used to be know as "Bot mode"
I'm looking at your "MXUnit and Selenium Remote Control" which seems an lot more on the right track; it's using MXUnit as the "framework" I referred to and is discussed here: http://seleniumhq.org/about/platforms.html#testing-frameworks
What I'm really trying to do is get this to run in the middle of the night (fired off by Hudson using Ant) or whenever so our tester can come in in the morning and look at the results. It's taken me the better part of two days so far.
Jim, Just because the example didn't contain a cfloop or other cfml doesn't mean it is "misleading". Imagine I was connected to a database, that had select box options for a form in it. If I wanted to test the form with every option, I would record one pass in the Selenium IDE, save the html, then rename it cfm, add a cfquery to grab all the select box options I would loop over the tests changing the value entered into the selected for the select after each test completes. Talk to the MXUnit team, Marc has experience with Hudson and Ant. http://groups.google.com/group/mxunit
What Im trying to say is the setup given here only allows an HTML test to be run; if you try to create a Selenium object and test by calling methods on it (ie variables.selenium.open("/"); ) it won't work using this setup (I coundn't get it to anyway) , but because these files have a .cfm extension one would think that it would. Im having a lot more luck using your MXUnit thing so thanks for that.
You should do an update blog post in regards to my original MXUnit/Selenium entry. That post also is a couple years old.
In today's competitive job market, employers are seeking to hire graduates that are highly specialized and well trained. You can't afford to waste your time with an education that won't help you get the job you want. At Centennial College, all our programs are geared for success.As part of your program, you will not only learn how to use the latest cutting edge tools, but you will also learn how to apply the latest principles from business professionals. To compliment your classroom learning, you will also get hands-on experience in the labs. Centennial's staff not only believes in providing students with the best teaching experience possible, but also to offer the best guidance and career advice.Program Overview : This program will prepare you for an exciting future as a skilled professional in the heavy equipment field. The in-school training, combined with practical on-the-job experience that is gained in the co-op work placement will provide an excellent start to an apprenticeship. Centennial offers Heavy Duty Equipment Technician and Heavy equipment courses to equip students to pursue a career in it.Successful students will earn an Ontario College Diploma, will have eight months of practical, on-the-job, co-op training at a heavy equipment facility and complete their entire Ontario Apprenticeship in-school curriculum within two years. In addition, you will take courses in advanced electrical/ electronics, logistics, plus hoisting and rigging that is only available at Centennial.To complete this program, you will spend the first eight months in school, eight months in co-op as a registered apprentice, and a final eight months in school. As part of the in-school curriculum, you will train on heavy duty equipment courses assemblies in fully-equipped heavy duty equipment labs. You will focus on applied mechanics, vehicle dynamics as well as component design and repair as it applies to the apprenticeship curriculum. In addition, you will take courses in business, English and general education. Admission Requirements : Centennial College expects students applying for admission to certificate or diploma programs to present at minimum an Ontario Secondary School Diploma (OSSD) or General Educational Development (GED) or equivalent. Possession of minimum admission requirements does not guarantee admission to the program.Non-academic Requirements : * Satisfactory results in a program admission session* Experience and mechanical aptitude* Resume may be required* English proficiency will be considered in the admission processNotes : * Students will be placed in the appropriate English level based on skills assessment results.
<a href=http://irdautrophmen.webuda.com/article.php?article=big-truck-salvage>Big truck salvage</a>
<a href=http://irdautrophmen.webuda.com/article.php?article=training-cranes>Training cranes</a>
<a href=http://irdautrophmen.webuda.com/article.php?article=enclosed-car-hauling>Enclosed car hauling</a>
<a href=http://irdautrophmen.webuda.com/article.php?article=heavy-equipment-for-sale-by-owner>Heavy equipment for sale by owner</a>
<a href=http://irdautrophmen.webuda.com/article.php?article=heavy-equipment-insurance>Heavy equipment insurance</a>