尝试从Jenkin运行我的Selenium脚本时出现无法识别ole流错误,但是在eclipse中从本地运行它时,它运行正常。这个脚本使用JXL
Excel已经以97-2003格式保存(我知道我正在使用不支持XLSX的JXL),并且使用eclipse在本地计算机上可以正常工作,但是从Jenkins运行它时出现错误。我检查了从站,发现从站计算机以及本地计算机上都安装了Office 2016
我应该能够连接到xls文件,因为它在本地计算机上可以正常工作。请建议
用于连接Excel的代码:
import java.io.IOException;
import java.util.Hashtable;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;
static Sheet wrksheet;
static Workbook wrkbook =null;
static Hashtable dict= new Hashtable();
private static int iDataSheetRow;
//Create a Constructor
public static void init(String ExcelSheetPath) throws BiffException, IOException
{
//Initialize
wrkbook = Workbook.getWorkbook(new File(ExcelSheetPath));
wrksheet = wrkbook.getSheet(0);
//setiDataSheetRow(0);
}
错误日志:
jxl.read.biff.BiffException: Unable to recognize OLE stream
at jxl.read.biff.CompoundFile.<init>(CompoundFile.java:116)
at jxl.read.biff.File.<init>(File.java:127)
at jxl.Workbook.getWorkbook(Workbook.java:221)
at jxl.Workbook.getWorkbook(Workbook.java:198)
at utilities.ExcelSheetDriver.init(ExcelSheetDriver.java:21)
at smokeTestRun.TC_BarclaysYS.beforeMethod(TC_BarclaysYS.java:26)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124