Automation Using Selenium Webdriver

Thursday 4 August 2016

Difference between Test case and Test scenario

Difference between Test case and Test scenario

April 23
Difference between Test case and Test scenario:

Test case consist of set of input values, execution precondition,
 excepted Results and executed post condition, developed to cover certain test Condition.
 While Test scenario is nothing but test procedure.

A Test Scenarios have one to many relation with Test case, Means A scenario have multiple test case.
Every time we have write test cases for test scenario.
So while starting testing first prepare test scenarios
then create different-2 test cases for each scenario.
Test cases are derived (or written) from test scenario.
The scenarios are derived from use cases.
Test Scenario represents a series of actions that are associated together.
While test Case represents a single (low level) action by the user.
Scenario is thread of operations where as Test cases are set of
input and output given to the System.
For example:
Checking the functionality of Login button is Test scenario and
Test Cases for this Test Scenario are:
1. Click the button without entering user name and password.
2. Click the button only entering User name.
3. Click the button while entering wrong user name and wrong password.
Etc…
In short,
Test Scenario is ‘What to be tested’ and Test Case is ‘How to be tested’.



Wednesday 3 August 2016

List and set

Difference between List and Set in Java::
------------------------------------------------
List and Set both are interfaces. They both extends Collection interface. In this post we are discussing the differences between List and Set interfaces in java.

List allows duplicates while Set doesn’t allow duplicate elements. All the elements of a Set should be unique if you try to insert the duplicate element in Set it would replace the existing value.

 List implementations: ArrayList, LinkedList etc.
 
 Set implementations: HashSet, LinkedHashSet, TreeSet etc.

EX: List

public class ListExample {

 public static void main(String[] args) {
   List<String> al = new ArrayList<String>();
   al.add("Chaitanya");
   al.add("Rahul");
   al.add("Ajeet");
   System.out.println("ArrayList Elements: ");
   System.out.print(al);

   List<String> ll = new LinkedList<String>();
   ll.add("Kevin");
   ll.add("Peter");
   ll.add("Kate");
   System.out.println("\nLinkedList Elements: ");
   System.out.print(ll);
 }
}

Output:
ArrayList Elements:
[Chaitanya, Rahul, Ajeet]
LinkedList Elements:
[Kevin, Peter, Kate]

Set Example:

public class SetExample {

  public static void main(String args[]) {
    int count[] = {11, 22, 33, 44, 55};
    Set<Integer> hset = new HashSet<Integer>();
    try{
      for(int i = 0; i<4; i++){
         hset.add(count[i]);
      }
      System.out.println(hset);

      TreeSet<Integer> treeset = new TreeSet<Integer>(hset);
      System.out.println("The sorted list is:");
      System.out.println(treeset);
    }
    catch(Exception e){
        e.printStackTrace();
    }
  }

Output:
[33, 22, 11, 44]
The sorted list is:
[11, 22, 33, 44]


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
}

}