Quick update on Selenium in TestRunner mode

Ian Bicking made a good point today on the selenium-devel mailing list: the introductory Selenium documentation makes things look much more complicated than they really are. And my previous post on Selenium falls in the same trap. It's true that I focused my tutorial on the Twisted server-driven mode of Selenium, but I should have made it clear that it's really easy to get started with Selenium in TestRunner mode if you have a Web application that you need to test.

Basically, all you need to do is to either download Selenium or check it out via svn from svn://selenium.codehaus.org/selenium/scm/trunk, then copy the contents of the javascript directory (all its files and sub-directories) to a directory that can be served via your Web server.

I created a directory called selenium under the DocumentRoot directory of one of my Apache virtual servers, then I pointed my browser to http://www.mywebsite.com/selenium/TestRunner.html and I was good to go -- that is, I could see all the sample tests and start experiment with them.

Note that in the current version, many of the shipped tests will fail, unless you do the following correction: edit selenium-api.js and delete the assertLocation function, then paste these lines in its place:

* Verify the location of the current page.
Selenium.prototype.assertAbsoluteLocation = function(expectedLocation) {
assertEquals(expectedLocation, this.page().location);

* Verify the location of the current page ends with the expected location
Selenium.prototype.assertLocation = function(expectedLocation) {
var docLocation = this.page().location.toString();
assertTrue(docLocation.length == docLocation.indexOf(expectedLocation) + expectedLocation.length);

To add your own tests, start from one of the sample tests, add your HTML test file to the "tests" subdirectory and edit the tests/TestSuite.html file by adding a new row pointing to your test.

Note: in the TestRunner mode of Selenium you will only be able to test the functionality of your own Web site. You will not be able to run tests against third party sites such as Google or Amazon, due to the cross-scripting security limitation of JavaScript.

By the way, Jason Huggins is asking for suggestions for better naming the 2 main Selenium implementation/execution modes. Currently, the nomenclature is:

1) "TestRunner mode", a.k.a "HTML table-style", "FIT style", "browser driven"
2) "Driven mode", a.k.a "source code-style", "server driven"

If you have a better descriptive name for Selenium in these modes, please leave a comment.


Anonymous said…
"Note that in the current version, many of the shipped tests will fail, unless you do the following correction: edit selenium-api.js and delete the assertLocation function, then paste these lines in its place:"

Why isn't this in CVS or in the newest release? I'm lucky I found this otherwise I would have thrown Selenium to the side pretty fast.

Oh, and it still doesn't work :(
Anonymous said…
On the subject of nomenclature, I don't think the problem is as much a matter of naming as it is a matter of packaging. Treating two substantially different ways of working with Selenium as "modes" of operation is the confusing part. My recommendation is to treat FitRunner and Driven as two different products. Offer them as separate downloads. Give them separate sites or sections of the site. Unless you're a Selenium developer, the fact that FitRunner and Driven share common code is pretty irrelevant.

For example, name them "Selenium FitRunner" and "Selenium Driven". Have a section of the site devoted to each, separtely. Separate FAQs or sections within a larger "Selenium" FAQ. Separate documentation. Distribute them as follows: FitRunner only, Driven only, and FitRunner + Driven bundle.
Mircea said…
Selenium numenclature:

From what you said, the suggestive names seem to pop-up immediately (I am a newcomer to Selenium - do not hit me too hard please :))

You said:
1) "TestRunner mode", a.k.a "HTML table-style", "FITstyle", "browser driven"

So, this mode emulates an external user or customer.

Proposal: Change "TestRunner mode" to "Customer mode".

You said:
2) "Driven mode", a.k.a "source code-style", "server driven"

Proposal: Change "Driven mode" to "Programmer mode".
John Sip said…
Very interesting blog. I'm still readin' it.

BTW, I agree ;)
JA said…

I'm a complete beginner with Selenium.

When you say Download Selenium (the link youve posted is not available at the moment) do you mean Selenium Core or IDE?
Mohammed said…
I am a beginner in selenium... are there any introductory slides or whitepapers available..
please mail them across to me.
my email nadir.ise@gmail.com
Arul shaji said…
Great article with good description! thanks a lot for sharing this useful info with us.

Popular posts from this blog

Performance vs. load vs. stress testing

Dynamic DNS updates with nsupdate and BIND 9

Running Gatling load tests in Docker containers via Jenkins