Saturday, 18 February 2017

What is Java Class :-

To understand "What is a Java class and how to define it in Java ?",we are taking very simple java program.By this program, you can understand what is Class in java very easily? After that we will create a class definition so that you can answer this during your interview easily. I will be providing some  rules to write a java class for a good programmer and some cases to check how to resolve the common java class errors while creating a java class in your project.

Let's have a look at the below example:-

package java2selenium;

public class TestJava {

public static void main(String[] args) {

System.out.println("Welcome to Java2Selenium");

}

}


















In the above example the TestJava is a user defined class.We can define a class by using one of the java keywords called "class". A java class always starts with '{' opening curly brace and ending with
closing brace'}'. By using this class name we can create a n- number of objects of same class type.We will discuss in next topic what is Object and how to create  a object using a class.

To understand what is class more,let's assume one real life example in our daily life.Suppose, a builder in a city wants to make a n-number of buildings .Before developing the buildings, he need one map so that based on that he can build a building. The Map contains all rooms size and positions, stairs position and so on. The Map will work like a template and using this template we can create any number of buildings.

In the above example, map is a kind of class and n- number of buildings are Objects those are created based on this map. The rooms numbers,sizes and all will define the state and behaviour.

Definition:-  "A java class is template or blueprint that describes the state and behavior of objects created using the same class."
A class can contain fields(variables) to describe the state and methods to describe the behavior of an object. Syntax:
--------------------------------------------------------------
<class modifier>  <class keyword>  class name
----------------------------------------------------------------------
Eg. public class TestJava or class TestJava

Class declaration:

class Map{

//fields declarations
//Methods declarations
//constructors declarations
}

The class body (the area between the braces) contains all the code that provides for the life cycle of the objects created from the class.

Rules to declare a class:-
********************
1. A class name always starts with initial letter capitalized by convention.

2. The class body, surrounded by braces, {}.

3. Having modifiers such as public, private and default.

4. Attach with class keyword starts with small letter.

Cases:-
---------
Case 1: If you are making a class as source file name and not declaring that class name as public then you will get compile time error. A source file name must be declared as public.A source file can contain many classes but only one class can public which should contain your main().



Once we have declared our class,we can declare fields, methods and constructors in a class body.We will discuss what they are in next topics.


Sunday, 12 February 2017

Java-How to Install Java.

Next

We know that Selenium is a web Automation tool which can be used to automate any web application across different different browsers and operating systems.So, if anyone want to automate a web based project using selenium WebDriver then you have to write some code using any programming language supported by Selenium.
Selenium supports below languages to write test scripts to automate a web project:-

  • Java
  • C#/Asp.Net
  • Python
  • perl
  • Ruby
  • PHP
  • JavaScript
Now a days,most of the software companies are using Java programming language to write test scripts in Selenium to automate their web based products.There are many reasons why these companies are prefer Java language.As,Java people are easily available and you will get any help related to java easily on internet.

There are many websites and blogs where you can find whatever you want for your projects in Java easily even with code.You will get many job calls for Selenium automation with Java once you have updated your CV on any job portal like Nakuri.com. Currently,there are many job openings in IT companies for Selenium automation with Java and you can get 8 job calls out of 10 for Selenium testing with core java.If you are a job seeker/fresher and want to get job in a Software/IT field then this is a great chance for you to get job into automation easily and fastly.

But there are lots of questions before going for the interview like how to prepare for selenium testing with Java to crack the interview either for experience or fresher level.There are lot's of websites from where you will learn for this but problem is that from where you have to start and how much do you need for a automation project.

In this blog,I am posting the Java topics those are really used in Selenium testing while writing test scripts.Here, I am providing every Java topic with explanation in a very simple way along with many java programs.Once you have completed a java topic you can see a link "Where to use in Selenium" then when you click on this link you will navigate to respective selenium topic to show how we are using this java concept in this selenium where and how.
To start playing with Java programming you should install JDK(Java Development Kit) latest version and any development IDE like Eclipse to your system.If you don't know how to install Java then follow the below steps to install latest version of Java successfully and any version of Eclipse to write code for practise.

Step 1:Click on the link Download Java to download the latest version of Java.

Step 2:Accept the Oracle licence as shown in below image.

Step 3:Click on .exe file link to start download for your OS version(64-bit or 32-bit) as shown on below image:-

Step 4: After that check your download has started as shown on below image:-

Step 5: Once java has successfully downloaded then you can see the .exe file in your downloads folder as shown in below image:

Step 6:Double click on the .exe file and start your installation as shown in below image:-

Step 7: Click on Next button as shown in below image :-

Step 8:Select your folder location if you want to change location and click next button to complete installation as shown in below image :-

Step 9:Successful message window will pop up,once java has installed successfully as shown in below image :-

Step 10: Go to java folder location as in step 8 and check that 'Java' new folder is created as shown in below image :-

Step 11: Double click on 'Java' folder and check JDK folder is created as shown in below image :-(Eg.jdk1.8.0_121)

Step 12:Double click on above JDK folder and go to 'bin' folder and copy the path and paste in notepad as shown in below image :-

Step 13: Go to My Computer->properties option as shown in below image :-

Step 14:Click on 'Advanced system setting' as shown in below page :-

Step 15: Click on 'Environment variable' button and then go to 'system variable->path and click on 'Edit' button as shown in below image:-

Step 17: Click on 'New' option in open window pop up and paste the bin folder location which you saved in your notepad in step 12 and click OK button as shown in below image:-

Step 18: Click on "OK" button to close all open window pop ups.

Step 19: Open your Command prompt CMD and type "Javac" command and you will see some description.
->Again type 'Java' command and again you will see some details.

Step 20: Again you type 'java -version' command to check java version which you recently installed.


Now, you have successfully installed Java in your system .After that you can download any version of Eclipse IDE to practise Java programs. If you do not know from where you need to download Eclipse IDE then follow the below steps:-
Step 1: Click on Download Eclipse link to download Eclipse IDE and select any Eclipse release as shown in below image :-

Step 2:Select 'Eclipse IDE for EE developers' link and click on corresponding OS version link as shown in below image:-

Step 3: Click on Download button to start download as shown in below image:-

Step 4:Go to download folder in your system and unzip the eclipse folder.After that double click on the .exe file to start application as shown in below image :-

Download Android SDK

Download Android SDK tools Follow me on Instagram - https://www.instagram.com/virenautomationtesting/ Follow me on Twitter- https://twitt...