Wednesday, October 29, 2014

QTP & Selenium Training from Basic to Advance Level- 9922500360

Classroom and Online Training QTP Classes in Pune,Delhi and Mumbai-09763315036

HP Quick Test Professional Online training from Automation Infotech 91-9763315036

Comprehensive QuickTest Professional 10.0
Course Code : QTP032012
Source : AutoamtionInfotech


HP Quick Test Professional (QTP basic to In-depth concepts + VB Scripting +

Descriptive Programming + Framework Development + Certification) Training


Please find below the QTP training details.

Training: QTP Specialist with Framework plus Certification Training

Duration: 4-5 weeks

Trainer: QTP Certified with 6+ years of experience working as Automation lead

Call 09763315036 / 9922500360



Classroom and Online Training Selenium Classes in Pune,Delhi and Mumbai-09922500360

Selenium Online training from Automation Infotech 91-9922500360

Comprehensive Selenium
Course Code : Selenium 112014
Source : AutoamtionInfotech


Selenium  basic to In-depth concepts + Java + RC + Web Driver + Grid + Framework Development  Training


Please find below the Selenium training details.

Training: Selenium Specialist with Framework plus Certification Training

Duration: 9 weeks


Call 09763315036 / 9922500360





Chapter 37- Selenium Grid

Selenium Grid

Selenium Grid is a tool that distributes the tests across multiple physical or virtual machines so that we can execute script in parallel(simultaneously) that results in cutting down the time required for running tests. This dramatically accelerates testing across browsers and across platforms by giving us quick and accurate feedback.
Selenium Grid allows us to execute multiple instances of WebDriver or Selenium Remote Control tests in parallel which uses same code base, hence code need NOT be present on the system they execute. The selenium-server-standalone package includes Hub, WebDriver, and Selenium RC to execute the scripts in grid.
Selenium Grid has a Hub and a Node
  • Hub - The hub can also be understood as server which acts as the central point where the tests would be triggered. A Selenium Grid has ONLY one Hub and it is launched on a single machine once.
  • Node - Nodes are the Selenium instances that are attached to the Hub which will execute the tests. There can be one or more nodes in a grid which can be of any OS and can contain any of the Selenium supported Browsers.

Architecture

Architecture of Selenium Grid is explained with the help of simple flow diagram.
selenium_ide_121

Working with Grid

In order to work with the Grid, we need to ensure that we follow certain protocol. Below are the major steps involved and let us lookg at each one of them in detail.
  • Configuring Hub
  • Configuring Nodes
  • Develop Script
  • XML Preperation
  • Test Execution
  • Result Analysis

CONFIGURING HUB

Step 1 : Download the latest Selenium Server standalone JAR file from http://docs.seleniumhq.org/download/. Download it by clicking on the version as shown below.
selenium_ide_45
Step 2 : Start the Hub by Launching the Selenium Server using the following command. Now we will use the port '4444' to start the hub.
NOTE : Ensure that there are no other applications that are running on port# 4444.
java -jar selenium-server-standalone-2.25.0.jar -port 4444 -role hub -nodeTimeout 1000
selenium_ide_122
Step 3 : Now open the browser and navigate to the URL http//localhost:4444 from Hub(The system where you have executed Step#2).
selenium_ide_123
Step 4 : Now click on 'console' link and click 'view config'. The config of hub would be shown. As of now we haven't got any nodes, hence we will not be able to see the details.
selenium_ide_124

CONFIGURING NODES

Step 1 : Logon to node(where you would like to execute the scripts) and place the 'selenium-server-standalone-2.42.2' in a folder. We need to point to the selenium-server-standalone JAR when launching the nodes.
Step 2 : Launch FireFox Node using the below command.
java -jar D:\JAR\selenium-server-standalone-2.42.2.jar -role node -hub http://10.30.217.157:4444/grid/register -browser browserName=firefox -port 5555

Where,
D:\JAR\selenium-server-standalone-2.42.2.jar = Location of the Selenium Server Standalone Jar File(on the Node Machine)
http://10.30.217.157:4444 = IP Address of the Hub and 4444 is the port of the Hub
browserName = firefox (Parameter to specify the Browser name on Nodes)
5555 = Port on which Firefox Node would be up and running.
selenium_ide_125
Step 3 : After executing the command, Now come back to Hub. Navigate to the URL - http://10.30.217.157:4444 and the Hub would now display the the node attached to it.
selenium_ide_126
Step 4 : Now let us Launch Internet Explorer Node. For Launching the IE Node, we need to ensure that we have Internet Explorer driver downloaded on the node machine.
Step 5 : To Download the Internet Explorer Driver, navigate to http://docs.seleniumhq.org/download/ and download based on the architecture of your OS. After you have downloaded, unzip the exe file and place it a folder which has to be referred while launching IE nodes.
selenium_ide_131
Step 6 : Launch IE using the below command.
C:\>java -Dwebdriver.ie.driver=D:\IEDriverServer.exe -jar D:\JAR\selenium-server-standalone-2.42.2.jar -role webdriver -hub http://10.30.217.157:4444/grid/register -browser browserName=ie,platform=WINDOWS -port 5558

Where,
D:\IEDriverServer.exe = The location of the downloaded the IE Driver(on the Node Machine)
D:\JAR\selenium-server-standalone-2.42.2.jar = Location of the Selenium Server Standalone Jar File(on the Node Machine)
http://10.30.217.157:4444 = IP Address of the Hub and 4444 is the port of the Hub
browserName = ie (Parameter to specify the Browser name on Nodes)
5558 = Port on which IE Node would be up and running.
selenium_ide_127
Step 7 : After executing the command, Now come back to Hub. Navigate to the URL - http://10.30.217.157:4444 and the Hub would now display the IE node attached to it.
selenium_ide_128
Step 8 : Now let us Launch Chrome Node. For Launching the Chrome Node, we need to ensure that we have Chrome driver downloaded on the node machine.
Step 9 : To Download the Chrome Driver, navigate to http://docs.seleniumhq.org/download/ and navigate to Third Party Browser Drivers area and click on the version number '2.10' as shown below.
selenium_ide_132
Step 10 : Download the Driver based on the type of OS. We will execute it on Windows Environment, hence we will download the Windows Chrome Driver. After you have downloaded, unzip the exe file and place it a folder which has to be referred while launching chrome nodes.
selenium_ide_133
Step 11 : Launch chrome using the below command.
C:\>java -Dwebdriver.chrome.driver=D:\chromedriver.exe -jar D:\JAR\selenium-server-standalone-2.42.2.jar -role webdriver -hub  http://10.30.217.157:4444/grid/register -browser browserName=chrome,platform=WINDOWS -port 5557

Where,
D:\chromedriver.exe = The location of the downloaded the chrome Driver(on the Node Machine)
D:\JAR\selenium-server-standalone-2.42.2.jar = Location of the Selenium Server Standalone Jar File(on the Node Machine)
http://10.30.217.157:4444 = IP Address of the Hub and 4444 is the port of the Hub
browserName = chrome (Parameter to specify the Browser name on Nodes)
5557 = Port on which chrome Node would be up and running.
selenium_ide_129
Step 7 : After executing the command, Now come back to Hub. Navigate to the URL - http://10.30.217.157:4444 and the Hub would now display the chrome node attached to it.
selenium_ide_130

DEVELOP SCRIPT

Step 1 : We will develop a test using TestNG. In the below example we will have launch each one of those browsers using remote webdriver can pass on their capabilities to the driver so that driver has all information to execute on Nodes.
The Browser Parameter would be passed from "XML" File.
package TestNG;

import org.openqa.selenium.remote.DesiredCapabilities;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.*;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
import java.net.URL;
import java.net.MalformedURLException;

import org.openqa.selenium.remote.RemoteWebDriver;

public class TestNGClass 
{
  public WebDriver driver;
  public String URL, Node;
  protected ThreadLocal<RemoteWebDriver> threadDriver = null;
 
  @Parameters("browser")
  @BeforeTest
  public void launchapp(String browser) throws MalformedURLException
  {  
   String URL = "http://www.calculator.net";
   if (browser.equalsIgnoreCase("firefox")) 
   {
  System.out.println(" Executing on FireFox");
  String Node = "http://10.112.66.52:5555/wd/hub";
    DesiredCapabilities cap = DesiredCapabilities.firefox();
  cap.setBrowserName("firefox");

  driver = new RemoteWebDriver(new URL(Node), cap);
  //Puts a Implicit wait, Will wait for 10 seconds before throwing exception
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  
  //Launch website
  driver.navigate().to(URL); 
  driver.manage().window().maximize();  
   } 
   else if (browser.equalsIgnoreCase("chrome")) 
   {
 System.out.println(" Executing on CHROME");
    DesiredCapabilities cap = DesiredCapabilities.chrome();
 cap.setBrowserName("chrome");
 String Node = "http://10.112.66.52:5557/wd/hub";
 driver = new RemoteWebDriver(new URL(Node), cap);
 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
  
 //Launch website
 driver.navigate().to(URL); 
 driver.manage().window().maximize();
   } 
   else if (browser.equalsIgnoreCase("ie")) 
   {
  System.out.println(" Executing on IE");
  DesiredCapabilities cap = DesiredCapabilities.chrome();
  cap.setBrowserName("ie");
  String Node = "http://10.112.66.52:5558/wd/hub";
  driver = new RemoteWebDriver(new URL(Node), cap);
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
 
 //Launch website
 driver.navigate().to(URL); 
 driver.manage().window().maximize();
   }
   else 
   {
      throw new IllegalArgumentException("The Browser Type is Undefined");
   }
 }
  
 
  @Test
  public void calculatepercent()
  {
 driver.findElement(By.xpath(".//*[@id='menu']/div[3]/a")).click();      // Click on Math Calculators  
 driver.findElement(By.xpath(".//*[@id='menu']/div[4]/div[3]/a")).click();     // Click on Percent Calculators
    driver.findElement(By.id("cpar1")).sendKeys("10");   // Enter value 10 in the first number of the percent Calculator
    driver.findElement(By.id("cpar2")).sendKeys("50");  // Enter value 50 in the second number of the percent Calculator    
    driver.findElement(By.xpath(".//*[@id='content']/table/tbody/tr/td[2]/input")).click();     // Click Calculate Button
    String result = driver.findElement(By.xpath(".//*[@id='content']/p[2]/span/font/b")).getText();      // Get the Result Text based on its xpath    
    System.out.println(" The Result is " + result);     //Print a Log In message to the screen
        
    if(result.equals("5"))
    {
     System.out.println(" The Result is Pass");
    }
    else
    {
     System.out.println(" The Result is Fail");
    }      
  }
  
   @AfterTest
   public void closeBrowser() 
   {
    driver.quit();     
   }
}
Step 2 : The Browser parameter will be passed using an XML. Create an XML we need to create the same under project folder.
selenium_ide_134
Step 3 : Select 'File' from 'General' and click 'Next'.
selenium_ide_135
Step 4 : Enter the name of the file and click 'Finish'.
selenium_ide_136
Step 5 : TestNg.XML is created under the project folder as shown below.
selenium_ide_137
Step 6 : Contents of XML are shown below. We create 3 tests and put in a suite and mention parallel="tests" so that all tests would be executed parallelly.
xml version="1.0" encoding="UTF-8"?>

 name="Suite" parallel="tests">
    name="FirefoxTest">
       name="browser" value="firefox" />
      
              name="TestNG.TestNGClass" />
      
name="ChromeTest"> name="browser" value="chrome" /> name="TestNG.TestNGClass" /> name="IETest"> name="browser" value="ie" /> name="TestNG.TestNGClass" />

TEST EXECUTION

Step 1 : Select the created XML and perform a right click and choose 'Run As' >> 'TestNG Suite'.
selenium_ide_139
Step 2 : Now open the Node, where we have launched all the browser nodes. We will be able to see all three browsers in execution simultaneously.
selenium_ide_140

RESULT ANALYSIS

Step 1 : Upon completing the execution, we will be able to analyze the result like any other execution. The result summary is printed on Console. Below is the snapshot of the same.
selenium_ide_142
Step 2 : Navigate to 'Results of Running Suite' Tab and TestNG would display the result summary as shown below.
selenium_ide_141
Step 3 : Upon Generating the HTML, we will be able to see the test results in HTML format.
selenium_ide_143