Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Test
- public void test() throws Exception {
- String sPath = "default.xlsx";
- DataHelper.setExcelFile(sPath, "sheet1");
- XSSFRow row;
- XSSFCell cell;
- boolean flag = true;
- XSSFSheet sheet = ExcelWSheet;
- Iterator rows = sheet.rowIterator();
- while (rows.hasNext()) {
- row = (XSSFRow) rows.next();
- Iterator cells = row.cellIterator();
- List <String> obj = new ArrayList<String>();
- while (cells.hasNext()) {
- cell = (XSSFCell) cells.next();
- String cellobj = cell.getStringCellValue();
- if(flag)
- {
- driver.findElement(By.id("text")).sendKeys(cell);
- driver.findElement(By.id("text")).click();
- driver.findElement(By.id("text")).clear;
- }
- }
- }
- public class DataHelper {
- public static XSSFSheet ExcelWSheet;
- private static XSSFWorkbook ExcelWBook;
- private static XSSFCell cell;
- private static String path;
- public static void setExcelFile(String path, String SheetName) throws Exception {
- path = path;
- FileInputStream ExcelFile = new FileInputStream(path);
- ExcelWBook = new XSSFWorkbook(ExcelFile);
- ExcelWSheet = ExcelWBook.getSheet(SheetName);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement