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