Selenium IDE: read set of data from excel -


this not question solution proposal: found workaround read set of data excel. in case there no need multiple users or data variation read parameters create validation environment.

ok, solution save excel file html format , let selenium ide read parameters that. users needs agree same filename used.

1) should add "apache poi" jar files in order read excel through java.   import java.io.fileinputstream; import java.io.ioexception; import java.util.arraylist; import java.util.hashmap; import java.util.iterator; import java.util.list; import java.util.map;  import org.apache.poi.xssf.usermodel.xssfcell; import org.apache.poi.xssf.usermodel.xssfrow; import org.apache.poi.xssf.usermodel.xssfsheet; import org.apache.poi.xssf.usermodel.xssfworkbook;  public class excelreadexample {      @suppresswarnings({ "unchecked", "rawtypes" })     public static void main(string[] args) throws exception {            string filename = "e:\\data.xls";            list sheetdata = new arraylist();          fileinputstream fis = null;         try {              fis = new fileinputstream(filename);              xssfworkbook workbook = new xssfworkbook(fis);              xssfsheet sheet = workbook.getsheetat(0);              iterator rows = sheet.rowiterator();             while (rows.hasnext()) {                 xssfrow row = (xssfrow) rows.next();                 iterator cells = row.celliterator();                  list data = new arraylist();                 while (cells.hasnext()) {                     xssfcell cell = (xssfcell) cells.next();                     data.add(cell);                 }                  sheetdata.add(data);             }         } catch (ioexception e) {             e.printstacktrace();         } {             if (fis != null) {                 fis.close();             }         }          showexeldata(sheetdata);     }      private static void showexeldata(list sheetdata) {           int sum = 0;             (int = 0; < sheetdata.size(); i++) {             list<xssfcell> list = (list) sheetdata.get(i);             (int j = 0; j < list.size(); j++) {                 xssfcell cell = (xssfcell) list.get(j);                   if(cell.getcelltype()==0)                 {                     sum += cell.getnumericcellvalue();                  }              }             system.out.println("");             system.out.println("sum value is:" +sum);         }     } }    change file path. hve mentioned sheet name "input" change per yours happy excelling :d 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -