Sunday, June 16, 2013

Reading and Writing in an existing Excel Sheet

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;

public class Excel_reading {

/**
* @param args
* @throws IOException
* @throws InvalidFormatException
*/
public static void main(String[] args) throws IOException, InvalidFormatException {
Excel_reading Exred =new Excel_reading();
Exred.excel_read();


}

public void excel_read() throws IOException, InvalidFormatException
{
String cell_val;
InputStream FIS= new FileInputStream("Testdata.xls");
HSSFWorkbook WorkBookObj=(HSSFWorkbook) new WorkbookFactory().create(FIS);
HSSFSheet SheetObj = WorkBookObj.getSheet("Testdata");
HSSFRow RowObj=SheetObj.getRow(0);
HSSFCell CellObj=RowObj.getCell(0);

for (int k=0; k<=10;k++)
{
RowObj=SheetObj.getRow(k);
RowObj.getCell(1,RowObj.CREATE_NULL_AS_BLANK);
System.out.println(RowObj.getCell(0).getStringCellValue());

for (int j=0; j<=10; j++)
{
if ( RowObj.getCell(1).getStringCellValue().equalsIgnoreCase(""))
{
HSSFCell CellObj1;
RowObj=SheetObj.getRow(k);
CellObj=RowObj.createCell(1);
CellObj.setCellValue("Used");
FileOutputStream FOS =new FileOutputStream("Testdata.xls");
WorkBookObj.write(FOS);
FOS.close();
}
FIS.close();
   }
}
   }
}




Out Put
Fig.1 Shows Initial Excel File.
Fig 2 Shows Console Output of reading excel
Fig 3 Shows Excel Write output









Fig 2




















Fig. 3 Excel Write output

Friday, April 12, 2013

Introduction for Beginners 2


Introduction 2When selenium came to market there we just two components in the beginning, those were:

  1. Selenium IDE
  1. Selenium RC                                                                                                                                         





Selenium in Begining


                Selenium IDE + Selenium RC
                                                                               







Selenium IDE was used for the automated test recording primarily. While RC was used to program automated test scrips, there were many languages which are supported by Selenium RC includingJava, Python, Javascript, C# etc.
IDE has versatile features apart from record and play, we can pass parameters, create loops eg. while loop,do programming in Javascript etc.
Selenium RC primarily had various drawbacks, so Google and Thoughtworks worked with each other and designed a new thing called Selenium webdriver.
The Selenium RC and webdriver are altogether different products. But Webdriver supports RC code.Many old companies are working on RC, so it is also necessary to learn RC to keep in phase with them.All new script development nowadays is done by using Selenium Webdriver. There are various languages which are supported by Webdriver like Java, Python, C#, Javascript etc, we can grill ourselves in one and start the learning of the tool.
So now there are three components of Selenium:1)Selenium IDE2)Selenium RC3)Selenium Webdriver
Please wait for my new posts for more clarifications, Post the comments here if you have any question,I would also post videos in my future post for training.Byee....











Introduction for Beginers 1

Hello Everyone,
This is a blog I have created, for providing Gyan to people for learning selenium.
I would tell you the most important facts in the begining itself which you would develop after devoting a long time in coaching and studying selenium.
Few facts for now:
1)The name of this tool is selenium as for treating Mercury poisioning we use Selenium element., QTP is developed by Mercury :).
2) This tool is absolutely free, slap anyone who asks money for its set up, :) don't fight just joking.
3) Selenium is not a single tool, its a combination of IDE, RC and webdriver. All these three are different entities, we
add them together and it acts like a tool.
4) We can record and play in selenium tool too using selenium IDE, but its not as intelligent recording as QTP.
5) For learning selenium we need to learn programming, this is true, but do not worry, I am here to guide you, I promise
that I can make anyone learn this tool, and that too free yaaar.
6) All guys providing coaching around in market for selenium are not fully equiped as this tool has very late entery in market, I guss in 2009.

I leave other facts for my next blog.
Keep me following I would guide you precisely and make you learn this,
I would also provide some assignments after each blog.

Byee........