Selenium Java to Advanced Framework

Hi All,

I hope that all are doing good!. If you are really interested in learning selenium and related stuff, its the right place you are! . So here I am going to teach you Selenium with Java. Hope you are following my Selenium with C# course as well.

For those who are having less knowledge on java , I will be starting with Basics of Java. Those who are profficient in this can skip this lecture and goto Selenium Java Topics through below link.

Link – Navigate to Selenium Java Topics.

BASICS OF JAVA

Here I will be teaching you to write java basic codes and concept in Eclipse. So you need to download Eclipse from Internet. You can got below link:

https://www.eclipse.org/downloads/

When you hit the link you will Eclipse IDE 2020-03 and download link. Now you can download that.

Image

Now if you want to open this eclipse you should have jdk installed and configured in your PC.

Go to Oracle Java official site and download their latest jdk version.

https://www.oracle.com/java/technologies/javase-downloads.html

Here jdk 14 is latest version. You can download it.

Image

Now once jdk is download next step is to Set the environmental variables. Right click on your ‘This PC’ icon -> Properties -> Advanced System Settings.

In that go to advanced tab -> Click on Environmental Variables.

There you will be seeing System Variables sections. Create a new System variable by clicking on ‘New’ under System Variables .and type name as JAVA_HOME and variable value as the path of jdk where it is stored in your computer. Lets say if its in C drive, inside Java folder, you must give as

C:\Java\jdk-14

Now inside System Variables section you will see something like ‘Path’ . If you double click on it it will open new window, where you can add new path. Click on ‘New’ and add java>jdk-14>bin path. Taking as above example path can be:

Image

C:\Java\jdk-14\bin

Now click on OK and close eveything. Now take your Command Prompt (Windows +R , type cmd and hit OK) and in when Command Prompt opens type java -version and hit Enter . You should see your java version in cmd. Then it means you have successfully configured java.

Image

Once Java is installed you can run your eclispse, It may ask for Workbench location, you can give your own path if required. It would be place where your projects are saved .

When eclipse got open you may see a Welcome message , you can close that. Now we have to create a java project. For that click on File >> New >> Java Project.

Image

You can create a java project with a name. Here i have given demo as name . Below project name you can see the project location. This would be selected while opening Eclipse as I mentioned earlier. Now click on Next.

Image

You will see a box like in above. Click on Finish. Now a project is created as demo in your eclipse. You can expand the project.

Image

You will see a src folder, where you have to create packages/classes and write your script.

Now what is package in Java?

A Package is a collection of related classes. It helps organize your classes into a folder structure and make it easy to locate and use them. More importantly, it helps improve re-usability.Each package in Java has its unique name and organizes its classes and interfaces into a separate namespace, or name group.

Although interfaces and classes with the same name cannot appear in the same package, they can appear in different packages. This is possible by assigning a separate namespace to each package.

Now definitely questions comes what is a ‘Class’?

Java is an object-oriented programming language.

Everything in Java is associated with classes and objects, along with its attributes and methods. For example: in real life, a car is an object. The car has attributes, such as weight and color, and methods, such as drive and brake.

So if you want to write something in java , it should be inside a class.

So how to create a class?

Please note if you are creating a class without creating a package , it by default goes under a default package. Its recommended to always create a package before creating a class.

Right click on src folder -> New -> Package. Give name for package and click on Finish.

Image

Now right click the created package , because you want to create a class inside the package.

New->Class

Image
Please provide a Classname, I have given MyFirstClass and select check the ‘public static void main(String[] args)

Please remember you have to provide first letter of Class name in capital letter as per coding standards. Lets continue in next lecture..

Leave a comment