我有各种各样的问题,例如:
project = 'abc' and status = Closed
project = 'def' and status = Open
project = 'ghi' and status = Open
我必须使用selenium中的sendKeys函数逐个调用这些查询。我必须将查询保存在.txt文件中并执行此操作。
怎么做?
答案 0 :(得分:0)
尝试使用以下的txt文件:
project;status
abc;Closed
def;Open
在你的程序中读取该文件,如下所示:
private void checkProejctStats(String filePath) throws Exception{
BufferedReader br = new BufferedReader(new FileInputReader(filePath));
String line = br.readLine(); //This is the headerline, we don't realy need to know whats inside there.
line = br.readLine();//means we are going to read the 2nd line.
while(line !=null){
String arr[] = line.split(";") //split it in an array
// TODO: CHECK PROPERLY!
String projectName = arr[0];
String projectStatus = arr[1];
line = br.readLine();//get the next line
}
}
请注意这是我在stackoverflow上的第一篇文章,从未在此编辑器中执行此操作,因此可能存在某些语法问题;) 如果有问题,请告诉我。