For CFSelenium Users: An Ant Script to Transcribe Your Tests For Multiple Browsers

CFSelenium , Selenium No Comments »

The easiest way to create a CFSelenium test case is to use the Selenium IDE plugin for Firefox to compose the test, then export the test using the export formatter Bob Silverberg included in the CFSelenium.  You end up with a test that can be run the test against Firefox but can be further customized to your needs.

Of course the beauty of CFSelenium is that it lets you run those tests against browsers other than Firefox, to conduct cross-browser testing.  But who wants to create multiple copies of the original tests, or edit the test files whenever you want to check them against another browser?

Not this guy.

Read more...

Quick Tip: Displaying HTML/CFML Code in the Regular Content of a Mura Page

Mura 6 Comments »

In a previous blog post, I mentioned that I'm currently playing around with the ColdFusion-powered Mura CMS.  I'm using it to create an internal website where my team can share best coding practices and examples.

When you create a page of content in Mura, you do so using the WYSIWYG editor CKEditor.  As with most WYSIWYG editors, CKEditor has a "Source" button that lets you drop out of editor mode and view/edit the raw HTML, so I figured if I wrote the CFML code I wanted to display on my page in source mode using "<" and ">" character entity references for the angle brackets it would display properly in the public view of the page.

It seemed to work at first, but if I opened the same page again in order to edit it, Mura would convert the character entity references into the actual angle brackets within the raw HTML code, and the content would become invisible to the public.

I tried a couple of different approaches before eventually determining that I could actually type the CFML or HTML code I wanted to show in my content within WYSIWYG editor mode as long as I put a space between the first angle bracket and the first letter of the starting tag.  Apparently whatever Mura is doing to the content (and to be clear, I don't think this is necessarily a bug - I suspect there's a good reason why it does what it does) only occurs if it recognizes the string fragment as being an HTML or CFML tag, and adding that space makes the tag unrecognizable.  It makes my code examples look a little funny, but I can live with it.

If anyone else has a better workaround for this situation, please share with the group.  :)

CFSelenium News: No Need To Start Selenium Server Separately Anymore

CFSelenium , Selenium No Comments »

In my earlier blog post on how to install and run CFSelenium, my steps included directions on copying the .jar file for the Selenium-RC/Selenium Server application to an easily accessible location and then starting your CFSelenium testing session by executing that .jar file from the command line.

I'm happy to report that anyone using CFSelenium in conjunction with ColdFusion 8 or 9 can skip those particular steps.  Marc Esher (of MXUnit fame) recently contributed code to the CFSelenium project that enables CFSelenium to start the Selenium Server (if it's not already running) anytime you run a test, and stops the server once the test is complete.  This code is now part of the latest version of CFSelenium that can be download via the CFSelenium GitHub page.

Unfortunately, when I revised the tag-based, CF 7/8-friendly versions of the CFSelenium files to incorporate Marc's code and ran it against CF 7, I found that CF 7 apparently could not start and stop the Selenium Server via the new code.  So ColdFusion 7 users will still have to start Selenium Server from the command line, but otherwise CFSelenium still works in CF 7.

Integrating Mura with the Jasig Central Authentication Services (CAS)

ColdFusion , Mura 1 Comment »

I've already posted most of this information on the Mura forums, but I wanted to post it here as well for anyone looking for information on this topic.

With the blessings of my boss, I've been playing around with the ColdFusion-powered Mura content management system to see if it might be a good CMS option for us.  From what I've seen so far, Mura is a well-thought out CMS system that is both powerful and easy to use, which is a difficult balancing act.

One of the things my boss wanted me to investigate was whether or not we could tie Mura in with our single sign-on solution, which is CAS (Central Authentication Service), a Jasig project originally created at Yale.  When a user tries to access a page or a site that requires them to authenticate, they are redirected to the CAS server and enters their LDAP-based user id and password on the CAS login page.  If they successfully authenticate, the CAS server redirects them back to the original site and stores a token as a cookie in the user's browser.  If the user visits a different website secured by CAS, the cookie allows them access to that site without the need to log in again.

Mura provides a plugin architecture that allows developers to intercept certain Mura events and run their own code.  A number of Mura shops have created plugins that intercept the Mura login events in order to tie in with their in-house directory and authentication servers, but those login events are triggered by the admin and user login forms built into Mura.  I couldn't go that route:  I needed to circumvent and replace the Mura login form(s) with the CAS login form and have Mura log in the user based on the credential information returned by CAS.

After some digging into the code and some trial-and-error, I came up with a way to authenticate Mura administrators via our CAS system.

Read more...

Quick Tip: Controlling Execution Speed in CFSelenium

CFSelenium , Selenium No Comments »

When you use Selenium IDE to play back the actions you've recorded on a web page (the clicks, the text input, etc.), you can control the waiting period between the execution of each command using the slider control on the left end of the tool bar:

Speed slider control

With CFSelenium, the way that you control the time period between executions is with the setSpeed(string milliseconds) function.  Once you set the execution speed with this function, the time period between executions will remain set at that length until you use setSpeed again.  So you could set the speed once within the setUp() function of your MXUnit test case...

public void function setUp() {
    browserUrl = "http://local.test";
    selenium = new CFSelenium.selenium(browserUrl, "localhost", 4444, "*firefox");
    selenium.start();
    selenium.setTimeout(30000);
    selenium.setSpeed("1000");
}

 

...or you could alter the speed within a test case function...

public void function testFormValidation() {
    selenium.open("blah/index.cfm?event=addEditUser&userId=12");
    selenium.setSpeed("3000");
    //Now Selenium will wait 3 seconds between each of the following command statements
    selenium.type("firstName", "John");
    selenium.type("lastName", "White");
    //Setting the speed back down to 1 second
    selenium.setSpeed("1000");
    ....
}

 

Knowing how to change the speed in CFSelenium is crucial if you're testing any sort of operation that might take a second or two to update the page, like an AJAX call that populates a drop-down box:  if the next command in your test requires that drop-down box to be populated, but CFSelenium tries to run that command before the AJAX call completes, either your test will fail or you'll get an error message from Selenium.  The setSpeed function lets you slow down the execution speed so your AJAX calls have time to do their work before the next step in the test.