Selenium [L1 ] is a test tool for web applications. Selenium tests run directly in a browser, just as real users do. And they run in Internet Explorer, Mozilla and Firefox on Windows, Linux, and Macintosh.

The main difference of this test setup as compared to doing HTTP requests with Tcl's http::geturl is that there is a browser in between, so it can test browser compatibility for your server pages, as well as JavaScript and Ajax.

Selenium Remote Control [L2 ] is a test tool that allows you to write automated web application UI tests in any programming language against any HTTP website using any mainstream JavaScript-enabled browser.

Selenium WebDriver [L3 ] is an alternative to Selenium Remote Control (RC). In contrast to Selenium RC, which controls the browser by injecting JavaScript, Selenium WebDriver talks to the browser directly through a native interface.

While this mimics real world behavior better and results in a stricter separation of test framework and AUT, it requires a custom driver for different browser engines and thus may not be an option for every browser on every platform. Drivers for many common browsers are available for download from the Selenium website [L4 ].

As of September 2014, an implementation of the WebDriver API for Tcl is available as part of the Caius project.

The rest of this Wiki page deals with the more seasoned Selenium Remote Control.

Alas, as of Feb 2007 there was no Tcl driver... so I wrote one :)

It's about 100 lines of Tcl. The selenium.tcl script can be found at [L5 ]. It requires an HTTP 1.1 aware version of geturl, which I had lying around from a previous WebDAV project anyway. You can get a copy of that script from [L6 ]. ( TP Adjusted paths of selenium.tcl and http.tcl.)

Here are the comments at the start of the selenium.tcl file:

 # selenium.tcl
 #       This code implements a driver to control Selenium, an open source
 #       test tool for web applications, see
 #       This code is modeled after the Python and Ruby drivers.  It differs
 #       by not implementing each supported command separately, but instead
 #       using a default dispatch to pass commands to the Selenium server with
 #       very little modification.  This is why the commands are not called
 #       get_title, wait_for_page_to_load, etc. but with the same "camelCase"
 #       names used by Selenium itself, i.e. getTitle, waitForPageToLoad, etc.
 #       All commands known to return a list are singled out and their return
 #       string is converted before returning the result.  Since everything is
 #       a string in Tcl, no special handling is needed for numbers and booleans
 #       (boolean results will be the same as in Selenium, i.e. "true"/"false").
 # Note: This code requires a new HTTP/1.1 aware version of geturl - the current
 #       http 2.4 package in Tcl doesn't know how to keep a 1.1 connection alive
 #       and will slow down because *each* Selenium request will time out.
 # Example use:
 #       package require selenium
 #       Se init localhost 4444 *firefox
 #       Se start
 #       Se open
 #       Se type q "hello world"
 #       Se clickAndWait btnG
 #       Se assertTitle "hello world - Google Search"
 #       Se stop
 # by Jean-Claude Wippler, 2007-02-24

Note: there is a quirk with Selenium RC 0.90 and FireFox (at least on Mac OS X), which causes the Selenium proxy (written in Java) to hang on startup. AFAIK, FireFox didn't have this problem - I hope it gets fixed soon.

On Mac OS X, a workaround is to launch the Selenium proxy as follows:

    java -jar selenium-server.jar -proxyInjectionMode -browserSessionReuse

On first use, it'll launch FireFox which you then need to Quit (!). Selenium detects this and relaunches FireFox, at which point you can just keep both running (minimized, if you prefer) and they will then happily perform as many test runs as you care to throw at them. When tests fail, I generally click on FireFox's back/forward buttons a few times to let all tests finish. Otherwise you may end up having to restart both Selenium and FireFox.

Selenium includes a large set of commands, see the (older) 0.8.0 documentation at [L7 ]. So far, the new Tcl driver appears to handle all commands just fine.

A test such as "Se waitForTextPresent foo*glob*bar" is very useful when the page you're testing has Ajax background activity, since it'll actually wait for the result to appear, while the browser is doing all the async JS processing.

Note also that you can of course put all your Se calls inside tcltests.

Enjoy! -jcw

I created selenium library for the Tcl world. It's very complete. I am currently using this framework in production.