Essential Java for Selenium - A Beginner's Guide

Essential Java for Selenium - A Beginner's Guide

"I want to learn test automation, Where to start?"

This is a very frequently asked question who wants to learn Selenium or aim to be an SDET. You can be a fresher or an experienced person and this dilemma sometimes makes one feel directionless. However, the answer really depends on what is your expectation when you choose to learn something new. I believe people have one of these objectives when they pick a language to learn -

  • Is this just for the sake of knowledge?
  • Is one going to develop it as a skill set in her carrier pursuit?

If you belong to the first group, there is no need to dig deep and you can start exploring Selenium with basic knowledge of OOPs concepts.

But if you lie in the second group and want to pursue a career as an SDET without a doubt you need to work on building a strong base by understanding various concepts and on getting a good grip of Selenium scripting.

Few areas one should be thorough with even before you start with Selenium are -

OOP’s fundamentals – Cover the following topics and you are good to go: Abstraction, Polymorphism, Inheritance, and Encapsulation.

Java basics -- Classes, Objects, Object Instances, Constructor overloading/overriding, method overloading/overriding concepts and packages.

Control statements – While, do-While, If statements – These statements will help you in writing decision-making scripts, and also Statements like switch can be very handy if there are multiple statements to check.

Looping statements – These will help in scenarios like iterating through a large table to find a record that you want or running the same test multiple times.

Arrays concepts – These will help in storing data sets. For e.g., if you want to fetch data from a CSV file, the array is the key to do that.

Threads and Multi-Threading concepts – Some would say that multi-threading is not related to Selenium. But this totally depends on how robust a framework you want to make. Practical implementation of multi-threading will run scripts in different threads with the help of which better performance can be achieved. Most modern age frameworks provide this built-in for you and you will do a better job in distributed tests if you understand these concepts.

Exception handling: This helps enables smooth execution and prevents unnecessary halts in code execution.

Java Collections Framework – ArrayLists and HashMaps – They help in maintaining a collection of data. Particularly useful for scenarios like when you know what type of data you are going to store but you don't know how much data will be there beforehand.

File Streams – This is helpful in fetching data from different file formats like .CSV, Excel or Java Properties file.

So, essentially you need to learn "how to" implement logic (Operators, Arrays, Control Statements, Loops) in Java concepts (Classes, Inheritance, Polymorphism, Multi-threading, Exception handling) to be an efficient and effective Selenium developer.

Please remember Java is just a way of talking to machines, it can be the python, JS whatever you are comfortable with. But if you are clear with the fundamentals of one language, it will be easier for you to navigate into another.

Share your thoughts and feel free to shoot any queries.

Cheers !!