Back To Normal

Subscribe To Our E-Mail Newsletter

Wednesday, September 26, 2012

Top Five Testing Blogs

I have found top five testing blogs for software testing . This blogs are really useful for software tester who want to know or practice new concepts .

James Bach  : http://www.satisfice.com/blog/

Agile : http://agiletesting.blogspot.in/

Martin Fowler : http://martinfowler.com/

Tester Tested : http://testertested.blogspot.in/

Test This blog : http://www.testthisblog.com/

Some useful Top 100 list will be listed in below urls.

http://www.testingminded.com/2010/04/top-100-software-testing-blogs.html

Read More


Connecting Excel as Database in java

User can connect excel as database by using excel drivers and perform insert , read operations.
import java.io.*;
import java.sql.*;

public class ExcelReadTest{

public static void main(String[] args){

Connection connection = null;

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection con = DriverManager.getConnection( "jdbc:odbc:exceltest" );

Statement st = con.createStatement();

ResultSet rs = st.executeQuery( "Select * from [Sheet1$]" );

ResultSetMetaData rsmd = rs.getMetaData();

int numberOfColumns = rsmd.getColumnCount();

while (rs.next()) {

for (int i = 1; i <= numberOfColumns; i++) {

if (i > 1) System.out.print(", ");

String columnValue = rs.getString(i);

System.out.print(columnValue);

}

System.out.println("");

}
st.close();

con.close();

} catch(Exception ex) {

System.err.print("Exception: ");

System.err.println(ex.getMessage());

}

}

}
To insert data :
"insert into [Sheet1$] (ColumnName1,ColumnName2) values ('"+sValue1+"','"sValue2"')"
Read More


Tuesday, September 25, 2012

How to read Excel data by using POI jars

Public List ReadExcel2010(String sFilename)


{

List SheetData = new ArrayList();

InputStream fs = new FileInputStream(filename);

XSSFWorkbook wb = new XSSFWorkbook(fs);

XSSFSheet sheet = wb.getSheetAt(0);

try

{

Header header = sheet.getHeader();
int rowsCount = sheet.getLastRowNum();

System.out.println("Total Number of Rows: " + (rowsCount + 1));

for (int i = 0; i <= rowsCount; i++) {

List data = new ArrayList();

Row row = sheet.getRow(i);

int colCounts = row.getLastCellNum();

System.out.println("Total Number of Cols: " + colCounts);

for (int j = 0; j < colCounts; j++) {

Cell cell = row.getCell(j);

data.add(cell );

System.out.println("[" + i + "," + j + "]=" + cell.getStringCellValue());

}

Sheetdata.add(data);

}
} catch (Exception ex) {

java.util.logging.Logger.getLogger(FieldController.class.getName()).log(Level.SEVERE, null, ex);

} finally {

try {

fs.close();

} catch (IOException ex) {

java.util.logging.Logger.getLogger(FieldController.class.getName()).log(Level.SEVERE, null, ex);

}

}
return Sheetdata;

}
Read More


Tuesday, August 21, 2012

Export - Import in Internet Explorer using Selenium Web Driver


Handling Export and Import by using Keys.
WebElement link = driver.findElement(By.xpath("myxpath"));
ExportAndSaveFileInIE(link, Path);

public static void ExportSaveFileInIE(WebElement element,String sFilepath) throws

InterruptedException{
    try {

      Robot robot = new Robot();
       //Focus the Element
       element.sendKeys("");

      //Press Enter Key to populate Window          
      robot.keyPress(KeyEvent.VK_ENTER);
      robot.keyRelease(KeyEvent.VK_ENTER);
   
      //Wait For Dialog        
      Thread.sleep(2000);

     //press s key to save          
      robot.keyPress(KeyEvent.VK_S);
      robot.keyRelease(KeyEvent.VK_S);
      Thread.sleep(2000);
     //press enter to save the file with specified name and in location
     sFilepath = sFilepath.ToUpperCase()
     for (int i=0;i<=sFilepath .length();i++)
     {
      Char ch = sFilepath.ChartAt(i);
      int iascvalue = ch;
      switch(ch)
{
      Case ":"
       robot.keyPress(KeyEvent.VK_SHIFT);
       robot.keyPress(KeyEvent.VK_COLON);
       robot.keyRelease(KeyEvent.VK_COLON);
       robot.keyRelease(KeyEvent.VK_SHIFT);
      Case "\"
    ....
      default
        robot.keyPress(iascvalue );
      robot.keyRelease(iascvalue );
}

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

 } catch (AWTException e) {

            e.printStackTrace();
  }

Read More


Thursday, August 16, 2012

Triggers


Oracle lets you define procedures called triggers that run implicitly when an INSERT, UPDATE, or DELETE statement is issued against the associated table or, in some cases, against a view, or when database system actions occur. These procedures can be written in PL/SQL or Java and stored in the database, or they can be written as C callouts.

Triggers are similar to stored procedures. A trigger stored in the database can include SQL and PL/SQL or Java statements to run as a unit and can invoke stored procedures. However, procedures and triggers differ in the way that they are invoked. A procedure is explicitly run by a user, application, or trigger. Triggers are implicitly fired by Oracle when a triggering event occurs, no matter which user is connected or which application is being used.

Examples:

CREATE TRIGGER schema.trigger_name
    BEFORE
    DELETE OR INSERT OR UPDATE
    ON schema.table_name
       pl/sql_block
Read More


Monday, August 13, 2012

Java : Test Automation Questions and Answers

1. String Immutable
The absolutely most important reason that String is immutable is that it is used by the
class loading mechanism, and thus have profound and fundamental security aspects.

Had String been mutable, a request to load "java.io.Writer" could have been changed to load
"vijay.co.DiskErasingWriter"
Details: http://javarevisited.blogspot.in/2010/10/why-string-is-immutable-in-java.html

2. Two main mehod in single class

Ans : Its possible with different retun type and parameters (method overloading )
3. String Memory allocation vs StringBuffer vs String Builders

String sname ='vijay';

sname ='ragavan';
Details: http://javarevisited.blogspot.in/2011/07/string-vs-stringbuffer-vs-stringbuilder.html

5. Usage of Interface
Often interfaces are touted as an alternative to multiple class inheritance. While
interfaces may solve similar problems, interface and multiple class inheritance are quite
different animals, in particular:
A class inherits only constants from an interface.
A class cannot inherit method implementations from an interface.
The interface hierarchy is independent of the class hierarchy. Classes that implement the
same interface may or may not be related through the class hierarchy. This is not true for
multiple inheritance.

Usage of Interfaces :
You use an interface to define a protocol of behavior that can be implemented by any class
anywhere in the class hierarchy. Interfaces are useful for the following:
Capturing similarities between unrelated classes without artificially forcing a class relationship
Declaring methods that one or more classes are expected to implement
Revealing an object's programming interface without revealing its class. (Objects such as these are called anonymous objects and can be useful when shipping a package of classes to other developers.)
6. Garbage collector in java and usage.
Java takes a different approach; it handles deallocation for you automatically. The technique that accomplishes this is called garbage collection. It works like this: when no references to an object exist, that object is assumed to be no longer needed, and the memory occupied by the object can be reclaimed.
The finalize( ) Method
Sometimes an object will need to perform some action when it is destroyed. For example, if
an object is holding some non-Java resource such as a file handle or window character font,
then you might want to make sure these resources are freed before an object is destroyed

Keyword: System.gc();
Read More


Thursday, August 2, 2012

How to Clear cookies from internet Explorer by selenium webdriver?:


User can enable Ie capabilities then clear cookies 

DesiredCapabilities caps = DesiredCapabilities.internetExplorer(); caps.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true); WebDriver driver = new InternetExplorerDriver(caps);
driver.manage().deleteAllCookies()

If above one is not woking then U can go for Windows command level clearnace:

RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2

Java : Runtime.getRuntime().exec("RunDll32.exe InetCpl.cpl,ClearMyTracksByProcess 2");

Read More


Different Types of drivers in Selenium Web Driver


HtmlUnit Driver
FireFox Driver
Internet ExplorerDriver
Chrome Drivers.

 In details of these drivers , U can go through following links,
  --http://marakana.com/bookshelf/selenium_tutorial/selenium2.html
Read More


Selenium Web driver : Implicit and Explicit Wait

Implicit wait :

driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);


Explicit Wait: 

Wait<WebDriver> wait = new WebDriverWait(driver, 30);
WebElement element= wait.until(visibilityOfElementLocated(By.id("some_id")));
Read More


Friday, July 27, 2012

Find child elements : Selenium Web driver


When same object is getting duplicated for N number of parent, then user can refer parent and child relationship to identify the object in browser.

WebElement bodyElement = driver.findElement(By.id("body"));
WebElement bodyElement1 = bodyElement.findElement(By.id("body"));
System.out.println(bodyElement1.findElement(By.id("TotalScore")).getText());

User want to read all child elements of div(parent) container by using following methods.

WebElement bodyElement = driver.findElement(By.id("body"));  
List divElements = bodyElement.findElements(By.className("div"));
for(WebElement childDiv : divElements){
 List fieldSetEle = childDiv.findElements(By.tagName("fieldset"));
 System.out.println(childDiv.getTagName()+":"+fieldSetEle.size());
    }  
Read More


Thursday, July 26, 2012

Types of locaters in Selenium Webdriver

Types :  
  • Finding element by id
  • Finding elemeny by name 
  • Finding element by link.
  • Finding element by Xpath.
  • Finding element by CSS
  • Findidng element by DOM
  • Finding child eleme
Finding element by id :

 
For Example : driver.findElement(By.id(userid));

 
Finding elemeny by name :

 
driver.findElement(By.name("logon"));

 
Finding element by link:

 
driver.findElement(By.linkText("rank list"));

 
driver.findElement(By.partialLinkText("rank"));

 
Finding element by Xpath:

 
-- To find xpath user can use fire bug.

 
//table/tr[2]/td/input

 
//input[@id='item_quantity']

 
(//table[@name='cart']//input)[2]

 
//input[contains(@class,'required')]

 
//input[contains(@class,'required') and type='text']

 
some more options..

 
// xpath iposition

 
//Xpath relative

 
Finding element by CSS

 
driver.findElements(By.css("input[class~='required']"));
driver.findElements(By.class("required"));

 
Finding elements by DOM

 
document.forms[0].elements[0]

 
document.forms['loginOut'].elements['username']

 
Read More


Wednesday, May 23, 2012

How to Identify popup window in Selenium Webdriver ?





1. First Check whether its popup window or IFrame window by using IE Developer or Find bug tools.

2. If its popup window then use following code :
driver.findElement(By.xpath("")).click();

Set s=driver.getWindowHandles();

This method will help to handle of opened windows other than parent



Iterator ite=s.iterator();

while(ite.hasNext())

{

String popupHandle=ite.next().toString();

if(!popupHandle.contains(mwh))

{

driver.switchTo().window(popupHandle);

/**/here you can perform operation in pop-up window**

//After finished your operation in pop-up just select the main window again

driver.switchTo().window(mwh);

}

}



This method will help to filter out of all opened windows



1) String parentWindowHandle = browser.getWindowHandle(); // save the current window handle.

WebDriver popup = null;

Iterator windowIterator = browser.getWindowHandles();

while(windowIterator.hasNext()) {

String windowHandle = windowIterator.next();

popup = browser.switchTo().window(windowHandle);

if (popup.getTitle().equals("Google") {

break;

}

}



2) Uncomment code for the same popup,



//action in popup "Google".

popup.findElement(By.name("q")).sendKeys("Thoughtworks");

//action in popup "Google".

popup.findElement(By.name("btnG")).submit();"



3) After the popup actions, switch the driver back to the parent window,



browser.close(); // close the popup.

browser.switchTo().window(parentWindowHandle); // Switch back to parent window.





If its IFrame then use following line.



String parentWindowHandle = driver.getWindowHandle();

driver.switchTo().Frame(driver.findelement(by.id("iframeid")));
// perform ur actions.
//revert back to parent control

driver.switchTo().window(parentWindowHandle);

Read More


Thursday, May 10, 2012

SQL: Set operators

Types of set Operators in SQL :
    1. Union
    2. Union ALL
    3. Intersect.
Read More


Tuesday, April 24, 2012

Select Object from Drop Down : Web driver


Select Object from Drop Down

WebElement select = driver.findElement(By.name("select"));

List options = select.findElements(By.tagName("option"));

for(WebElement option : options){

if(option.getText().equals("Name you want"){

option.click();

break;

}
Read More


Friday, April 20, 2012

Web driver For Internet Explorer.

For loading URL:

DesiredCapabilities ieCapabilities = DesiredCapabilities.internerExplorer();
ieCapabilities .setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_INNORING_SECURITY_DDOMAINS)
Read More


How to Create Test suite in Junit ?

import junit.framework.Testcase

public class TestSuite extends Testcase
{
public static Test suite()
{
TestSuite suite = new Testsuite();

suite.addTestSuite(Testcase1.class);

return suite;

}
public static void main (String args[])
{
 TestRunner.run(suite());
}

}
Read More


560 Free Online Courses

Top 200 universities launched 500 free online courses.  Please find the list here .