Jan 30, 2007 4:38 AM
help improving stability to read values from Excel file (web testing)
Hello,
I'm having some issues reading values from an opened excel file (through web testing). I only have one class which I think can be responsible for this- which I hope to later parametrize to take expected values, etc. Strangely, the code doesn't work for getting an already running instance of Excel. I later added some code (which was probably silly) to open a new instance of excel first, then to grab the already opened instance...and that seemed to work. However, the code always crashes on first attempt when I reboot my computer. Then it mostly works. With a random failure here and there. It is about 90% effective. Can you perhaps give me some pointers or suggestions on what I may be doing wrong? I'll attach my class file, and then the 2 stack traces (1st trace = with trying 2 instances of Excel, which mostly works, 2nd trace = by just grabbing the active instance which never works). Thank you very much for your time,
-Alejandro
-
stack trace of the class as is:
java.lang.reflect.InvocationTargetException
at com.jniwrapper.win32.MessageLoopThread.doInvokeAndWait(MessageLoopThread.java:232)
at com.jniwrapper.win32.MessageLoopThread.doInvokeMethod(MessageLoopThread.java:296)
at com.jniwrapper.win32.automation.OleMessageLoop.invokeMethod(SourceFile:191)
at lib.ExcelCommunicator2.testRow(ExcelCommunicator2.java:40)
at watij.WatijBatchTemplateReport.testTrailBlaze(WatijBatchTemplateReport.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.jniwrapper.win32.MessageLoopThread$MethodInvocationAction.run(MessageLoopThread.java:656)
at com.jniwrapper.win32.MessageLoopThread$LoopThread.run(MessageLoopThread.java:502)
Caused by: java.lang.NullPointerException
at lib.ExcelCommunicator2.getProperty(ExcelCommunicator2.java:122)
at lib.ExcelCommunicator2.testValue(ExcelCommunicator2.java:68)
... 6 more
-
stack trace without using the "pre" method (never works):
java.lang.reflect.InvocationTargetException
at com.jniwrapper.win32.MessageLoopThread.doInvokeAndWait(MessageLoopThread.java:232)
at com.jniwrapper.win32.MessageLoopThread.doInvokeMethod(MessageLoopThread.java:296)
at com.jniwrapper.win32.automation.OleMessageLoop.invokeMethod(SourceFile:191)
at lib.ExcelCommunicator2.testRow(ExcelCommunicator2.java:37)
at watij.WatijBatchTemplateReport.testTrailBlaze(WatijBatchTemplateReport.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:478)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:344)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.jniwrapper.win32.MessageLoopThread$MethodInvocationAction.run(MessageLoopThread.java:656)
at com.jniwrapper.win32.MessageLoopThread$LoopThread.run(MessageLoopThread.java:502)
Caused by: com.jniwrapper.win32.com.ComException: COM object method returns error code: 0x800401E3; Operation unavailable
at com.jniwrapper.win32.com.ComException.checkResult(SourceFile:72)
at com.jniwrapper.win32.com.ComFunctions.getActiveObject(SourceFile:414)
at lib.ExcelCommunicator2.init(ExcelCommunicator2.java:58)
... 6 more
- excelcommunicator2.java (5.6 K)