Thursday, October 11, 2012

Cloud Computing

Today, i am surfing about "Cloud Computing" and i found some nice information to start with what is "Cloud Computing"?

Cloud computing is the use of computing resources (hardware and software) that are delivered as a service over a networ (typically the Internet). The name comes from the use of a Cloud-shaped symbol as an abstraction for the complex infrastructure it contains in system diagrams. Cloud computing entrusts remote services with a user's data, software and computation.
There are many types of public cloud computing:
  • Infrastructure as a service (IaaS)
  • Platform as a service (PaaS)
  • Software as a service (SaaS)
  • Storage as a service (STaaS)
  • Security as a service (SECaaS)
  • Data as a service (DaaS)
  • Test environment as a service (TEaaS)
  • Desktop as a service (DaaS)
  • API as a service (APIaaS) 

The above two are nice to go through to get start with what is "Cloud Computing"



Friday, October 5, 2012

Selenium RC vs WebDriver

Selenium RC (Selenium 1):
Selenium uses JavaScript to automate web pages. This lets it interact very tightly with web content, and was one of the first automation tools to support Ajax and other heavily dynamic pages. However, this also means Selenium runs inside the JavaScript sandbox. This means you need to run the Selenium-RC server to get around the same-origin policy, which can sometimes cause issues with browser setup.

WebDriver (Selenium 2):

WebDriver on the other hand uses native automation from each language. While this means it takes longer to support new browsers/languages, it does offer a much closer ‘feel’ to the browser. If you’re happy with WebDriver, stick with it, it’s the future. There are limitations and bugs right now, but if they’re not stopping you, go for it.

Selenium Benefits over WebDriver
  • Supports many browsers and many languages, WebDriver needs native implementations for each new languagte/browser combo.
  • Very mature and complete API
  • Currently (Sept 2010) supports JavaScript alerts and confirms better
Benefits of WebDriver Compared to Selenium
  • Native automation faster and a little less prone to error and browser configuration
  • Does not Requires Selenium-RC Server to be running
  • Access to headlessHTMLUnit can allow really fast tests
  • Great API

Wednesday, September 26, 2012

How to maximize window of the browser?


How to maximize window of the browser?

We can maximize browser window in multiple ways...

By Using WebDriverBackedSelenium, by using Robot class and by webdriver.

1. WebDriverBackedSelenium:
        The very first method which is given in their documentation is using windowMaximize() command of selenium instance.

selenium = new WebDriverBackedSelenium(driver, url);


selenium.windowMaximize();

2. Using Robot class:  We can use robot class to invoke keyboard action to maximize browser window.

Robot robot = new Robot();
// Press ALT and SPACE Keys

robot.keyPress(KeyEvent.VK_ALT);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_ALT);
robot.keyRelease(KeyEvent.VK_SPACE);
Thread.sleep(1000);
//Press down arrow keys to move to select Maximize option in menu

robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
Thread.sleep(100);

robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
Thread.sleep(100);

robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
Thread.sleep(100);

robot.keyPress(KeyEvent.VK_DOWN);
robot.keyRelease(KeyEvent.VK_DOWN);
Thread.sleep(100);
//Press enter to invoke the Maximize menu option

robot.keyPress(KeyEvent.VK_ENTER);
robot.keyRelease(KeyEvent.VK_ENTER);
}

3. Using WebDriver and dimensions:

public static void maximizeWindow(){

        Toolkit t = Toolkit.getDefaultToolkit();
        org.openqa.selenium.Dimension screenResolution = new   org.openqa.selenium.Dimension((int)t.getScreenSize().getWidth(), (int)t.getScreenSize().getHeight());

       driver.manage().window().setSize(screenResolution);
}



4. WebDriver:

driver.manage().window().maximize();

























Tuesday, September 18, 2012

What is Defect Density?


DEFINITION
Defect Density is the number of confirmed defects detected in software/component during a defined period of development/operation divided by the size of the software/component.

ELABORATION
The ‘defects’ are:
  • confirmed and agreed upon (not just reported).
  • Dropped defects are not counted.
The period might be for one of the following:
  • for a duration (say, the first month, the quarter, or the year).
  • for each phase of the software life cycle.
  • for the whole of the software life cycle.
The size is measured in one of the following:
  • Function Points (FP)
  • Source Lines of Code
DEFECT DENSITY FORMULA











USES
  • For comparing the relative number of defects in various software components so that high-risk components can be identified and resources focused towards them.
  • For comparing software/products so that quality of each software/product can be quantified and resources focused towards those with low quality.

Sunday, September 16, 2012

How to pass parameters in selenium RC using TestNG

How to pass parameters in selenium RC using TestNG


We can parametrize our test cases using TestNG in Selenium RC in two ways

Pass the data from testng.xml file...

1. using @parameters

public class first_class {
    private Selenium selenium;
    public String url = "http://google.com/";   

    @Parameter ({ "url" })
    @Test   
    public void Test(String url) throws MalformedURLException { 
        System.out.println("In Test Methos");
        selenium.open(url); 
        System.out.println(selenium.getTitle() + "in in Test Method");
        selenium.close();
    }
    }


2. using @DataProvider


import org.openqa.selenium.server.RemoteControlConfiguration;
import com.thoughtworks.selenium.*;
import org.openqa.selenium.server.*;
import org.testng.annotations.*;

import java.io.*;
import java.sql.*;



public class TestExcel extends SeleneseTestBase {

@DataProvider(name="DP1")
public Object[][] createData(){
Object[][] retObjArr = {{"testuser1","password1"},
{"testuser2","password2"},
{"testuser3","password3"},
{"testuser4","password4"},
{"testuser5","password5"},
};
return(retObjArr);
}


private SeleniumServer seleniumServer;
Selenium selenium;

@BeforeClass
public void setUp()throws Exception{

RemoteControlConfiguration rc = new RemoteControlConfiguration();
rc.trustAllSSLCertificates();
seleniumServer = new SeleniumServer(rc);
selenium = new DefaultSelenium("localhost",4444,"*iexplore","http://www.yahoo.com");
seleniumServer.start();
selenium.start();
}

@Test (dataProvider = "DP1")
public void testEmployeeData(String username, String password){
selenium.open("https://login.yahoo.com/config/mail?.src=ym&.intl=us/");
selenium.type("username", username);
selenium.type("passwd",password);
selenium.click(".save");
selenium.waitForPageToLoad("30000");
assertTrue(selenium.isTextPresent("Hi,"+username));
selenium.click("_test_sign_out");
selenium.waitForPageToLoad("30000");

}
@AfterTest
public void tearDown() throws InterruptedException{
selenium.stop();
seleniumServer.stop();

}

Saturday, September 15, 2012

How to take screenshot of a page using webdriver?

How to take screenshot of a page using webdriver?

 Here is a sample code to get the screenshot of the current browser window using webdriver ...

The file name with the specific path should mentioned. Either it should be dynamic or we can hard-code the file name ( every time we run this code, the file will be overriden).


    public static void snapshot() throws IOException{
       
        File fi = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(fi, new File("file name with the path should be mentioned here... "));
    }

It is very simple and we call this method when ever we need (Pass or Fail cases) to take the screenshots of the pages.

Hope this is helpful.. :)

How to maximize window size of current window using webdriver?

How to maximize window size of current window  using webdriver?

Generally when we start the browsers, it will open based on its previous state. Some times it is customized to certain size (width and height) manually. So in order to make the browser opens in a maximized window, we need to use Toolkit class.

Maximize window option will allows the user to see the complete application under test.

Here is the snippet to achieve the maximized window using Webdriver...

Here driver is WebDriver object for Firefox or IE driver.

WebDriver driver = new Firefoxdriver();

public static void maximizeWindow(){
        Toolkit t = Toolkit.getDefaultToolkit();
        org.openqa.selenium.Dimension screenResolution = new org.openqa.selenium.Dimension((int)t.getScreenSize().getWidth(), (int)t.getScreenSize().getHeight());
        driver.manage().window().setSize(screenResolution);
   
    }