Brief Guide to Testing Browser Behavior with Selenium IDE and CFSelenium
Join the DZone community and get the full member experience.Join For Free
The Selenium IDE Firefox plugin makes it easy to record the actions you perform on a web pages or series of web pages as a set of commands. You simply open the Selenium IDE tool from the "Tools" menu in Firefox, make sure the Record button (the red circle in the upper right) is active, and then click and type away. Once you've stopped recording, you can re-run the the recorded steps any number of times and even save the steps as a test case file to run again later.
Fortunately, it's easy to add such statements with Selenium IDE. If the browser behavior results in a visible change to the page (like updating text in a form field), right-click on the changed part of the page. At the bottom of the context menu that appears will be several Selenium commands you can choose to add to your current recording. One or more of the commands will be a "verify" or "assert" command that you can add to your recording that basically means "return true if this page element contains this value or this text; return false if not".
Take the example below. If the user selects "College" from the first select box on the bottom line, an AJAX call is made that populates the third select box on that line with the acronyms of the various colleges. When I right-click on that third select box, I can select the verification command that verifies whether or not the select box contains all of the acronyms (you can see all of the text labels for the options in the select are concatenated together). Other verfication and assertion commands for the element you selected might also be available under the "Show All Available Commands" option at the bottom of the context menu.
If you're running CFSelenium on ColdFusion 8 or 9 in conjunction with MXUnit, you can add MXUnit debug() statements to your test cases to retrieve additional information from the test (beyond the success or failure of the verifications or assertions). For example, you could add the following line to your MXUnit test case to retrieve all of the text on the web page used in the test:
For more information about the debug() statement, consult the MXUnit documentation. For more information about what kinds of data CFSelenium can return from the test, look through the functions and read the hints in the relevant CFSelenium .cfc file (selenium.cfc for ColdFusion 9, selenium_tags.cfc for ColdFusion 7 and 8).
Published at DZone with permission of Brian Swartzfager, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.