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());

}


}

}