Skip to main content


Showing posts from August, 2011

QTP - Logging with folder structure

'QTP - Logging with folder structure for cases------
Function PushLog(StepName, StepDetail) Dim dicMetaDescription, intContext Set dicMetaDescription = CreateObject("Scripting.Dictionary") dicMetaDescription("Status") = micGeneral dicMetaDescription("PlainTextNodeName") = StepName dicMetaDescription("StepHtmlInfo") = "" + StepDetail +" "
'Some backdoor settings: 'dicMetaDescription("DllIconIndex") = 206 'dicMetaDescription("DllIconSelIndex") = 206 dicMetaDescription("DllPAth") = "C:\Program Files\HP\QuickTest Professional\bin\ContextManager.dll"
intContext = Reporter.LogEvent("User", dicMetaDescription, Reporter.GetContext) 'Set the new report node as a parent 'From now on, all reports will be added under this node Reporter.SetContext intContext End Function
Function PopLog() 'Now return to the parent level: Reporter.UnSetContext End Function

'So Calling w…

Apache POI - Read Excel - For use of Selenium TestNG DataProvider

Here is the Class designed for reading Excel file...
You can download the JAR files needed to work with Apache POI here.

package Excel;

import java.util.Enumeration;
import java.util.Hashtable;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.dom4j.DocumentException;

public class POI {
int rowIndex = 0, columnIndex = 0;
Workbook wb;
Sheet ws;
Row wr;
String fileName, sheetName;
Hashtable <String, String> [] data = null;

public  void open() throws IOException  {
if (fileName.indexOf("xlsx") < 0) {
wb = new HSSFWorkbook(new FileInputStream(new File(fileName)));
ws = wb.getSheet(sheetNa…

TestNG - DataDriven Custom Framework

Here is the sample code for DataDriven TestNG test...
package Excel;
import; import java.lang.reflect.Array; import java.util.Hashtable;
import org.testng.annotations.Test; import org.testng.annotations.DataProvider; import org.testng.annotations.BeforeClass; import org.testng.annotations.AfterClass; import org.openqa.selenium.*; import org.openqa.selenium.server.SeleniumServer; import com.thoughtworks.selenium.DefaultSelenium; import com.thoughtworks.selenium.Selenium; import Excel.POI; //Class POI contains methods to read Excel file
public class Test1 { SeleniumServer server; Selenium sel; POI poi = new POI(); @BeforeClass public void beforeClass() throws Exception { server = new SeleniumServer(); server.start(); sel = new DefaultSelenium("localhost", 4444, "*iehta", ""); sel.start(); } @DataProvider public Object[][] dp() throws IOException { poi.fileName = "C:\\Users\\shanmugavel.chinnago\\Desktop\\test.xlsx"; poi.sheetNa…