Saturday, May 16, 2015

Selenium with Python : Basic Script

#Basic Script to start Selenium with  Python

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

d = webdriver.Firefox()

d.get("http://www.google.com")

assert "Google" in d.title

webElement = d.find_element_by_name("q")

webElement.send_keys("Tester")

webElement.send_keys(Keys.RETURN)

assert "No results found" not in d.page_source

d.close()

Tuesday, April 21, 2015

Performance Bottle Necks

There are various type of Performance Bottle Necks. These could be  system, database, or application related.

System-related bottlenecks may lead to infrastructure changes such as increasing the memory available to the application, reducing CPU consumption, increasing or decreasing thread pool sizes, revising database pool sizes, and reconfiguring network settings.

Database-related bottlenecks may lead to analyzing database I/O operations, top queries from the application under test, profiling SQL queries, introducing  additional indexes, running statistics gathering, changing table page sizes and locks, and a lot more.

Application-related changes might lead to activities such as refactoring application components, reducing application memory consumption and database round trips.

Wednesday, February 18, 2015

Implicit Wait Example

/*
 *
 * @Author : Gaurav Khanna
 * 
 */

package webdriverScripts;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class ImplicitWaitTime {

    public static void main(String... args) {

        WebDriver driver = new FirefoxDriver();

        // Wait for 10 Secs
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

        driver.get("www.google.com");
    }
}

Tuesday, February 17, 2015

Global Wait Example

/*
 *
 * @Author : Gaurav Khanna
 * 
 */

package webdriverScripts;

import java.util.concurrent.TimeUnit;

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

public class GlobalWait {

    @Test
    public void testglobalWait() {

        //
        System.out.println("Hello!!! how are you?");

        //
        WebDriver webDriver = new FirefoxDriver();

        //
        webDriver.get("http://not-just-a-tester.blogspot.in/");

        // Wait for elements that haven't appeared yet
        webDriver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);

        //
        System.out.println("I am good!!!");

    }

}

Get Text of Web Element

/*
 *
 * @Author : Gaurav Khanna
 * 
 */

package webdriverScripts;

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

public class GetText {

    //
    WebDriver webDriver = new FirefoxDriver();

    @Test
    public void testgetText() {

        //
        webDriver.get("http://www.google.com");

        //
        WebElement searchButton = webDriver.findElement(By.name("btnK"));

        //
        System.out.println(searchButton.getText());
    }
}