The latest version of Selenium WebDriver, 2.48 has been released. You can get the direct link for the downloads for the Selenium Server and the Java and C# bindings below. The changelogs for each, as well as other language bindings can be found on the Selenium Downloads page
The latest version of Selenium WebDriver, 2.47.0 has been released. You can get the direct link for the downloads for the Selenium Server and the Java and C# bindings below. The changelogs for each, as well as other language bindings can be found on the Selenium Downloads page
The latest version of Selenium WebDriver, 2.46.0 has been released. You can grt the direct link for the downloads for the Selenium Server and the Java and C# bindings below. The changelogs for each, as well as other language bindings can be found on the Selenium Downloads page
For something as simple as checking a checkbox you would think that all the different browser drivers would implement this in the same way. But sadly this is not the case. Firefox expects that you click on a checkbox to check or uncheck it whereas both the IEDriver and ChromeDriver expect you to type a space to do the same. This is all well and good for running a simple once off test, but we cant be expected to change code and re-build every time we want to test in a different browser.
Thankfully there is a solution at hand. Once we know which browser is currently running the test, we can decide which method to use. I have provided a C# and a Java code snippet below:
IWebElement checkbox = driver.FindElement(By.Id("ElementID"));
if (((RemoteWebDriver)driver).Capabilities.BrowserName == "firefox")
// Chrome and IE
WebElement checkbox = driver.findElement(By.id("idOfTheElement");
If you come across any other discrepancies between the different driver implementations let us know in the comments.
Here is a sample WebDriver Java test using the JUnit framework:
import static org.junit.Assert.*;
public class WebDriverTest1
private WebDriver driver;
public void setup() throws Exception
driver = new FirefoxDriver();
public void teardown() throws Exception
public void WebDriverTips()
String title = driver.getTitle();
assertEquals("Title mismatch", "WebDriver Tips", title);
As we can see from my earlier C# Example, there isn’t a world of difference between the two. There is no corresponding Test Fixture attribute but there are attributes for Before, After and Test. Similar to NUnit, the Before method gets executed before every test case, and the After method gets executed after every test case. Each test case is indicated with the @Test annotation.
There are a couple of setup steps required before you can run a Java JUnit WebDriver test on your Mac. As always there are a number of different ways this can be done but I will outline one that has worked well for me. I’ll just outline the steps involved first and then go through each of them in a little more detail after:
- Download and install “Eclipse IDE for Java EE Developers”
- Download and install Java
- Download JUnit
- Download and install Apache Ant
- Download Selenium WebDriver
- Create Project and lib folders
- Configure the build path (in Eclipse)
(1) Download and install “Eclipse IDE for Java EE Developers”
Go to http://www.eclipse.org and click on the downloads link. From this page download and install “Eclipse IDE for Java EE Developers”
(2) Download and install Java
- Setup $JAVAHOME
- Setup $CLASSPATH
- Verify your Java installation by using
(3) Download JUnit
Download the following JAR files from http://www.junit.org/ :
(4) Download and install Apache Ant
Download and install Apache Ant. For further details on this please see my earlier post on Installing Ant. You can also find a link to Apache Ant page from my Resources page.
Don’t forget to verify your installation with
(5) Download Selenium WebDriver
Download the following two JAR file from Selenium HQ Downloads: (see link in the Resources page.)
- WebDriver jar file
- Java Bindings jar file
(6) Create Project and lib folders
Eclipse uses a folder called a “workspace” in which all of its projects are located. On first opening Eclipse you will be prompted to specify a default workspace.
Inside this folder create a folder for your project. Inside this project folder create a “lib” folder and add the 4 JAR files you have downloaded earlier. Note you will have to unzip the Java Bindings zip file to get the seelnium-java JAR file.
(7) Configure the build path (in Eclipse)
Right click on the project name, and select Build Path > Configure Build Path. When the dialog is displayed, click on the button for Add External JARs.
From here select the 4 JAR files (hamcrest, junit, selenium-java & selenium-server-standalone) we have added to the /Workspace/Project/lib folder in the previous step.
And that concludes the basic setup required to run Java/JUnit Selenium WebDriver tests on your Mac. You are now ready to create and run a Selenium WebDriver Java test using the JUnit framework. In the next post I will create a simple test and execute it from within Eclipse and also from the Command Line/Terminal using Ant.
A new version of WebDriver has been released on September 9th.
Java: Download – Changelog
C#: Download – Changelog
The C# NuGet packages have also been update to version 2.43
For further language bindings, documentations and information you can find the link to the Selenium HQ Download page on the Resources page.
Is your JUnit Assert class now deprecated? Well here’s how to fix it. JUnit have moved things around, and as a result the Assert class is now in a different location as and from JUnit 4.11
But fear not, rectifying this is a simple one-liner. Simply change your import statement from