HI in this i just created ExcelLibrary and featched this in TestScript1
but i am unable to fetch numbers and date format i want the same type of code to fetch all the dat numbers,String values and date formats please help me out
public class ExcelLibrary
{
public static int readData(String sheetName,int rowNum,int cellNum)
{
try
{
String path = "E:\\WorkSpace\\GoogleFrameWork\\data\\Inputdata.xlsx";
FileInputStream fis = new FileInputStream(path);
Workbook w1 = WorkbookFactory.create(fis);
int data = (int)w1.getSheet(sheetName).getRow(rowNum).getCell(cellNum).getNumericCellValue();
return data;
}
catch(Exception rv)
{
return 0;
}
}
public static void writeData(int sheetName,int rowNum,int cellNum,String data)
{
try
{
String path = "E:\\WorkSpace\\GoogleFrameWork\\data\\Inputdata.xlsx";
FileInputStream fis = new FileInputStream(path);
Workbook w1 = WorkbookFactory.create(fis);
w1.getSheetAt(sheetName).getRow(rowNum).createCell(cellNum).setCellValue(data);
}
catch(Exception rv)
{
}
}
}
---------------------------------------------------------------------------------------------------------------------------------------------------
package com.Google.common_library;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import com.Google.common_library.ExcelLibrary;
public class SuperTestScript
{
public static WebDriver driver = null;
@BeforeMethod
public void preConfig()
{
//WebDriver driver= new FirefoxDriver();
//driver.get("https://accounts.google.com/");
String browser = ExcelLibrary.readData("config", 1, 0);
String buildUrl = ExcelLibrary.readData("config", 1, 1);
//fetching the browser from Excel
if(browser.equals("FF"))
{
driver = new FirefoxDriver();
}
else if(browser.equals("GC"))
{
driver = new ChromeDriver();
}
else
{
driver = new InternetExplorerDriver();
}
driver.get(buildUrl);
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
}
@AfterMethod
public void postConfig()
{
driver.close();
}
}
------=====================================================--------------------------
package com.actitime.project_and_tasks_test_scripts;
import org.testng.annotations.Test;
import com.actitime.common_library.ExcelLibrary;
import com.actitime.common_library.SuperTestScript;
import com.Google.webpages.LoginPage;
public class TestScript1 extends SuperTestScript
{
@Test
public void testLogin()
{
String un = ExcelLibrary.readData("ValidData", 1, 0);
String pwd = ExcelLibrary.readData("ValidData", 1, 1);
LoginPage lp = new LoginPage();
lp.enterUsername(un);
lp.enterPassword(pwd);
lp.clickOnLogin();
}
}