How-to-use-IntelliJ-IDE-amp_-Selenium-Webdriver-min

How to use IntelliJ IDE & Selenium Webdriver

Table of Contents

IntelliJ IDEA is a powerful Java Integrated Development Environment (IDE) widely used for software development, designed to help developers code more efficiently and with higher quality. Known for its intelligent code assistance, debugging tools, and seamless integration with various development frameworks, IntelliJ supports developers in writing cleaner, optimized code at a faster pace.

It streamlines the entire coding process, from initial setup to deployment, with a suite of productivity-enhancing features like code refactoring, smart completion, and real-time error detection, making it a preferred choice for both beginner and experienced Java developers.

What is IntelliJ?

IntelliJ is an integrated development environment (IDE) created and maintained by JetBrains, designed specifically to support various aspects of software development.

It offers comprehensive tools for coding, importing, modeling, and deploying software projects, providing a streamlined environment that enhances productivity and code quality across multiple programming languages and frameworks.

It is available in two versions, namely:

  • Community Version (Free and Open-Source)
  • Commercial Version (Licensed Version)

It provides services like advanced code refactoring capabilities and code navigation.

Advantages of IntelliJ

  1. It supports multiple languages like Javascript, Java, etc
  2. It supports multiple Operating Systems like Linux, Windows, etc. which can be downloaded from JetBrains website.
  3. For object attributes it generates setter and getter methods.
  4. It generates inbuilt packaging tools like Grunt, SBT, gradle, bower, etc.
  5. Databases like ORACLE, SQL, Microsoft SQL Server, PostgreSQL can be accessed directly from IDE.

Pre-requisites required for IntelliJ with Selenium Webdriver

We need following Pre-requisites for IntelliJ with Selenium Webdriver

  • IntelliJ
  • Any browser
  • JDK (Java Development Kit)
  • Selenium jar files

Download & Install IntelliJ

Step1: Go to the official website https://www.jetbrains.com/idea/download/#section=windows. And select the desired version of your choice. Here we are selecting “Community” version which is a Free and Open-Source. You can download “Ultimate” version for Web, mobile and enterprise development.

How to use IntelliJ IDE & Selenium Webdriver

Step2: You can see a message like below while downloading.

How to use IntelliJ IDE & Selenium Webdriver

Step3: Click on the Downloaded folder as shown below

How to use IntelliJ IDE & Selenium Webdriver

Step4: Click on the ‘Next’ button in the setup wizard.

How to use IntelliJ IDE & Selenium Webdriver

Step5: Click on ‘Next’ button and Browse your destination folder.

How to use IntelliJ IDE & Selenium Webdriver

Step6: In this step

  1. Check the checkbox – 64-bit launcher
  2. Check the checkbox for language as per your requirement
  3. Click on ‘Next’ button
How to use IntelliJ IDE & Selenium Webdriver

Step7: Click on ‘Install’ button

How to use IntelliJ IDE & Selenium Webdriver

You can see the progress as IntelliJ installing.

How to use IntelliJ IDE & Selenium Webdriver

Step8: In this step,

  1. To run IntelliJ, check the checkbox ‘Run IntelliJ IDEA Community Edition and
  2. Click the ‘Finish’ button
How to use IntelliJ IDE & Selenium Webdriver

Step9: Click the checkbox ‘I confirm that I have read and accept the terms of this User Agreement’ and click ‘Continue’ button.

How to use IntelliJ IDE & Selenium Webdriver

Step 10: Click on Skip Remaining and Set Defaults to set plugin setting.

How to use IntelliJ IDE & Selenium Webdriver

Step 11: In this step, select the option like create a new project, import project, open, etc. as per your choice.

How to use IntelliJ IDE & Selenium Webdriver

Configure IntelliJ to Support Selenium

Follow the below steps to configure IntelliJ IDE

Step 1: Launch IntelliJ IDE. Select File -> New -> Project and click on New to make a new Project.

How to use IntelliJ IDE & Selenium Webdriver

Step2: A new screen will open when we click on Next button and give the project name and Click on Finish button. Your project has been created in IntelliJ.

How to use IntelliJ IDE & Selenium Webdriver

Enter the Project Name as and click Finish button

How to use IntelliJ IDE & Selenium Webdriver

Step3: Now add the Selenium’s .jar files into intelliJ as external libraries. Click on File-> Project Structure.

How to use IntelliJ IDE & Selenium Webdriver

Go to Modules and click on Dependencies.

How to use IntelliJ IDE & Selenium Webdriver

Click on ‘+’ Sign -> Select for JARs or directories in a project setting tab.

How to use IntelliJ IDE & Selenium Webdriver

Step 4: Select all the selenium .jar files from the directory and subdirectory /lib.

How to use IntelliJ IDE & Selenium Webdriver

By now, you should have added the required .jar files into IntelliJ. When you check your project structure, you’ll see that the external libraries are accessible, but the /src folder is still empty.

This shows that while dependencies are configured, the source directory doesn’t contain any code files yet. You can now add or import source files into the /src folder to start using the libraries and continue with development.

Step 5: Expand the Project and Right Click on /src directory -> Click on New -> Java Class and your project structure will look as below.

How to use IntelliJ IDE & Selenium Webdriver
How to use IntelliJ IDE & Selenium Webdriver

Example

We will use the site http://www.facebook.com/.

In this test scenario

  • We will launch the URL
  • Enter Invalid Email ID
  • Enter Password
  • Click the Log In button
  • The output will be as shown below- ‘Email id is not valid’

Program

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class SeleniumTest {

        public static void main(String[] args) {
            System.setProperty("webdriver.chrome.driver", "F:\\drivers\\chromedriver.exe");
            //create chrome instance
            driver = new ChromeDriver();
            driver.get("http://www.facebook.com/");
            WebElement element = driver.findElement(By.xpath("//input[@name='email']"));
            element.sendKeys("[email protected]");
            WebElement element = driver.findElement(By.xpath("//input[@name='pass']"));
            element.sendKeys("abbaas");
            WebElement button = driver.findElement(By.xpath("//input[@name='login']"));
            button.click();
        }
    }

Conclusion

  • IntelliJ is a Java Integrated Development Environment used for software development 
  • It has facilities like advanced code navigation and code refactoring capabilities.
  • IntelliJ comes with inbuilt plugins and packaging tools
  • The advantage of using intelliJ is
  1. It supports multiple languages like Javascript, Java, etc
  2. It supports multiple Operating Systems like Linux, Windows, etc. which can be downloaded from JetBrains website.
  3. For object attributes it generates setter and getter methods.
  4. It generates inbuilt packaging tools like Grunt, SBT, gradle, bower, etc.
  5. Databases like ORACLE, SQL, Microsoft SQL Server, PostgreSQL can be accessed directly from IDE.
  • To work with Selenium, you need to configure IntelliJ.

Call to Action

Gaining proficiency in IntelliJ IDEA and Selenium WebDriver can significantly advance your skills in software testing and automation. With IntelliJ’s powerful code-editing, debugging, and smart assistance features, paired with Selenium’s capabilities for automating browser actions, you can create high-quality, efficient test scripts more effectively.

Integrating these tools enables you to automate repetitive testing workflows, boosting productivity and ensuring robust application quality.

At H2K Infosys, we provide immersive, hands-on training in IntelliJ and Selenium WebDriver, from basic setup to expert-level usage.

Join us to elevate your testing skills, gain practical project experience, and stand out in today’s fast-evolving tech industry. H2K Infosys is here to support your journey toward a successful career in test automation!

Share this article
Subscribe
By pressing the Subscribe button, you confirm that you have read our Privacy Policy.
Need a Free Demo Class?
Join H2K Infosys IT Online Training
Enroll Free demo class