Webdriver Script036 : Creating IsElementPresent() method

/*********************************************************************

 Script Summary

 Title  : Webdriver Script036 : Creating IsElementPresent() method
 Author : Gaurav Khanna

 *********************************************************************/

package com.gaurav.webdriver;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class s036_IsElementPresent {

    // Declaring variable 'webDriver' of WebDriver Type
    WebDriver webDriver;

    // Declaring variable 'baseUrl' of String Type
    String baseUrl;

    @BeforeMethod
    public void startUp() throws Exception {

        // Initializing FireFox Driver
        webDriver = new FirefoxDriver();

        // Assigning URL to variable 'baseUrl'
        baseUrl = "http://book.theautomatedtester.co.uk";
    }

    @Test
    public void tests036_IsElementPresent() throws Exception {

        // Open the link
        webDriver.get(baseUrl);

        // Maximize browser window
        webDriver.manage().window().maximize();

        //
        if (webDriver.findElement(By.id("verifybutton")) != null) {
            System.out.println("Pass");
        } else {
            System.out.println("Fail");
        }
    }

    @AfterMethod
    public void shutDown() throws Exception {

        // This will close the browser
        webDriver.quit();
    }

}

Webdriver Script029 : Running Multiple Tests

/*********************************************************************

Script Summary

Title  : Webdriver Script029 : Running Multiple Tests
Author : Gaurav Khanna

1. Initialize 2 Browser
2. Open different urls in all browsers.
3. close all instances using quit() method

 *********************************************************************/


Webdriver Script026 : Handling Radio Buttons

/*********************************************************************

Script Summary

Title  : Webdriver Script026 : Handling Radio Buttons
Author : Gaurav Khanna

1. Set the Base URL to "http://www.quackit.com/html/codes/html_radio_button.cfm"
2. Retreive the list of checkboxes present.
3. Click on checkbox

 *********************************************************************/


package com.gaurav.webdriver;

import java.util.List;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class s026_HandlingRadioButton {

    // Declaring variable 'webDriver' of WebDriver Type
    WebDriver webDriver;

    // Declaring variable 'baseUrl' of String Type
    String baseUrl;

    @BeforeMethod
    public void startUp() throws Exception {

        // Initializing FireFox Driver
        webDriver = new FirefoxDriver();

        // Assigning URL to variable 'baseUrl'
        baseUrl = "http://www.quackit.com/html/codes/html_radio_button.cfm";
    }

    @Test
    public void tests026_HandingRadioButton() throws Exception {

        webDriver.get(baseUrl);

        List<WebElement> radio_button = webDriver.findElements(By
                .name("preferred_color"));

        System.out.println("radio_button");

        System.out.println("Printing Value : "
                + radio_button.get(2).getAttribute("value"));

        System.out.println("Is Radio Button checked : "
                + radio_button.get(2).getAttribute("checked"));

        // Check the radio button if it is unchecked
        radio_button.get(2).click();

        System.out.println("Is Radio Button checked : "
                + radio_button.get(2).getAttribute("checked"));

    }

    @AfterMethod
    public void shutDown() throws Exception {

        // This will close the browser
        webDriver.quit();
    }

}

Webdriver Script020 : Data Driven Testing from Excel

/*********************************************************************

Script Summary

 Title  : Webdriver Script020 : Data Driven Testing from Excel
 Author : Gaurav Khanna

 1. Open the excel file.
 2. Store Username and Password in list.
 3. Prints username and password.

 *********************************************************************/


Basic Script 2

package webdriverScripts.others;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;

public class BasicScript2 {

// Declaring variable 'webDriver' of WebDriver Type
WebDriver webDriver;

// Declaring baseURL variable of String Type
String baseUrl;

@Test
public void testbasicScript2() {

// Initializing FireFox Driver
webDriver = new FirefoxDriver();

// Assigning URL to variable 'baseUrl'
baseUrl = "http://www.webmath.com/";

// Wait for 30 seconds
webDriver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

// Open the link
webDriver.get(baseUrl);

// Click on element
webDriver.findElement(By.id("www-content-wrap")).click();

// Select `Simple Interest` option from dropdown
new Select(webDriver.findElement(By.id("topicItem"))).selectByVisibleText("Interest, Simple");

// Click on element
webDriver.findElement(By.cssSelector("option[value=\"simpinterest.html\"]")).click();

// Click on element
webDriver.findElement(By.name("principal")).clear();

// Click on element
webDriver.findElement(By.name("principal")).sendKeys("1000");

// Click on element
webDriver.findElement(By.name("interest")).clear();

// Click on element
webDriver.findElement(By.name("interest")).sendKeys("1");

// Click on element
webDriver.findElement(By.name("desired_time")).clear();

// Click on element
webDriver.findElement(By.name("desired_time")).sendKeys("5");

// Click on element
webDriver.findElement(By.xpath("//input[@value='Find the amount of interest']")).click();

webDriver.quit();
}

}

Jmeter : Interleave Controller

Please download the example script from below link :

https://www.dropbox.com/sh/c0utecr4t87ez7v/2m4OIULEkV

Jmeter : Random Order Controller

Please download the example script from below link :

https://www.dropbox.com/sh/c0utecr4t87ez7v/2m4OIULEkV

Jmeter : Random Controller

The Random Logic Controller acts similarly to the Interleave Controller, except that instead of going in order through its sub-controllers and samplers, it picks one at random at each pass.

You can download sample script from E-Books section

Jmeter : Once Only Controller

The Once Only Logic Controller tells JMeter to process the controller(s) inside it only once per Thread, and pass over any requests under it during further iterations through the test plan.

The Once Only Controller will now execute always during the first iteration of any looping parent controller. Thus, if the Once Only Controller is placed under a Loop Controller specified to loop 5 times, then the Once Only Controller will execute only on the first iteration through the Loop Controller (ie, every 5 times). Note this means the Once Only Controller will still behave as previously expected if put under a Thread Group (runs only once per test per Thread), but now the user has more flexibility in the use of the Once Only Controller.

For testing that requires a login, consider placing the login request in this controller since each thread only needs to login once to establish a session.

You can download sample script from E-Books section

Jmeter : Loop Controller

If you add Generative or Logic Controllers to a Loop Controller, JMeter will loop through them a certain number of times, in addition to the loop value you specified for the Thread Group. For example, if you add one HTTP Request to a Loop Controller with a loop count of two, and configure the Thread Group loop count to three, JMeter will send a total of 2 * 3 = 6 HTTP Requests. 

You can download sample script from E-Books section

Jmeter : Simple Controller

The Simple Logic Controller lets you organize your Samplers and other Logic Controllers. Unlike other Logic Controllers, this controller provides no functionality

You can download sample script from E-Books section

Test Cases for Shopping Cart

- Adding Item in shopping cart
- Deleting item from shopping cart
- Verifying Item count after adding and deleting
- Verifying Coupon codes-If your application supports that(Coupons help you redeem the points)
- Verifying Sales price,MRP as as per data you have been provided
- Verifying Payment Methods-Paypal,Google Checkout,Other payment methods
- Verifying purchasing of any item when it is not in stock

Test Cases for Pen

- Check the pen type
- Check the pen cap is present or not
- Check the pen ink is filled or not
- Check the pen writing or not
- Check the ink color i.e black or blue
- Check the pen color
- Check weather the pen is used to write all types of papers or not
- Check the ink capacity of the pen
- Check the pen product by fiber or plastic
- Check the Dimension of the pen
- Check the logo of the pen maker,

Test Cases for Text Editor

- Check for the successful message by enter characters
- Check for the successful message by enter numbers
- Check for the successful message by enter special characters
- Check whether the selected text become bold or not by click on Bold icon
- Check whether the selected text become bold or not by press ctrl+B
- Check whether the selected text become Italic or not by click on Italic icon
- Check whether the selected text become Italic or not by press ctrl+I
- Check whether the selected text become strikethrough or not by click on strikethrough icon
- Check whether undo is working or not
- Check for the redo is working or not after undo
- Check for the redo is working or not before undo
- Check whether bullets are applied for selected text lines
- Check whether numbers are applied for selected text lines
- Check whether the selected bold text become unbold or not by click on Bold icon
- Check whether the selected bold text become unbold or not by press ctrl+B
- Check whether the selected Italic text become normal or not by click on Italic icon
- Check whether the selected Italic text become normal or not by press ctrl+I
- Check whether the selected strithrough text become normal or not by click on strikethrough icon

How LoadRunner Addresses the Performance Testing?

Following points explains how LoadRunner Addresses the Performance Testing :

- LoadRunner reduces personnel requirements by replacing human users with virtual users or Vusers. These Vusers emulate the behavior of real users— operating real applications.

- Because numerous Vusers can run on a single computer, LoadRunner reduces the amount of hardware required for testing.

- The HP LoadRunner Controller allows you to easily and effectively control all the Vusers—from a single point of control.


Various Components of LoadRunner

Vuser Generator

Vuser Generator is the Script generation component of LoadRunner. This component has two main things and are described below:

Vusers: In the scenario, LoadRunner replaces human users with virtual users or Vusers. When you run a scenario, Vusers emulate the actions of human users working with your application.
While a workstation accommodates only a single human user, many Vusers can run concurrently on a single workstation. In fact, a scenario can contain tens, hundreds, or even thousands of Vusers.


What is the purpose of a Load Test?

The purpose of any load test should be clearly understood and documented. A load test usually fits into one of the following categories:

- Quantification of risk: Determine, through formal testing, the likelihood that system performance will meet the formal stated performance expectations of stakeholders, such as response time requirements under given levels of load. This is a traditional Quality Assurance (QA) type test. Note that load testing does not mitigate risk directly, but through identification and quantification of risk, presents tuning opportunities and an impetus for remediation that will mitigate risk.

- Determination of minimum configuration: Determine, through formal testing, the minimum configuration that will allow the system to meet the formal stated performance expectations of
stakeholders - so that extraneous hardware, software and the associated cost of ownership can be minimized. This is a Business Technology Optimization (BTO) type test.


What is Load Test?

Load Tests are end to end performance tests under anticipated production load. The objective of such tests are to determine the response times for various time critical transactions and business processes and ensure that they are within documented expectations (or Service Level Agreements - SLAs). Load tests also measures the capability of an application to function correctly under load, by measuring transaction pass/fail/error rates.

Load Tests are major tests, requiring substantial input from the business, so that anticipated activity can be accurately simulated in a test environment. If the project has a pilot in production then logs from the pilot can be used to generate ‘usage profiles’ that can be used as part of the testing process, and can even be used to ‘drive’ large portions of the Load Test.