Using Selenium IDE

ALL THIS INFORMATION IS OLD AND PROBABLY OBSOLETE

Using Selenium IDE

Using Selenium IDE, it’s possible to create selenium tests without writing any java code. However, there are some limitations that I haven’t been able to figure out how to get around.

Download Selenium IDE

Selenium IDE is a Firefox extension that can be downloaded from here . Obviously you’ll need to use Firefox. Click on the Selenium IDE link and choose to install the extension. You’ll need to re-start Firefox.

Download selenium-server.jar v1.0.1

The current version of selenium server is 1.0.3, and unfortunately it doesn’t pack all the stuff you need into a single jar. I’ve attached the 1.0.1 version of this jar to this page to make this step easier.

Create test cases

After re-starting Firefox, select Selenium IDE from the Tools menu. I’m not going to go into too much detail on how to use this tool, but basically the steps are:

  1. Type the URL of the resource you want to test into the Base URL field. *Note:* Selenium can’t access files using the file: protocol. You’ll need to put your test file somewhere reachable using http.
  2. Turn on recording (the right circle button at the right of the toolbar).
  3. Click on links, etc. Use the context menu to apply different asserts. Both of these steps will create new commands in the Selenium IDE browser.
  4. In the File menu, click on Export Test Case. Export it as HTML, and save the HTML to your file system.
  5. Repeat for as many test cases as you want. Note that you can also export it as java code (for example, if you are building your code using maven and have selenium integration already).

Create test suite

For some reason, you can’t export your test suite to HTML. You’ll have to create it manually. Use this as a template, and for each test case add a row to the table:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Sample Selenium Test Suite</title>
</head>
<body>
    <table cellpadding="1" cellspacing="1" border="1">
        <thead>
            <tr><td>Test Cases</td></tr>
        </thead>
    <tbody>
        <tr><td><a href="testCase1.html">Test Case #1</a></td></tr>
        <tr><td><a href="testCase2.html">Test Case #2</a></td></tr>
    </tbody>
    </table>
</body>
</html>

Create ant task

Copy the selenium server jar to wherever you want (and update the template below). You’ll also need to update the suite and results file paths. This task will fail if one of the selenium checks fails.

<target name="selenium-test">
	<taskdef name="selenese" classname="org.openqa.selenium.server.ant.SeleneseAntTask">
	    <classpath>
	    	<pathelement location="lib/selenium-server-1.0.1jar" />
	    </classpath>
	</taskdef>
	<selenese
	    suite="test\js\testSuite.html" browser="*firefox" results="test\results.html" multiWindow="false" timeoutInSeconds="30" startURL="http://www.google.com" />
</target>

Interpreting results

The ant task will put the results file into testresults.html (or wherever you specified).

Browser Support

This works on Firefox 3.5.8, but not 3.6. Selenium 1.0.1 doesn’t work with Firefox 3.6.

Firefox 3.6 and Selenium 1.0.1

These two result in this error:

BUILD FAILED
\test\build.xml:39: Unable to delete file c:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\customProfileDir104496\parent.lock

The way to fix this is documented here . Or you can use the jar file that I have already attached to this page.

Selenium 1.0.3

By default selenium 1.0.3 supports Firefox 3.6. But there seems to be a different distribution. Instead of a single jar file, there are two: selenium-server.jar and selenium-server-coreless.jar. These are both missing the class that defines the ant selenese task (org.openqa.selenium.server.ant.SeleneseAntTask). In fact, I couldn’t find that anywhere in the 1.0.3 jars. When I created a new jar that had only that file, I ran into another problem.

I got a ClassNotFoundException for org.openqa.selenium.remote.server.DriverServlet. However, this was in one of the jar files that I was using in the classpath. It’s almost like selenium was starting jetty in a new process that didn’t have that file in it’s classpath. I wasn’t able to get this working, even after constructing my own jar file that had the server, coreless and ant tasks in it.

BUILD FAILED
org.openqa.jetty.util.MultiException[java.lang.ClassNotFoundException: org.openqa.selenium.remote.server.DriverServlet]
        at org.openqa.jetty.http.HttpServer.doStart(HttpServer.java:686)
        at org.openqa.jetty.util.Container.start(Container.java:72)
        at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:396)
        at org.openqa.selenium.server.ant.SeleneseAntTask.execute(SeleneseAntTask.java:130)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
        at org.apache.tools.ant.Main.runBuild(Main.java:758)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)
java.lang.ClassNotFoundException: org.openqa.selenium.remote.server.DriverServlet
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at org.openqa.jetty.http.HttpContext.loadClass(HttpContext.java:1227)
        at org.openqa.jetty.jetty.servlet.Holder.start(Holder.java:188)
        at org.openqa.jetty.jetty.servlet.ServletHolder.start(ServletHolder.java:219)
        at org.openqa.jetty.jetty.servlet.ServletHandler.initializeServlets(ServletHandler.java:446)
        at org.openqa.jetty.jetty.servlet.ServletHandler.doStart(ServletHandler.java:415)
        at org.openqa.jetty.util.Container.start(Container.java:72)
        at org.openqa.jetty.http.HttpContext.startHandlers(HttpContext.java:1704)
        at org.openqa.jetty.http.HttpContext.doStart(HttpContext.java:1675)
        at org.openqa.jetty.util.Container.start(Container.java:72)
        at org.openqa.jetty.http.HttpServer.doStart(HttpServer.java:708)
        at org.openqa.jetty.util.Container.start(Container.java:72)
        at org.openqa.selenium.server.SeleniumServer.start(SeleniumServer.java:396)
        at org.openqa.selenium.server.ant.SeleneseAntTask.execute(SeleneseAntTask.java:130)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:357)
        at org.apache.tools.ant.Target.performTasks(Target.java:385)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
        at org.apache.tools.ant.Main.runBuild(Main.java:758)
        at org.apache.tools.ant.Main.startAnt(Main.java:217)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:257)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:104)

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply