セレンWebドライバープロジェクトを実行しています。テストケースの入力としてExcelシートを使用しています。次のエラーが発生します
org.testng.TestNGException: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence.
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:340)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:88)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175) Caused by: com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.read(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.arrangeCapacity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipString(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:17)
at org.testng.xml.SuiteXmlParser.parse(SuiteXmlParser.java:10)
at org.testng.xml.Parser.parse(Parser.java:172)
at org.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:310)
... 3 more
誰かがこのエラーで私を助けてくれますか?ありがとう
Excelシートドライバのコードは
package com.bigMachines.TCL.ExcelShhetDataProvider;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Set;
import org.testng.Assert;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
public class ExcelSheetDriver {
private Sheet wrksheet;
private Workbook wrkbook =null;
private HashMap<String, Integer> dict= new HashMap<String, Integer>();
//Create a Constructor
public ExcelSheetDriver(String ExcelSheetPath){
try {
wrkbook = Workbook.getWorkbook(new File(ExcelSheetPath));
wrksheet = wrkbook.getSheet(0);
columnDictionary();
} catch (BiffException e) {
Assert.fail(e.getMessage());
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
//Returns the Number of Rows
public int rowCount()
{
return wrksheet.getRows();
}
//Returns the Cell value by taking row and Column values as argument
public String readCell(int column,int row)
{
return wrksheet.getCell(column,row).getContents();
}
public String readCell(String columnName,int row)
{
return readCell(getColumnNo(columnName), row);
}
//Create Column Dictionary to hold all the Column Names
private void columnDictionary()
{
//Iterate through all the columns in the Excel sheet and store the value in Hashtable
for(int col=0;col<wrksheet.getColumns();col++)
{
dict.put(readCell(col,0), col);
}
}
//Read Column Names
public int getColumnNo(String colName)
{
try {
int value;
value = ((Integer) dict.get(colName)).intValue();
return value;
} catch (NullPointerException e) {
return (0);
}
}
public Set<String> getColumnNameList(){
return dict.keySet();
}
}
編集
テストXMLへのリンクはここにあります。