Für Excel lesen, können Sie wie this-
Open Excel {YourExcelFileName}.xls
${strColCount} = Get Column Count {YourExcelSheetName}
${strRowCount} = Get Row Count {YourExcelSheetName}
:FOR ${rowIndex} IN RANGE 0 ${strRowCount}
\ ${col1Val} Read Cell Data By Coordinates {YourExcelSheetName} 1 ${rowIndex}
\ ${col2Val} Read Cell Data By Coordinates {YourExcelSheetName} 2 ${rowIndex}
\ ${col3Val} Read Cell Data By Coordinates {YourExcelSheetName} 3 ${rowIndex}
verwenden und Excel für writting, youi kann durch Robot Framework bereitgestellt Schlüsselwort "Put String In Zelle"
Bitte mehr Details zu ExcelLibrary finden zur Verfügung gestellt von Robot Framework here
Unten ist Code zum Lesen von Excel mit POI & Java. (Stellen Sie sicher, dass Sie die necessory Dinge wie Dateinamen ändern, den Pfad, den Paketnamen usw.)
package sbps;
import java.io.File;
import java.io.FileInputStream;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.LinkedHashMap;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class del
{
public static void main(String a[])
{
String strConnString = null;
Connection con1 = null;
String strQuery = null;
String strFilePath = Driver.APP_PATH;
HSSFWorkbook xlWBook;
HSSFSheet xlSheet;
HSSFRow xlRow,xlHeaderRow;
HSSFCell xlCell;
String strLogicalPath="";
String strColValue = "";
Statement st1 = null;
ResultSet rs1 = null;
String strGroups = null;
String strExeVal = null;
int intNumberOfColumns;
String runOnBrowser = "";
String IEGroup = "", FFGroup = "", CHGroup = "";
boolean IEFlag = false, FFFlag = false, CHFlag = false;
try
{
FileInputStream xlFile = new FileInputStream(new File(strFilePath+"\\05_TestCases\\GroupControlFiles.xls"));
xlWBook = new HSSFWorkbook(xlFile);
xlSheet = xlWBook.getSheet("Groups");
int rows = xlSheet.getPhysicalNumberOfRows();
int cols = xlSheet.getRow(0).getLastCellNum();
xlHeaderRow = xlSheet.getRow(0);
Driver.APP_MAP = new LinkedHashMap<String, String>();
boolean blnFound=false;
try
{
for(int i=1; i<=rows; ++i)
{
xlRow = xlSheet.getRow(i);
runOnBrowser = "";
strGroups = xlRow.getCell((short)0).getStringCellValue();
strExeVal = xlRow.getCell((short)1).getStringCellValue();
if (!strExeVal.equalsIgnoreCase("null")
&& strExeVal.equalsIgnoreCase("YES")) {
IEGroup = IEGroup + strGroups + ",";
IEFlag = true;
}
strExeVal = xlRow.getCell((short)2).getStringCellValue();
if (!strExeVal.equalsIgnoreCase("null")
&& strExeVal.equalsIgnoreCase("YES")) {
FFGroup = FFGroup + strGroups + ",";
FFFlag = true;
}
strExeVal = xlRow.getCell((short)3).getStringCellValue();
if (!strExeVal.equalsIgnoreCase("null")
&& strExeVal.equalsIgnoreCase("YES")) {
CHGroup = CHGroup + strGroups + ",";
CHFlag = true;
}
// }
}
}
catch(Exception ee)
{
}
if (CHFlag) {
CHGroup = CHGroup.substring(0, CHGroup.length() - 1);
Driver.APP_MAP.put("CH", CHGroup);
}
if (IEFlag) {
IEGroup = IEGroup.substring(0, IEGroup.length() - 1);
Driver.APP_MAP.put("IE", IEGroup);
}
if (FFFlag) {
FFGroup = FFGroup.substring(0, FFGroup.length() - 1);
Driver.APP_MAP.put("FF", FFGroup);
}
xlFile.close();
}
catch(Exception ee)
{
}
}
}
Sie müssen Ihre eigenen Methoden schreiben, um eine Excel-Bericht mit Apache POI Jars zu bekommen. –
Ich habe deine Idee. Haben Sie Erfahrungen zum Erstellen eines eigenständigen Automatisierungsroboters? Ich möchte einen Roboter mehrfach verwenden, damit meine Gruppenmitglieder den Robotercode ändern können. Welches Format/welche Art möchten die Testdaten eingeben? – user2520217