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.
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 http://selenium.openqa.org/ # # 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 http://www.google.com/webhp # Se start # # Se open http://www.google.com/webhp # 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 22.214.171.124 (at least on Mac OS X), which causes the Selenium proxy (written in Java) to hang on startup. AFAIK, FireFox 126.96.36.199 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.
I created selenium library for the Tcl world. It's very complete. I am currently using this framework in production. https://sourceforge.net/projects/selenium-tcl