Java Quick Tutorial for Selenium Part 2

Java Quick Tutorial for Selenium Part 2

In Java Quick Tutorial Part 1 I explained,

Java Environment Setup & Verify

A) Java Fundamentals
i) Comments in Java
ii) Java Data Types
iii) Java Modifiers
iv) Variables
v) Operators
vi) Conditional Statements
vii) Loop Statements
viii) String Handling in Java
ix) Arrays in Java
x) Java IO Operations
----------------------------------------------------- 
Java for Selenium Part 2

xi) File Handling
xii) Java Built-in Methods 
xiii) Java User defined Methods
xiv) Java Exception Handling

B) Java OOPS (Object Oriented Programming System)
i) Inheritance
ii) Polymorphism
iii) Abstraction
iv) Encapsulation
--------------------------------------- 
xi) File Handling

Using File Class we can handle Computer files.

Example:

1) Create a Folder

File fileObject = new File("C:/Users/gcreddy/Desktop/ABC");
fileObject.mkdir();
--------------------------------------- 
xii) Java Methods 

A Java Method is a set of statements that are grouped together to perform an operation.

Methods are also known as Functions.

In structured programming (Ex: C Language) we use Functions (Built-in and User defined)

In Object Oriented Programming (Ex: Java Language) we use Methods (Built-in and User defined)
-------------------------------------------
When we choose Methods?

Whenever we want perform any operation multiple times then we choose methods.

Advantages of Methods

Code Reusability, using methods we can reduce the project code size.

Code Maintenance is easy.
--------------------------------------- 
ii) Types Methods in Java

Two types of Methods

1) Built in /Pre-defined Methods

2) User defined Methods
--------------------------------------- 
Examples for Built in Methods

equals() Method

Compares two strings and supports 2-way comparison

Example:

public static void main(String[] args) {
String str1 = "selenium";
String str2 ="SELENIUM";
String str3 ="seleniuma";
String str4 = "selenium";

System.out.println(str1.equals(str2));//false
System.out.println(str1.equals(str4));//true
--------------------------------------- 
round()
Rounds the value to nearest integer.

public static void main(String[] args) {
double a =10.234;
double b =-10.784;

System.out.println(Math.round(a));//10
System.out.println(Math.round(b));//-11
}
--------------------------------------- 
isAlphabetic()

Checks weather the value is alfa byte or not?

public static void main(String[] args) {
char a ='Z';
char b ='1';

System.out.println(Character.isAlphabetic(a));//true
System.out.println(Character.isAlphabetic(b));//false
System.out.println(Character.isAlphabetic('B'));//true
System.out.println(Character.isAlphabetic('a'));//true
System.out.println(Character.isAlphabetic('*'));//false
--------------------------------------- 
xiii) User Defined methods in Java

Two types of user defined methods

1) Method without returning any value
a) Calling Methods by invoking Object
b) Calling methods without invoking Object

2) Method with returning a Value
a) Calling Methods by invoking Object
b) Calling methods without invoking Object

Examples:

//User defined methods
public int multiply(int a, int b, int c){
int result = a*b*c;
return result;
}
public static void main(String[] args) {
//Create Object
JavaMethods abc = new JavaMethods();

//Call methods
int x = abc.multiply(10, 25, 35);
System.out.println(x);
---------------------------------
//Create a method without returning any value
public static void studentRank(int marks){
if (marks >= 600){
System.out.println("Rank A");
}
else if (marks >=500){
System.out.println("Rank B");
}
else{
System.out.println("Rank C");
}
}

public static void main(String[] args) {
//Call Methods
JavaMethods.studentRank(650);
}
--------------------------------------- 
xiv) Java Exception Handling

> An Exception is an event that occurs during execution of a program when normal execution of a program
    is interrupted.

> Exception handling is a mechanism to handle exceptions.

Common Scenarios where exceptions may occur

1) Scenario where ArithemeticException occurs

2) Scenario where NullPointerException occurs.

3) Scenario where NumberFormatException occurs

4) Scenario where ArrayIndexOutofBounds exception occurs

Example:

public static void main(String[] args) {
int a =10;
int b =0;
int result = a/b;
System.out.println(result);
System.out.println("Hello Java");
System.out.println("Hello Selenium");
}
--------------------------------------- 
B) Java OOPS

Four fundamentals of OOPS:

i) Inheritance

ii) Polymorphism

iii) Abstraction

iv) Encapsulation
--------------------------------------- 
i) Inheritance

> It is a process of Inheriting (reusing) the class members (Variables and Methods) from one class to another.

> Non static class members only can be inherited.

> The Class where the class members are getting inherited is called as Super Class/parent Class/Base Class.

> The Class to which the class members are getting inherited is called as Sub Class/Child Class/Derived Class.

> The Inheritance between Super class and Sub class is achieved using "extends" keyword.
--------------------------------------- 
Example

Class 1:

public class ClassA {
int a =10;
int b =20;

public void add(){
System.out.println(a+b);
}
public static void main(String[] args) {
ClassA objA = new ClassA();
System.out.println(objA.a);//10
objA.add();//30
}
}
------------------------------
Class 2:

public class ClassB extends ClassA{
int a =100;
int b =200;

public void add(){
System.out.println(a+b);
}
public static void main(String[] args) {
ClassB objB = new ClassB();
System.out.println(objB.a);//100
objB.add();//300
}
}
--------------------------------------- 
ii) Polymorphism

Existence of Object behavior in many forms

There two types of Polymorphism

1) Compile Time Polymorphism / Method Overloading

2) Run Time Polymorphism / Method Overriding
--------------------------------------- 
1) Compile Time Polymorphism / Method Overloading

If two or more methods with same name in the same class but they differ in following ways.

a) Number of Arguments

b) Type of Arguments
------------------------------------
Example:
------------------------------------
public class Class1 {

public void add(int a, int b){
System.out.println(a+b);
}

public void add(int a, int b, int c){
System.out.println(a+b+c);
}

public void add(double a, double b){
System.out.println(a+b);
}

public static void main(String[] args) {

Class1 obj = new Class1();
obj.add(1.23, 2.34);
obj.add(10,  20);
obj.add(1,  5, 9);
}
}
--------------------------------------- 
iii) Abstraction

> It is a process of hiding implementation details and showing only functionality to the user.

Two types of Methods in Java

1) Concrete Methods (The methods which are having body)

2) Abstract Methods (The methods which are not having body)

> If we know the method name but don't know the method functionality then we go for Abstract methods.

> Java Class contains 100% concrete methods.

> Abstract class contains one or more abstract methods.
--------------------------------------- 
Example for Abstract Class:

public abstract class Bikes {

public void handle(){
System.out.println("Bikes have handle");
}
public void seat(){
System.out.println("Bikes have Seats");
}

public abstract void engine();

public abstract void wheels();

public static void main(String[] args) {
//Bikes obj = new Bikes();

}
}
--------------------------------------- 
iv) Encapsulation

It is a process of wrapping code and data into a single unit.

Ex: Capsule (mixer of several medicines)

Encapsulation is the technique making the fields in a class private and providing access via public methods.

> It provides control over the data

> By providing setter and getter methods we can make a class read only or write only.
--------------------------------------- 
Example:

Class 1:

public class Class1 {
private String name ="Test Automation";

public String getName(){
return name;
}
public void setName(String newName){
name = newName;
}
public static void main(String[] args) {
Class1 obj = new Class1();
System.out.println(obj.getName());
}
}
-----------------------------------------------
Class 2:

public class Class2 extends Class1{

public static void main(String[] args) {
Class2 abc = new Class2();
//abc.setName("Selenium Testing");
System.out.println(abc.getName());
}
}
----------------------------------------------------- 
Java Tutorial for Selenium Part 1

Software Testing Live Project Training

Software Testing Live Project Online Training

Manual Testing and Automated Testing (using Selenium)
-----------------------------------------------------------
Training Program will commence on: 23rd July 2016 
Weekday Training Program (Saturday & Sunday, 5 Weekends)
-----------------------------------------------------------
Timings:
5:30 PM to 10:00 PM - Indian Standard Time
8:00 AM to 1:00 PM - EST
7:00 AM to 12:00 PM - CST
5:00 AM to 10:00 AM - PST
-----------------------------------------------------------
Fee: 300 US Dollars
----------------------------------------------------------- 
Contact
Email: gcreddy@gcreddy.com  
-----------------------------------------------------------
  I) Testing Project (Manual Testing)

Session 1: Software Project Overview

• Introducing Application Environment
• Project Technical Information
• Project General / Business Information
• Stake holders of the Project
• Users of Admin Interface
• Users of User Interfaces and Project Flow

Session 2: Understanding and Analyzing Test Requirements

• Understanding Admin Interface Functional Test Requirements
• Understanding User Interface Functional Test Requirements
• Understanding Usability Test Requirements
• Understanding Performance Test Requirements

Session 3: Test Plan Documentation

• Identify Features to be Tested
• Test Strategy Implementation
• identify Entry, Suspension and Exit Criteria
• Roles and Responsibilities
• Test Plan Documentation

Session 4: Create Test Scenarios

• Identify Smoke Test Scenarios for Admin and User Interfaces
• Identify all possible Test Scenarios for Admin Interface of the Project
• Identify all possible Test Scenarios for User Interface of the Project
• Positive and Negative Test Scenarios Documentation  

Session 5: Test Case Documentation Part-1

• Introducing Test Case Template
• Identify Verification Points for Smoke Test Cases
• Write Test Cases for Smoke Testing/Sanity Testing

Session 6: Test Case Documentation Part-2

• Identify Verification Points for all Possible Test Cases of the Project

• Admin Interface Test Cases Documentation
• User Interface Test Cases Documentation

Session 7: Test Data Collection

• Prepare Test Data for Smoke Test Cases
• Prepare Test Data for Comprehensive Test Cases
• Collect Error messages and Help messages information from Development Team

Session 8: Test Execution (Test Case Execution, Defect Reporting & Tracking Part-1)

• Create Test Batches
• Verify Test Environment Setup
• Execute Smoke Test Cases / Smoke Testing

Session 9: Test Execution (Test Case Execution, Defect Reporting & Tracking Part-2)

• Introducing Defect Report Template
• Execute Comprehensive Test cases
• Defect Reporting and Tracking
• Select Test Cases for Regression

Session 10: Test Closure (Test Summary Report...)

• Evaluate the Exit Criteria
• Collect all artifacts and Test Summary Report
• Send Test Deliverables  to Customer

II) Automated Testing using Selenium

Session 11: Test Planning 

• Get Environment details from Development Team and Analyze the AUT in terms of Object identification
• Select Test Cases for Automation
Choose Selenium Tools and Configure Selenium Test Environment


Session 12: Writing Selenium Test Cases Part-1

Identify Smoke Test Cases and Prepare Test Steps and Verification points
• Inspect Web Elements and identify unique locators
Write Test Steps using Element Locators and WebDriver API Commands
• Enhance Test cases using Java Programming features.  

Session 13: Writing Selenium Test Cases Part-2

Identify all Possible Test Cases and Prepare Test Steps and Verification points
• Inspect Web Elements and identify unique locators
Write Test Steps using Element Locators and WebDriver API Commands
• Enhance Test cases using Java Programming features.  

Session 14: Writing Selenium Test Cases Part-3

Write Test Steps using Element Locators and WebDriver API Commands
• Enhance Test cases using Java Programming features.  


Session 15: Writing Selenium Test Cases Part-4

Write Test Steps using Element Locators and WebDriver API Commands
• Enhance Test cases using Java Programming features.  

Session 16: Cross Browser Testing

Create Selenium WebDriver Test case/s
• Download Google Chrome and Internet Explorer Browser drivers
• Execute Test cases using Mozilla Firefox Browser 
• Execute Test cases using Google Chrome Browser 
• Execute Test cases using Internet Explorer Browser   

Session 17: Batch Testing

Select a Test batch / Series of Tests
Identify Reusable Components and Create
Create Test Cases using Reusable Components/user defined methods
Write multiple Test cases in a program and Execute   

Session 18: Data Driven Testing

• Identify Data Driven Test Cases
Data Driven Testing by Dynamic Test Data Submission
Conduct Data Driven Testing by reading Test Data from Text Files
Conduct Data Driven Testing by reading Test Data from Excel Files 

Session 19: TestNG Framework Implementation

• Install TestNG and Create TestNG Programs
Grouping Test Cases, Prioritize Test Cases
• Execute Test batches and generate Test Reports
Data Driven Testing and Parallel Test Execution

Session 20: Test Execution (Test Case Execution, Defect Report....)

• Test Case Execution
Analyze Test Results and Report Defects
------------------------------------------------------
Highlights of the Training

• Software Test Documentation Templates

• Software Test Documentation

• Identifying Smoke Test Cases

• Creating Test Batches

• Test Plan Documentation

• Test Case Documentation

• Test Data Collection

• Defect Report Documentation

• Test Summary Report
----------------------------------------
• Select Test Cases for Automation

• Identifying Data Driven Test Cases

• Cross Browser Testing, Batch Testing and Data Driven Testing
-----------------------------------------------------------------------