Selenium webdriver using Eclipse

To start selenium scripting with Eclipse, you need to first install Java Development Kit (JDK) Download and Install Java

Installing eclipse is very easy, First download eclipse . The downloaded file should be a .zip file. Place it in a folder and ensure that you have full read and write permissions. Try to create a shortcut of the eclipse executable file.

You can check in Eclipse from Window->Preferences options, if java is installed and configured successfully on Eclipse. You can also check the java version from command prompt, enter 'java -version' which will display the java version installed on your machine.
Now we will start creating our first program in selenium using java from Eclipse Editor.

Now start writing First example to launch Firefox browser using Selenium Webdriver java

1.Create new Java Project
[From top menu file->New->Project/Java Project and enter the project name]

2.Create a new Package under Project
[Give any name to the package]

3.Create a new Java class file under the Package
[Give a name to the class]

4. Next add the selenium server Jar files to the Project. Download Selenium Server
[Right click on the Project Name, Mouse over on Build Path and select 'Configure Build Path', Select Libraries tab, Click on Add External Jars and select the selenium server jar from your local machine]

Selenium Firefox Example

5.Write the script in the Java and execute it by right clicking on the program and Run as Java Program.

NOTE: If you are using selenium 3, please use GeckoDriver to launch Firefox browser

Please find the below example program to open Google in Firefox browser

package com.easy;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class OpenGoogle {
	public static void main(String args[]) {

		WebDriver driver = new FirefoxDriver();
		System.out.println("Hello Google...");
		driver.get("http://google.com");

	}
}

Make sure always download latest version of selenium and supported Firefox version until there is no specific requirement to execute on particular version. You may have compatibility issues which you need check if any issues arises when working.

Selenium Tutorials: 

Comments

what all is needed to work with eclipse and webdriver.
please instruct into steps

Hi, while executing the program, I am getting error on step - instantiate the browser.
"Webdriver can not be resolved to Type"

am i missing something.

It seems you have not added jar file in build path.

Right click your project and click on build path.. Then go to library and click on add external jar..
Browse to the path of server.jar file and thyen ok

Does not
1) Get "Firefox has stopped working" popup, so I select "Close the program'
2) Firefox browser appears with no menu and New Tab (also nothing in address field), so I close the browser.
3) After short time get NotConnectedException

Was able to get InternetExplorerDriver to work using internal and external URLs and passing proxy variables to JVM, but this doesn't seem to work for the FirefoxDriver. I actually want to use HtmlUnitDriver but that one is only working on internal URLs. This all all new for me but seems like problem is related to use of "automatic proxy configuration URL" and getting it to work with anonymous instance of browser? Am using version 38 of FF and latest version of Selenium. Was just using simple examples to just validate the access. Any comments would be appreciated. Thank you.

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:

I am getting this error how to resolve this error

I am getting launch browser error
org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:

How to resolve the below exception

Exception in thread "main" java.lang.IllegalStateException: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
at com.google.common.base.Preconditions.checkState(Preconditions.java:199)
at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:109)
...

Looks like the exception is with the Selenium 3 (Latest Version of Selenium).

To work with Selenium 3, you should first download 'GeckoDriver' and set the System property with webdriver.gecko.driver.

Syntax - System.setProperty("webdriver.gecko.driver", geckoDriverPath);

This is the same way as we run webdriver with Chrome browser and Internet explorer.

Refer this and replace gecko driver in the place of chrome driver
https://www.seleniumeasy.com/selenium-tutorials/how-to-run-webdriver-in-...

I have used the above code.It is working fine, but when I wrote other url inplace of google Its not navigate to that page.

I am getting launch browser error.

Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:

Add new comment

Image CAPTCHA