Sunday, July 6, 2014

Webdriver Script : Webdriver Wait Commands

There are different type of Webdriver Wait commands which are useful for an effective scripting and can avoid using the Thread.sleep() comamnds.

After searching, I have created a sample script explaining the types of wait commands. Mainly commands are categorize in two parts :

1. Using WebDriver.manage().timeouts()

- implicitlyWait : The ImplicitWait will tell the webDriver to poll the DOM for a certain duration when trying to find the element, this will be useful when certain elements on the webpage will not be available immediately and needs some time to load. By default it ill take the value to 0, for the life of the WebDriver object instance through out the test script.

- pageLoadTimeout : Sets the amount of time to wait for a page load to complete before throwing an error. If the timeout is negative, page loads can be indefinite.

- setScriptTimeout : Sets the amount of time to wait for an asynchronous script to finish execution before throwing an error. If the timeout is negative, then the script will be allowed to run indefinitely.

2. Using support.ui

- FluentWait : Each FluentWait instance defines the maximum amount of time to wait for a condition, as well as the frequency with which to check the condition. Furthermore, the user may configure the wait to ignore specific types of exceptions whilst waiting, such as NoSuchElementExceptions when searching for an element on the page.

- ExpectedConditions : Models a condition that might reasonably be expected to eventually evaluate to something that is neither null nor false. Examples would include determining if a web page has loaded or that an element is visible. Note that it is expected that ExpectedConditions are idempotent. They will be called in a loop by the WebDriverWait and any modification of the state of the application under test may have unexpected side-effects.

Sunday, June 29, 2014

Fake Testers

Hi Readers,

This article is not related to any tutorial but yes its a lesson learn and still i am learning. In my career, I have seen so many tester mates whom I feel are fake tester, not because I don't like them but because of the ways they find and apply to sign off things from there end. I am surprised how easily they are able to do so but sad that it affects the image of other testers. Hence, I am sharing few ways used by these fake testers to get there job done.

- Blocker ! Blocker ! We are blocked : This is one the common instance, I have seen done by few fake testers. They simply run 1 flow gets a blocker in form of Blank/Error pages and start running all over the floor without even studying the logs and trying to find out what could be the RCA of it.

- We need More time : Yes, we need more time to test this requirement. This requirement is too complex to test. This is one of the thing I noticed quite regularly when a new release is about to start. Main point of concern is the time which is not justifiable. I agree that a requirement is complex but ultimately there is a time constraint which is required to be met for a release cycle. Hence, working on new requirements rather than demanding of more time will reduce the burden.

- It was working fine earlier : Wooo... This point will definitely put me under radar whether i am on tester side or other team. However, i am true tester and want to deliver a quality product. There are situation where build arrive thrice in a day. On the contrary, build also arrive once in a week. Now, during this course of time, if someone test a requirement, assures that he/she has tested it completely and then comes a defect in new build which was a basic flow to be covered and is missed, fake tester say this line "It was working fine in previous build". Goosh !! Why to lie ? This is the common thing I see so often and feel sad.

Saturday, June 14, 2014

Group Tests

package com.gaurav.testNG;

import org.testng.annotations.*;

public class GroupTest {

    @Test(groups = "method1")
    public void testingMethod1() {
        System.out.println("Method - testingMethod1()");

    @Test(groups = "method2")
    public void testingMethod2() {
        System.out.println("Method - testingMethod2()");

    @Test(groups = "method1")
    public void testingMethod1_1() {
        System.out.println("Method - testingMethod1_1()");

    @Test(groups = "method4")
    public void testingMethod4() {
        System.out.println("Method - testingMethod4()");


Friday, June 13, 2014

Select Record


Title  : Selecting Records
Author : Gaurav Khanna


package com.gaurav.jdbc;

import java.sql.*;
import org.testng.annotations.Test;

public class SelectRecord {

    public void testselectRecord() throws SQLException, ClassNotFoundException {

        // Causes the class "oracle.jdbc.driver.OracleDriver" to be

        System.out.println("Oracle JDBC Driver Registered!");

        // Declaring Connection type variable

        Connection connection = null;

        Statement stmt;

        // Create Connection Object
        connection = DriverManager.getConnection(
                "jdbc:oracle:thin:@localhost:1521:orcl", "gaurav", "gaurav");

        if (connection != null) {

            System.out.println("Database Connection Successful !! ");

            System.out.println("Creating statement...");

            stmt = connection.createStatement();

            String sql = "SELECT id, first, last, age FROM Registration";

            ResultSet rs = stmt.executeQuery(sql);

            while ( {
                // Retrieve by column name
                int id = rs.getInt("id");
                int age = rs.getInt("age");
                String first = rs.getString("first");
                String last = rs.getString("last");

                // Display values
                System.out.print("ID: " + id);
                System.out.print(", Age: " + age);
                System.out.print(", First: " + first);
                System.out.println(", Last: " + last);


        // Closing Statement and Connection