webdriver 的CSV数据驱动
2020-11-16 07:42
标签:des style blog http java 使用 1.获取CSV数据内容 public static Object[][] getFromCSV(String filename) { 2.定义数据驱动 String file = "src/test/java/data/page/TaxIssueAnswerTest.csv"; @DataProvider(name="CsvDataProvider") 3.使用数据驱动 @Test(dataProvider = "CsvDataProvider",description
="正常业务场景测试") //执行用例 } 4.图例文件路径 webdriver 的CSV数据驱动,搜素材,soscw.com webdriver 的CSV数据驱动 标签:des style blog http java 使用 原文地址:http://www.cnblogs.com/joewu/p/3699628.html
if (!(new
File(filename)).exists()){
return
null;
}
Object[][]
content;
CSVReader reader;
try
{
reader = new CSVReader(new
FileReader(filename));
Vector
String[]
nextLine;
reader.readNext(); //skip
title
while ((nextLine = reader.readNext()) != null)
{
vec.add(nextLine);
}
content = new
Object[vec.size()][];
for (int i = 0; i content[i] =
vec.get(i);
}
return
content;
} catch (Exception e)
{
System.out.println("Read CSV File:" + filename +
"failed.");
e.printStackTrace();
}
return null;
}
public Object[][]
inputData(){
return getFromCSV(file);
}
public void answerIssue(String caseId, String
description,String userName, String pwd){