Abhinav Abhinav - 2 months ago 6x
Java Question

Why am I getting "The type is deprecated" as an error in Selenium?

I am using eclipse-jee-luna-SR1-win32-x86_64 for Selenium (the Selenium version is selenium-standalone-2.44.0 and selenium-java-2.44.0). I am getting the error

The type is deprecated
. I have JavaSE-1.8 installed on my system.

> java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

This is the code I'm using:

import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
public class FirstTestCase {
public static void main(String[] args) {
System.out.println("Hello World");
Selenium selenium = new DefaultSelenium("localhost", 5555, "chrome", "http://www.xxxxxxyxyxyx.com");


The Selenium Interface and DefaultSelenium Class both belong to Selenium 1 and are deprecated. Selenium has advanced to Selenium 2 (WebDriver) and for this reason these warning messages are displayed to encourage users to stop using old Selenium 1 code and start using Selenium 2 (WebDriver) code.

To add: This has got nothing to do with your IDE (Eclipse) or your Java version.

You will want to use the following classes as these are part of Selenium 2 (WebDriver). WebDriver is an interface used by various Selenium 2 drivers.

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

Then you have various drivers that you can use. RemoteWebDriver / HtmlUnitDriver / FireFoxDriver / ChromeDriver / IEDriverServer etc. You will want to import the driver in your Java class.

Selenium selenium = new DefaultSelenium();


WebDriver driver = new TheSpecificDriver();