Setting up Selenium

I’ve just started to have a look at Selenium to automatically test web sites from Java code (and hopefully do other things). This is just a note on how to install Selenium in a few words. It’s quite easy once you’ve figured out what is relevant or not.

  • Selenium is a set of Java libraries that allow you to manage a browser from your code. (They rely on an additional native .EXE file as well; more on this later).
  • There are several things: Selenium RC, Selenium WebDriver, Selenium Server. Forget about everything except WebDriver. RC is an older version (Selenium 1.0), and you will use the server only if you do some special things. Initially, you need Selenium WebDriver (which is equivalent to say “Selenium 2.0”) and that’s it.
  • You have to download Selenium itself. It’s a .zip file (some 20 MB) with a lot of .jar files inside. Take those .jar files (all of them; there are two at the root and a bunch of them inside a directory), copy them wherever you like, and add all of them to your project build path in Eclipse (with “Add external .JARs”).
  • There is an additional thing you will need. When you try to use some “browser”, there is an external (plaftorm-native) executable that handles that browser. And you’ll have to download that executable separately, copy it to some directory of yours, and refer to it from your code. This “driver” is sometimes called “server”, because of how Selenium libraries communicate with it, but it has nothing to do with “Selenium server” as mentioned above (an unfortunate and confusing double use of the word “server”).

So, in my case, I had to do something like this:

  1. Download Selenium itself from here: In my case, I downloaded the Java version. But you can use other languages.
  2. Unpack, get the .jar and add them to the build path of muy project (add external jars).
  3. Download the Internet Explorer executable (from here:; don’t get confused if they call it “IEDriverServer” when “server” should be reserved for other uses in this context, but this is the file you need). Or maybe the Chrome executable from here: Or the Firefox, or whatever; it’s up to you which browser you want to automate.
  4. Put the executable wherever you want. And then add this line to your code:
    System.setProperty(“”, “exe/ChromeDriver/chromedriver.exe”);
    or this one:
    System.setProperty(“”, “myexefolder/IEDriver/IEDriverServer.exe”);
    or whatever, stating the relative or absolute path where your exe file is. This line must be executed before you call the constructor for the driver: WebDriver driver = new InternetExplorerDriver(); or whatever.
  5. [UPDATE] There is a “generic” browser, which comes from the HtmlUnit framework. This is a Java implementation of a non-GUI browser; it works as a browser, and emulates JavaScript as well. If you use this one, you don’t need external executables, since it’s included in the Selenium libraries, and in addition it’s cross-platform. In that case, remember that HtmlUnitDriver has JavaScript disabled by default, and you have to explicitly enable it; have a look at

That’s it. From there, you’ll be able to do things like driver.get(someUrl); and so on.




Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: