I create the framework for our project,
BEFOREMETHOD (reads the first line using JXl)
@BeforeMethod
public void Test2() throws BiffException, IOException{
FileInputStream filepath = new FileInputStream("D://Selenium//Project_Stage//AddGroup//inputtoAddGroup.xls");
Workbook wb = Workbook.getWorkbook(filepath);
Sheet sh = wb.getSheet(0);
int totalNoOfRows = sh.getRows();
int rows;
for (rows=1 ; rows < totalNoOfRows;) {
System.out.println("BeforeMethod Executed"+rows);
CellContent1 = sh.getCell(0, rows).getContents().toUpperCase();
System.out.println("CellContent is: "+CellContent1);
CellContent2 = sh.getCell(1, rows).getContents();
CellContent3 = sh.getCell(2, rows).getContents();
CellContent4 = sh.getCell(3, rows).getContents();
CellContent5 = sh.getCell(4, rows).getContents();
rows=rows+1;
}
}
Test methods
@Test(priority=0)
public void Test(){
System.out.println("Test Is Executed1");
if (CellContent1.matches("TRUE")) {
System.out.println("p=0 Cell content is : "+CellContent5);
cells.add(CellContent5);
}
}
What I want for each test method is the BeforeMethod method, which is executed first the first time, my question is: I read the first line from Excel, I put it in the Before method (I need it in the testing method), for the second line from Excel I want to read to perform the second test method, how can I achieve this?
If there is another way how to use different loops, please help me.
source
share