Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. @Test
  2. public void test() throws Exception {
  3. String sPath = "default.xlsx";
  4. DataHelper.setExcelFile(sPath, "sheet1");
  5. XSSFRow row;
  6. XSSFCell cell;
  7. boolean flag = true;
  8. XSSFSheet sheet = ExcelWSheet;
  9. Iterator rows = sheet.rowIterator();
  10. while (rows.hasNext()) {
  11. row = (XSSFRow) rows.next();
  12. Iterator cells = row.cellIterator();
  13. List <String> obj = new ArrayList<String>();
  14. while (cells.hasNext()) {
  15. cell = (XSSFCell) cells.next();
  16. String cellobj = cell.getStringCellValue();
  17. if(flag)
  18. {
  19. driver.findElement(By.id("text")).sendKeys(cell);
  20. driver.findElement(By.id("text")).click();
  21. driver.findElement(By.id("text")).clear;
  22. }
  23. }
  24.  
  25.  
  26. }
  27.  
  28. public class DataHelper {
  29. public static XSSFSheet ExcelWSheet;
  30. private static XSSFWorkbook ExcelWBook;
  31. private static XSSFCell cell;
  32. private static String path;
  33.  
  34. public static void setExcelFile(String path, String SheetName) throws Exception {
  35. path = path;
  36. FileInputStream ExcelFile = new FileInputStream(path);
  37. ExcelWBook = new XSSFWorkbook(ExcelFile);
  38. ExcelWSheet = ExcelWBook.getSheet(SheetName);
  39.  
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement