JetBrians has developed a very popular Java IDE (Integrated Development Environment) called IntelliJ, which is widely being used on OSx and Windows. This is another way to show how WebDriver works in various editors and language.
Components
You will need the following components to create and run WebDriver tests in Java.
- Java
- JUnit Test Framework
- IntelliJ
- Standalone Server Library
- Firefox Proxy
IntelliJ
IntelliJ IDEA has two versions.
- Ultimate (Commercial) – It supports a number of development scenarios.
- Community (Free) – It is used for Java VM and Android development.

You can download it from IntelliJ’s homepage for Mac, Linux, and Windows platform. It can be easily installed by just following the on-screen instructions. We will use the default settings while using IntelliJ.
Project Creation
- At the startup screen, choose ‘Create New Project’ option.

- Choose a simple Java project without selecting any library options. Click ‘Next’.

- Click ‘Next’ without selecting the ‘Create project from template’ checkbox.

- Name the project and choose the directory to save the project.

- This will take you to the home page of IntelliJ project.

Adding Standalone Server Library
You can use Maven or Gradle to add WebDriver in your IntelliJ projects. However, there are various other ways to do it.
- Download the standalone server and Java WebDriver bindings and save it to a folder.
- Go to File->Modules. Click ‘Dependencies’ and add the saved directory using the ‘+’ icon.

- The dialog will look as below.

Adding Firefox Driver Proxy
You need to add an appropriate Firefox proxy in order to talk to the browser. Since, Firefox’s driver is part of the releases of Mozilla’s Gecko Driver; you need to download the driver, according to the version of Windows (x32/x64). Extract the drivers from the zip file to a location and add the location to the system’s PATH environment variable.
Writing and Running a Simple Test
You will need test framework like JUnit to write the test cases. Add a new Java file by selecting New->Java class. Name the file and transform it into JUnit test class. You can use IntelliJ properties to import JUnit libraries.
Run the test by right-clicking context menu from the test method’s signature.
You may also like: How to use WebDriver in C# Using Visual Studio
Recent Comments