qileilove

          blog已經(jīng)轉(zhuǎn)移至github,大家請(qǐng)?jiān)L問(wèn) http://qaseven.github.io/

          Selenium使用Npoi來(lái)實(shí)現(xiàn)Report

           Selenium自動(dòng)化測(cè)試過(guò)程中,模擬用戶操作能實(shí)現(xiàn)后需要測(cè)試結(jié)果輸出,這是一個(gè)比較重要的過(guò)程
            1.用system.IO 讀寫來(lái)實(shí)現(xiàn),如果使用這個(gè)方式,每個(gè)測(cè)試生成一個(gè)報(bào)告,容易開啟太多的線程,占用內(nèi)存太多
            FileStream ofs1 = new FileStream(path1, FileMode.Create);
            StreamWriter owr = new StreamWriter(ofs);
            2.開發(fā)幫助說(shuō)使用vs com組件里邊的引用,如下鏈接,感覺(jué)這個(gè)實(shí)現(xiàn)方式還更麻煩哪
            http://blog.csdn.net/gisfarmer/article/details/3738959
            3.再詢問(wèn)一個(gè)測(cè)試網(wǎng)友,他說(shuō)可以用NPOI來(lái)實(shí)現(xiàn),直接引用dll,寫幾句代碼就能實(shí)現(xiàn)了,
            下載地址:http://npoi.codeplex.com/releases
            新建ecxel表格,在第一行第一列添加內(nèi)容
            excel行從1開始,NPOI內(nèi)部從0開始;excel列從字母開始,NPOI是數(shù)字表示,記得轉(zhuǎn)換
          public void NPOITest()
          {
          HSSFWorkbook hssWorkbook = new HSSFWorkbook();
          ISheet hssSheet = hssWorkbook.CreateSheet("new sheet");
          hssSheet.CreateRow(0).CreateCell(0).SetCellValue("This a sample");
          FileStream fs = new FileStream(@"d:\temp\test.xls", FileMode.Create);
          hssWorkbook.Write(fs);
          fs.Close();
          }
            在已有的test.xls添加數(shù)據(jù)
          public void TestExcel()
          {
          FileStream file = new FileStream(@"d:\temp\test.xls", FileMode.Open, FileAccess.Read);
          HSSFWorkbook hssfWork = new HSSFWorkbook(file);
          ISheet iSheet = hssfWork.GetSheet("new sheet");
          //獲取所有行數(shù),然后再+1的基礎(chǔ)上加入數(shù)據(jù)  (lastRowNum是當(dāng)前數(shù)據(jù)的最后一行)
          iSheet.CreateRow(iSheet.LastRowNum+1).CreateCell(0).SetCellValue("testtest");
          FileStream fss = new FileStream(@"d:\temp\test.xls", FileMode.Create);
          hssfWork.Write(fss);
          file.Close();
          }

          posted on 2014-05-12 10:43 順其自然EVO 閱讀(243) 評(píng)論(0)  編輯  收藏 所屬分類: selenium and watir webdrivers 自動(dòng)化測(cè)試學(xué)習(xí)

          <2014年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(55)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 英吉沙县| 牟定县| 鱼台县| 东宁县| 巴彦县| 内黄县| 霸州市| 巧家县| 鄂伦春自治旗| 遵义市| 青龙| 侯马市| 潜江市| 彭阳县| 丹阳市| 五原县| 祁连县| 错那县| 湛江市| 乐安县| 文成县| 新邵县| 青阳县| 哈尔滨市| 辛集市| 南溪县| 镇康县| 罗田县| 舟山市| 满城县| 孟连| 平凉市| 武平县| 随州市| 高雄县| 海盐县| 永新县| 威远县| 新竹县| 昌江| 渭源县|