在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 教程/ Python/ 使用Excel數(shù)據(jù)驅(qū)動(dòng)
log4j日志
Selenium IDE測試創(chuàng)建
Selenium - IDE模式匹配
Selenium教程
多瀏覽器測試
Selenium IDE下載
Selenium用戶擴(kuò)展
鍵盤操作
捕捉屏幕截圖
Selenium網(wǎng)格
Selenium TestNG
Selenium定位器
查找所有鏈接
Selenium測試設(shè)計(jì)技術(shù)
鼠標(biāo)操作
下拉框交互
Selenium IDE驗(yàn)證點(diǎn)
Selenium IDE- 不同的瀏覽器
Selenium RC
多選擇操作
復(fù)選框交互
單選按鈕互動(dòng)
捕捉視頻
拖放
Selenium IDE 測試
Synchronization 同步
異常處理
Selenium 環(huán)境安裝設(shè)置
Selenium概述
用戶交互
Selenium Webdriver
Selenium IDE
Selenium頁面對象模型
Selenium IDE 工具特點(diǎn)
使用Excel數(shù)據(jù)驅(qū)動(dòng)
Selenium - Selenese命令

使用Excel數(shù)據(jù)驅(qū)動(dòng)

使用Excel數(shù)據(jù)驅(qū)動(dòng)

在設(shè)計(jì)測試,參數(shù)化測試是不可避免的。我們會(huì)利用Apache的POI- Excel JAR實(shí)現(xiàn)是一樣的。它可以幫助我們來讀取和寫入到Excel中。

下載JAR

第1步:導(dǎo)航到URL- http://poi.apache.org/download.htmll并下載ZIP格式。

selenium_ide_152

第2步:點(diǎn)擊鏡像鏈接下載JAR。

selenium_ide_153

第3步:解壓縮到一個(gè)文件夾。

selenium_ide_154

第4步:如下所示的解壓縮后的內(nèi)容將被顯示。

selenium_ide_155

第5步:現(xiàn)在創(chuàng)建一個(gè)新的項(xiàng)目,并在“External JARs”添加“POI-3.10.FINAL”文件夾中所有的jar包。

selenium_ide_147

第6步:現(xiàn)在,添加所有的“External JARs”在“OOXML-LIB”文件夾中。

selenium_ide_148

第7步:現(xiàn)在,添加所有的“External JARs”在“lib”文件夾中。

selenium_ide_149

第8步:如下圖所示,顯示已添加的JAR文件。

selenium_ide_150

第9步:如下圖所示的Package Explorer顯示。此外附加“webdriver”相關(guān)的JAR

selenium_ide_151

參數(shù)

為了演示目的,我們將參數(shù)的百分比計(jì)算器測試。

第1步:我們將所有的參數(shù)需要使用Excel的%計(jì)算器的輸入。所設(shè)計(jì)的excel如下所示。

selenium_ide_156

第2步:現(xiàn)在,我們將執(zhí)行所有百分比計(jì)算器,所有指定的參數(shù)。

第3步:讓我們創(chuàng)建通用的方法來訪問使用導(dǎo)入JARS Excel文件。這些方法可以幫助我們獲得一個(gè)特定的單元格數(shù)據(jù)或設(shè)置一個(gè)特定的單元格的數(shù)據(jù)等。

import java.io.*;
import org.apache.poi.xssf.usermodel.*;
    
public class excelutils 
{
   private XSSFSheet ExcelWSheet;
   private XSSFWorkbook ExcelWBook;

   //Constructor to connect to the Excel with sheetname and Path
   public excelutils(String Path, String SheetName) throws Exception 
   {
	  try 
	  {
	    // Open the Excel file
	    FileInputStream ExcelFile = new FileInputStream(Path);
	    // Access the required test data sheet
	    ExcelWBook = new XSSFWorkbook(ExcelFile);
	    ExcelWSheet = ExcelWBook.getSheet(SheetName);    
	  } 
	  catch (Exception e)
	  {
	    throw (e);           
	  }
   }
              
    //This method is to set the rowcount of the excel.
    public int excel_get_rows() throws Exception 
    {
	  try 
	  {
	     return ExcelWSheet.getPhysicalNumberOfRows();           
	  } 
	  catch (Exception e)
	  {
	  	throw (e);
         
	  }
    }
        

    //This method to get the data and get the value as strings.
    public String getCellDataasstring(int RowNum, int ColNum) throws Exception
    {
	   try
	   {
		   String CellData = ExcelWSheet.getRow(RowNum).getCell(ColNum).getStringCellValue();
		   System.out.println("The value of CellData " + CellData);
		   return CellData;
	   }
	   catch (Exception e)
	   {
	   	 return "Errors in Getting Cell Data";
	   }
    }
    
 
  //This method to get the data and get the value as number.
    public double getCellDataasnumber(int RowNum, int ColNum) throws Exception
    {
	   try
	   {
		  double CellData = ExcelWSheet.getRow(RowNum).getCell(ColNum).getNumericCellValue();
		  System.out.println("The value of CellData " + CellData);
		  return CellData;
		}
		catch (Exception e)
		{
			return 000.00;
		}
    }
}

第4步:現(xiàn)在,添加它將訪問,我們已經(jīng)開發(fā)了Excel的方法,主要的方法。

import java.io.*;
import org.apache.poi.xssf.usermodel.*;
    
public class excelutils 
{
   private XSSFSheet ExcelWSheet;
   private XSSFWorkbook ExcelWBook;

   //Constructor to connect to the Excel with sheetname and Path
   public excelutils(String Path, String SheetName) throws Exception 
   {
	  try 
	  {
		 // Open the Excel file
		 FileInputStream ExcelFile = new FileInputStream(Path);
		 // Access the required test data sheet
		 ExcelWBook = new XSSFWorkbook(ExcelFile);
		 ExcelWSheet = ExcelWBook.getSheet(SheetName);    
	
	   } 
	   catch (Exception e)
	   {
		   throw (e);           
	   }
   }
              
    //This method is to set the rowcount of the excel.
    public int excel_get_rows() throws Exception 
    {
	   try 
	   {
		   return ExcelWSheet.getPhysicalNumberOfRows();           
		} 
		catch (Exception e)
		{
			throw (e);
		
		}
    }
      

    //This method to get the data and get the value as strings.
    public String getCellDataasstring(int RowNum, int ColNum) throws Exception
    {
	   try
	   {
		   String CellData = ExcelWSheet.getRow(RowNum).getCell(ColNum).getStringCellValue();
		  //Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
		  //String CellData = Cell.getStringCellValue();
		  System.out.println("The value of CellData " + CellData);
		  return CellData;
		}
		catch (Exception e)
		{
			return "Errors in Getting Cell Data";
		}
    }
    
   //This method to get the data and get the value as number.
    public double getCellDataasnumber(int RowNum, int ColNum) throws Exception
    {
	   try
	   {
		   double CellData = ExcelWSheet.getRow(RowNum).getCell(ColNum).getNumericCellValue();
		  //Cell = ExcelWSheet.getRow(RowNum).getCell(ColNum);
		  //String CellData = Cell.getStringCellValue();
		  System.out.println("The value of CellData " + CellData);
		  return CellData;
		}
		catch (Exception e)
		{
			return 000.00;
		}
    }    
}

輸出

在執(zhí)行腳本,輸出顯示在控制臺(tái)中,如下圖所示。

Selenium IDE 157
 

上一篇:拖放下一篇:多選擇操作