Setting up Selenium in Eclipse IDE is very simple.
Just like another Java project, create a new project in Eclipse IDE.
- Inside Eclipse select the menu item File > New > Project.... to open the New Project wizard
- Select Java Project then click Next to start the Open the new Java project wizard New Java Project wizard:
- On this page,
- type "JUnit" in the Project name field, and
- select "J2SE-1.4" in the Use an execution environment JRE field.
- Then click Finish.
- In the Package Explorer, expand the JUnit project and select the source folder src.
- Select the menu item File > Import...
- Expand General, select Archive file, and click Next.
- Click the Browse button next to the Archive file field and browse to select
- Note: This step assumes that you followed steps 1 and 2 in the Getting the Sample Code section above.
- In the Import wizard, expand the root node, press Deselect All and select only the JUnit node. You can expand and select elements within the JUnit directory on the left pane to view the individual resources that you are importing in the right pane. Note: Do not deselect any of the resources in the JUnit directory at this time. You will need all of these resources in the tutorial.
- Make sure that the JUnit project's source folder appears in the destination Into folder field. Then click Finish. In the import progress indicator, notice that the imported resources are compiled as they are imported into the workbench. This is because the Build automatically option is checked on the Workbench preferences page.
- In the Package Explorer view, expand the JUnit project and the src folder to view the JUnit packages.
So, now you have a basic project setup ready.
You can now download(http://www.seleniumhq.org/download/) and add Selenium libraries to your Eclipse project.
Below are steps to add your Selenium JARs to the Eclipse project.
- Eclipse -> Preferences -> Java -> Build Path -> User Libraries -> New(Name it) -> Add external Jars
- (I recommend dragging your new libraries into the eclipse folder before any of these steps to keep everything together, that way if you reinstall Eclipse or your OS you won't have to link anything except the JDK) Now select the jar files you want. Click OK.
- Right-click on your project and choose Build Path -> Add Library
- FYI just code and then right click and Source->Organize Imports