A Gentle, Newbie-Friendly Guide to Installing Selenium WebDriver – Part 2: Get Intellij!

If you followed the 5-minute “Getting Started with Maven” guide from the previous post (link here incase you missed it), then you should now have Maven installed on your machine. From installing Maven, you should inturn also have installed the JDK on your machine. If not, go and check the Maven guide and come back here once you have the JDK and Maven installed.

We are now ready for the next step in getting Selenium WebDriver up and running, installing an IDE. You can use any Java IDE that you want, alot of people use Eclipse and its a great choice, but I am going to recommend Jetbrains Intellij.

I feel that this IDE is a little bit more friendly / forgiving to newer users and offers a lot of useful help/tips when there are errors in your code. Intellij has a free, open-source ‘Community Edition’ that is perfect for Selenium testing. You can download it from here – https://www.jetbrains.com/idea/download/

Once you have downloaded Intellij install it as normal by following the on-screen instructions. After the install has completed, launch Intellij and you should arrive at a landing page that looks something like below:

Intellij conveniently ties in with Maven, and we are going to use that functionality to get setup quickly. Go ahead and click “Create New Project” in Intellij. The “New Project” window opens, with several options. Simply select “Maven” from the left hand menu, and click next:

Next we need to enter a GroupId and ArtifactId for our project. You may have learnt a little about these from the Maven documentation in the previous post, but they are basically just names for our project. For the GroupId enter something like “com.mycompanyname.mytestapp” and for the ArtifactId enter “MyTestApp”. Click next.

Finally we need to enter a project name, and choose the location to save all the files. For the project name enter something like “MyFirstAutomationProject”, and choose a location that you will remember. Click “Finish” and the project will be created:

Once the project has been created Intellij should automatically open up the “pom.xml” file. This might look a little confussing but don’t worry, in just a few small lines of code we are going to install WebDriver and Junit directly from this file.

TIP: for Maven to work well with Intellij, it is important to turn on Auto-Import. When you open Intellij, you should see a popup in the top-right corner of the page – “Maven projects need to be imported”. Go ahead and click “Enable Auto-Import”. Now whenever we add a new dependency to the POM, Intellij will automatically import it through Maven.

Confussed? Don’t worry, it will all become clear soon! We are going to go ahead and install both Selenium and Junit in one swoop. Add the following code so that your POM.xml file looks like this:

As soon as you type in this code, Intellij will automatically get to work installing Selenium and Junit for you.

Congratulations, you are now in a position to begin writing automated tests! When I first started out with this stuff, it took me an embarrassingly long time to get to this point, so I hope that I made it a little less painful for you.

In the next post we will check that the installation of Selenium was indeed successful, and we will write our first Selenium test!

Hello James,
This is hands down one of the most simplified and ‘Actually’ newbie-friendly tutorials. Other tutorials I tried, did not explain explicitly that the dependencies in pom.xml help to download selenium webDriver and JUnit. I was under the impression I have to download selenium standalone jar or something, which was not explained anywhere, most tutorials had created the pom and asked to “add these lines to your pom.xml”

Appreciate your work!
Greetings!

James Willett

Hi Ken,

I am glad the tutorial has been helpful for you. When I started out with this stuff, I had very similar experiences to you, in that a lot of knowledge about certain aspects it is assumed you already know, or they are so obvious that the tutorial doesn’t mention it! Hopefully this is more “newbie friendly” 🙂

Thanks for the feedback.

James

Mike

Agreed, this is easily understood even for a novice like myself.

One thing James, you say “… you should see a popup in the top-right corner of the page – “Maven projects need to be imported”. ” I don’t see that anywhere.

Does this mean they’re imported already?

Thanks

James Willett

Possibly, although you will soon find out when you try to build a project, as you will get an error then.

Gaze

Thank you so so so much. This tutorial helped me a lot. I was tired of eclipse and as a regular user of pycharm I develop an attachment to jetbrains products. Thanks a lot again!

http://james-willett.com James Willett

Thanks Gaze, I am pleased that it helped you!

Richa

Hey James,

Really appreciate your work!
Thanks a lot…

I am seeing cannot resolve error for “FirefoxDriver” though i have imported both –
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

Will you please help here!

Richa

Stephanie

This was an amazing tutorial! It also took me ‘an embarrassingly long amount of time’ figure out how to install Selenium webdriver within Intellij. So many other instructions that I found online are very piecemeal. Thank you for laying out the instructions (and the reasoning behind them) very simply! 🙂

Thanks for the information Marit . I know that Firefox has recently switched over to the Gecko driver and it has caused lots of capability versions with Selenium. I appreciate you sharing your approach here.