Automation Using Selenium Webdriver

Monday, 1 August 2016

Country Names and Currency List

package com.Test.web;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class TableList {

public static void main(String[] args) {

/*
* ##########################################################
* ComponentName : Getting Option
* Description   : It is Web Tables Getting List
*  Created By   : Team
* Creation Date : 10th May 2016
* Author        : T Jagan
* ##########################################################
   */

/*I have write to best scenario display all country name and currency list on rediff.com
* this is easy way  find web tables list on web page
*/
System.out.println("*************************************************");
   System.out.println("Execution is started");

List<WebElement>currencyList;
List<WebElement>rows;
List<WebElement>cells;
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
driver.get("http://money.rediff.com/tools/forex");

        rows=driver.findElements(By.xpath("html/body/div[1]/div[5]/div[2]/div[2]/table/tbody/tr"));
   for (int i = 1; i < rows.size(); i++) {
   
    cells=driver.findElements(By.xpath("html/body/div[1]/div[5]/div[2]/div[2]/table/tbody/tr["+i+"]/td"));
    System.out.println("Country Name ::" +cells.get(0).getText());
   
    System.out.println("country Currency Rate::" +cells.get(1).getText());

}


}

}

DrogandDrop Best Example

package com.Test.web;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;

     public class DragandDrop {

public static void main(String[] args) {
/*
* ##########################################################
* ComponentName : DragandDrop
* Description   : It Action on WebElement DragandDrop Oparation
*  Created By   : Team
* Creation Date : 1th Aug 2016
* Author        : T Jagan
* ##########################################################
   */

System.out.println("*************************************************");
        System.out.println("Execution is started");

System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
Actions action=new Actions(driver);

        driver.get("http://www.dhtmlgoodies.com/scripts/drag-drop-custom/demo-drag-drop-3.html");
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
     
        WebElement source=driver.findElement(By.id("box1"));
        WebElement target=driver.findElement(By.id("box101"));
     
        if (source.isDisplayed() && source.isEnabled() && target.isDisplayed() && target.isEnabled())
     
             {
System.out.println("Element is Present");
action.dragAndDrop(source, target);
action.build().perform();
}
             else
             {
            System.out.println("Element not Present");
             }

    }  
     
}


Sunday, 31 July 2016

Java Encapsulation Exampe

Encapsulation:
--------------
Encapsulation means putting together all the variables (instance variables) and the methods into a single unit called Class. It also means hiding data and methods within an Object. Encapsulation provides the security that keeps data and methods safe from inadvertent changes.

encapsulation in java
We can create a fully encapsulated class in java by making all the data members of the class private. Now we can use setter and getter methods to set and get the data in it..


package oopsconcept;
public class Mobile {    
    private String manufacturer;
    private String operating_system;
    public String model;
    private int cost;
    //Constructor to set properties/characteristics of object
    Mobile(String man, String o,String m, int c){
        this.manufacturer = man;
        this.operating_system=o;
        this.model=m;
        this.cost=c;
    }
    //Method to get access Model property of Object
    public String getModel(){
        return this.model;
    }
    // We can add other method to get access to other properties
}

Advantage of Encapsulation in java:
---------    ------------     -----
By providing only setter or getter method, you can make the class read-only or write-only.

It provides you the control over the data. Suppose you want to set the value of id i.e. greater than 100 only, you can write the logic inside the setter method.

Simple example of encapsulation in java:
---------       ----------     ---------
public class Student{
private String name;
 
public String getName(){
return name;
}
public void setName(String name){
this.name=name
}
}

class Test{
public static void main(String[] args){
Student s=new Student();
s.setname("jagan");
System.out.println(s.getName());
}
}
Output:jagan


Manual Testing FAQ

What Is Regression Testing Explain It with Example?
When a bug is fixed by the development team than testing the other features of the applications which might be affected due to the bug fix is known as regression testing.

Regression testing is always done to verify that modified code does not break the existing functionality of the application and works within the requirements of the system.
Regression Testing Example - Real and Practical

Example of regression testing with its process is explained below:

For Example there are three Modules in the Project named Admin Module, Personal Information, and Employment Module and suppose bug occurs in the Admin Module like on Admin Module existing User is not able to login with valid login credentials so this is the bug.

Now Testing team sends the above - mentioned Bug to the Development team to fix it and when development team fixes the Bug and hand over to Testing team than testing team checks that fixed bug does not affect the remaining functionality of the other modules (Admin, PI, Employment) and also the functionality of the same module (Admin) so this is known as the process of regression testing done by Software Testers.

Smoke testing:


Example:

Let us assume that there is an application like ‘Student Details’ which has 5 important components like Login page, Adding student details, Saving the details, Updating it and Deleting it. As a part of smoke testing we will test the login page with valid input. After login we will test the addition, saving, updating and deleting of records. If all the 5 critical components work fine then the build is stable enough to proceed with detailed testing. This is known as Smoke testing.

What is Agile Methodology?

Agile as the name specifies something that to be done faster or quickly. On testing and development point of view Agile is completely a new methodology to speed up your testing and development activity. As the requirements change frequently and we need to complete the testing or development for the change request as quick as possible. In this situation agile methodology comes forward. Agile methodology should be performed from the starting of the project and should carry out till the project go live. Even some times this methodology carry forward for some more time until the project becomes stable. . There are many processes comes under Agile methodology but out of them tow are very important-

Scrum and Sprint.

Scrum Meeting:

Scrum is a kind of short time meeting done every day and we discuss about every day work. Its not like a general meeting but we fully focus on the whole day development and testing work. Also in this meeting we discuss about the daily work and priority modules. We plan for –

Total time duration: In scrum meeting we decide the total time duration for each sprint to test and develop. On daily basis we track the progress of each task assigned.

Identifying the risk: Another plan that we make in scrum meeting is to identify the risks. Risks like which tasks are more complicated or which task could have probability to be failed or which task could have more bugs etc.

Cost: This is another priority that we discuss in Scrum meeting that how much cost will be to develop or test any task. If development time or testing time will be exceeded will affect the expected or allocated cost. So we discuss how to balance time and cost.

Resources: How many resources required to test or develop each task is also an important factor that are discussed in scrum meeting.

There are some other topics as well like potential of the work, backlogs etc. are also a part of discussion that should be happen in scrum meeting.

In Scrum meeting generally we used to have one scrum master who decides how smoothly project development and testing are going on.

agile

Sprint Planning:

Sprint is nothing but its a part of scrum meeting where we decide which module should be developed or tested first. The piece of task is called sprint. In scrum meeting we set our sprint planning. Once sprint planning is done we discuss on daily basis about the progress of particular sprint and sprint backlog in sprint meeting. Backlog is nothing but a list of tasks to be completed and assigned to the individual. The progress of the sprint is discussed in scrum meeting. We analyze how many sprints are developed and how many sprints are still pending. Sprint which takes the long time as expected are divided into small sprints to speed up the work. Work on each sprint is completely based on priority.




Manual Testing FAQ

Saturday, 30 July 2016

Simple and Easy Example for Java - Polymorphism

polymorphism :--
--------------------
polymorphism mean exiting objects behaviour in many forms

There are two type of polymorphism
signature  1)No of orgumantes 2)Types of orguments 3)order of arguments

In below program we have three print methods each with different arguments. When you properly overload a method, you can call it providing different argument lists, and the appropriate version of the method executes

1)complile time / static /method overloading:
-----------------------------------------------------

    Example
   -------------
         public class MethodOverload {


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, double c){
System.out.println(a+b+c);
}

public static void main(String[] args) {
MethodOverload mo=new MethodOverload();
mo.add(10, 20);
mo.add(20, 30, 50);
        mo.add(1.245, 4.567, 7.890);
}

}

2)Run time polymorphism:-
---------------------------------
    If two are more methods haveing same name and same arguments available in the  super class and sub class

        Example:
        -----------

public class A {
public void addition(int a,int b){
System.out.println(a+b);


}
public static void main(String[]args){
A ja=new A();
ja.addition(20, 50);
}

}

public class B extends A{
public void addition(int a,int b){
System.out.println(a+b);

}


public static void main(String[] args) {
A ja1=new A();
ja1.addition(40, 30);//70
B ja2=new B();
ja1.addition(55, 35);//90
}

}


Friday, 29 July 2016

Check Box

Check Box in Webpage Checked or not

package com.Test.web;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class CheckBox {

public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("https://www.irctc.co.in");
driver.manage().window().maximize();
if (!driver.findElement(By.id("otpId")).isSelected());
{
driver.findElement(By.id("otpId")).click();
}


}

}

Java Program Palindrom


Given Number palindrome Or not

Palindrome number in Java: A palindrome number is a number such that if we reverse it, it will not change. For example some palindrome numbers examples are 121, 212, 12321, -454. To check whether a number is palindrome or not first we reverse it and then compare the number obtained with the original, if both are same then number is palindrome otherwise not. C program for palindrome number is given below.

Example:

                package com.java.exmp;

public class Palindrom {

public static void main(String[] args) {
int r,sum=0,temp;
int n=57575;
        temp=n;
        while(n>0)
{
        r=n%10;
        sum=(sum*10)+r;
        n=n/10;
       
}
        if(temp==sum)
        System.out.println("Palindrom number");
        else
        System.out.println("Not Palindrom number");

}

}

Output:
Palindrom number