CFSelenium - A Native CFML (ColdFusion) Client Library for the Selenium WebDriver
CFSelenium is a ColdFusion Component (CFC) which provides a native client library for the Selenium WebDriver. This allows you to write tests, using CFML, which will drive a browser and verify results.
This version has dropped support for Selenium-RC and Selenium-IDE. Also the tests have been rewritten for TestBox by Ortus Solutions.
- Lucee 4.5+ or Adobe ColdFusion 11+
- TestBox if you want to run the test suite
Ensure that the standalone Selenium Server jar file is in your Java load path. You can add this to your Application.cfc to ensure the file is loaded.
this.javaSettings = { loadPaths = [ '/path/to/cfselenium/lib/selenium-server-standalone-3.4.0.jar' ] };
To create an instance of Selenium WebDriver:
selenium = new cfselenium.SeleniumWebDriver( driverType="firefox", webDriver="path/to/webdrivers/webDriverFilename" );
where webDriverFilename is the binary for the platform you are running. See the example in tests/specs/firefoxSpec.cfc
Currently the Firefox WebDrivers for both Macintosh and Windows are provided. Other browsers and operating systems will be added as test coverage increases.
Example: Get a page title.
selenium = new cfselenium.SeleniumWebDriver( driverType="firefox", webDriver="path/to/webdrivers/webDriverFilename" );
driver = selenium.getDriver();
driver.get( "https://www.google.com" );
writedump( var="#driver.getTitle()#" ); // evaluates to "Google"
driver.quit();
cd /path/to/my/webroot/ # or wherever you want to put stuff
git clone https://github.com/teamcfadvance/CFSelenium.git cfselenium
cd cfselenium
git checkout master
git clone https://github.com/Ortus-Solutions/TestBox.git testbox
cd testbox
git checkout master
One super-easy way to do tests in different CFML engines is this is to install CommandBox by Ortus Solutions , run the executable, then, within CommandBox:
cd /path/to/my/webroot/ # or wherever you'd put it
# testing in Lucee 4.5, for instance
server start cfengine=lucee@4.5 # when done testing, run `stop`
# testing in ACF 11, for instance
server start cfengine=adobe@11 # when done testing, run `stop`
That will open a browser window with a random port (e.g., 62261), after which, browse to the following to run the tests and see the results:
- Functional tests:
- WebDriver: http://localhost:62261/cfselenium/tests/
Please use the main repo's issue tracker to report bugs and request enhancements.
The script-based version of CFSelenium was created by Bob Silverberg and the tag-based version was created by by Brian Swartzfager. Marc Esher provided the logic which starts and stops the Selenium-RC server automatically. @Lampei and Jamie Jackson added WebDriver support.
Richard Herbert refactored the WebDriver approach and removed support for Selenium-RC and Selenium-IDE. The tests were rewritten using TestBox/CommandBox and MXUnit has been removed.