Completed
Last Updated: 16 Nov 2016 11:16 by ADMIN
ADMIN
Elena
Created on: 10 Nov 2016 14:32
Type: Feature Request
0
Data Binding// Excel data source with dynamic formulas is not updated automatically by execution
Steps to reproduce: 

1. Get the attached sample project. Review the bound Excel sheet in the Data folder - it contains dynamically changing formulas which show the current time and date. 

2. Execute the test in the project. The values from the data source in the iteration will be the last refreshed when the excel file was opened. 

Expected: The file to be refreshed before the values for the iteration are taken 

Actual: The values remain the same until next time the file is opened from the project location. 
1 comment
ADMIN
Daniel Djambov
Posted on: 16 Nov 2016 11:15
Telerik: this behavior is expected and specific to how excel works - it updates its formula on workbook open. The solution is to open and trigger update of the data file before the test runs. 

We have an option to use our Execution Extension (http://docs.telerik.com/teststudio/advanced-topics/coded-samples/general/execution-extensions) and in it to reload the Excel file before the execution of the test starts, which will solve your problem. 

Attached is the updated project (TestPRoject24Updated.zip) and built execution extension (ExecutionExtensionTAS.dll) to be placed in [Test Studio install directory]\Bin\Plugins\ folder to trigger the refresh. 

Here is the code implemented in OnInitializeDataSource(ExecutionContext executionContext) to trigger the update of the data file using Test Studio execution extension:
             public System.Data.DataTable OnInitializeDataSource(ExecutionContext executionContext)
            {
            Microsoft.Office.Interop.Excel.Application objexcel;
            Microsoft.Office.Interop.Excel.Workbook wbexcel;
            objexcel = new Microsoft.Office.Interop.Excel.Application();
            objexcel.Visible = false;
            wbexcel = objexcel.Workbooks.Open(executionContext.DeploymentDirectory.ToString()+"\\Data\\"+executionContext.Test.Source.ToString());
            wbexcel.RefreshAll();
            wbexcel.Save();
            objexcel.Workbooks.Close();
            objexcel.Quit();
            return null;
            }