This is a migrated thread and some comments may be shown as answers.

Issues when write result into data source

7 Answers 109 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Y
Top achievements
Rank 1
Y asked on 27 Feb 2014, 09:34 AM
Hi, Support

  When I try to write test result into the data source,  errors meet.

 I refer to the related section # 'Write Into Data Source' in user guide (http://docs.telerik.com/teststudio/user-guide/code-samples/general/writeintodatasource.aspx)

And my corresponding code part as following, nothing too much changed from the reference.
But errors meet.
From the reference above "Note: Ensure you Add an Assembly Reference to Microsoft.Office.Interop.Excel. You can download a version of that file on Microsoft's website that matches your version of MS Office."
Is it caused by the file?
 I did add this, but not sure if it's the correct version. I also launched the Microsoft's website, but not found the exact version for Excel 2010.
Can you provide the link to download?

Many thanks.

Errors

'2/27/2014 5:12:29 PM' - System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Office, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
   at POC_Testing.WebTest..ctor()

My coded steps

Dim dataSourcePath As String = Me.ExecutionContext.DeploymentDirectory + "\Data\test data.xlsx"
Dim myPath As String = "C:\Users\cyang087\Desktop\test data.xlsx"
   
 Public Sub Find_Excel()
      
     If NOT (System.IO.File.Exists(myPath)) Then           
          System.IO.File.Copy(dataSourcePath, myPath)       
     End If
    
 End Sub


'''''others skipped

    
Dim excelApp As New Microsoft.Office.Interop.Excel.Application()
    
Dim workbook As Microsoft.Office.Interop.Excel.Workbook = excelApp.Workbooks.Open(myPath)

      Public Sub WebTest_CodedStep2()
           
 
            System.Threading.Thread.Sleep(1000)
            ActiveBrowser.RefreshDomTree()
              
            ' Write the test result in the 4th column in the data source excel

             If  (Assert.Equals(DesRedirectUrl, GetExtractedValue("redirectUrl").ToString())) then
            
      
                excelApp.Cells(Data.IterationIndex + 1, 3) = "Pass"
                'Log.WriteLine("pass")
                
             else
                excelApp.Cells(Data.IterationIndex + 1, 3) = "Fail"
                'Log.WriteLine("fail")
                
             End if
        
            excelApp.Visible = True
            excelApp.ActiveWorkbook.Save()
 
            workbook.Close(False, Type.Missing, Type.Missing)
            excelApp.Workbooks.Close()
            System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook)
 
            excelApp.Quit()
            GC.Collect()
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp)
            
            
        End Sub

7 Answers, 1 is accepted

Sort by
0
Y
Top achievements
Rank 1
answered on 28 Feb 2014, 06:29 AM
Hi,Support

I have found the matched version on MS website (http://www.microsoft.com/en-us/download/confirmation.aspx?id=3508).

But failed to install by the first two installation methods on the website , and hasn't resolved the issues.

Is there a Microsoft.Office.Interop.Excel.DLL for Office 2010 available from you side?

I'm not sure if the version I downloaded is for Office 2010, as met errors as last post shows.

Can you help to check if the error in last post is caused the the .dll file or something else?


Thanks again.

0
Velin Koychev
Telerik team
answered on 04 Mar 2014, 08:32 AM
Hi,

You can also use this Dropbox link to download the required dll file. 

If this issue persist, please copy this dll file to the root folder of the project and reference it from that location. Note this will work only if you put the dll in the root directory as it is described at the bottom of this article. Test Studio will not find references to a DLL in the subfolders of the project folder. These include: bin, Properties, obj, Data, Backup, TestResults, Results, TestLists, and Profiler Configurations.

Let me know if this helps. 

Regards,
Velin Koychev
Telerik
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
0
Y
Top achievements
Rank 1
answered on 05 Mar 2014, 06:30 AM
Hi,

 Thanks for your .dll file, the issue is fixed, but a new issue comes.

 It seems my code's problem, can you help to figure out?

Error MSG as below:

'3/5/2014 2:29:14 PM' - System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: The ExecutionContext is null. Initialize has not been called yet or it failed.
   at ArtOfTest.WebAii.Design.BaseWebAiiTest.get_ExecutionContext()
   at POC_Testing.WebTest..ctor() in C:\Users\cyang087\Documents\Test Studio Projects\POC Testing\WebTest.tstest.vb:line 40
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Activator.CreateInstance(Type type)
   at ArtOfTest.WebAii.Design.Execution.ExecutionUtils.CreateCodedTestInstance(Test test, TestResult result, String binariesFolder)
   at ArtOfTest.WebAii.Design.Execution.ExecutionEngine.InternalExecuteTest(Test test, TestResult initializationResult)
   at ArtOfTest.WebAii.Design.Execution.TestExecuteProxy.ExecuteTest(ExecuteTestCommand command)
------------------------------------------------------------
'3/5/2014 2:29:14 PM' - Test completed!
0
Y
Top achievements
Rank 1
answered on 05 Mar 2014, 07:09 AM
Attached the Project file.
0
Y
Top achievements
Rank 1
answered on 06 Mar 2014, 07:11 AM
Please pending this issue.
I will update in the future.
0
Y
Top achievements
Rank 1
answered on 06 Mar 2014, 08:27 AM
Hi,Support

 Ignore all above.

 It has been fixed.

 Thanks for your support all the way.
0
Boyan Boev
Telerik team
answered on 06 Mar 2014, 02:40 PM
Hi,

I am happy to hear that.

Let us know if you need further information.

Regards,
Boyan Boev
Telerik
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Y
Top achievements
Rank 1
Answers by
Y
Top achievements
Rank 1
Velin Koychev
Telerik team
Boyan Boev
Telerik team
Share this question
or