How to Refresh Excel Data Source during runtime

Ask general questions here.
kaancha
Posts: 17
Joined: Wed Oct 22, 2014 4:12 pm

How to Refresh Excel Data Source during runtime

Post by kaancha » Fri May 27, 2016 8:17 pm

Here is my scenario:
1. I have a Test Case which uses Excel Data source ( c:\abc.xlsx)
2. In the spreadsheet, the column “Salary” data is binded with the module ‘SelectSalary’
3. My another module named “UpdateExcel” opens the spreadsheet “abc.xlsx” ( which is associated with the test case too) , change the “Salary” value , saved it and close the spreadsheet.
4. The next module (ChangedSalary) of the same test case does not see the changed salary value, instead it gets the previously saved Salary value.
5. What should I do to refresh / reload the data during the runtime?
If I looked at the Data Source while it is still being run, I see the NEW value has been updated but it still gets the previous data before the spreadsheet was updated.

I added these codes and it is not working :

Wb,Save().
Wb.Close()
TestCase.Current.DataContext.ReloadData();

I appreciate your help.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: How to Refresh Excel Data Source during runtime

Post by krstcs » Fri May 27, 2016 8:29 pm

If you search these forums you will find several threads on this same topic. Please search first in the future so the data is not duplicated across several threads.

Excel connectors are not designed for dynamic data loading. There are ways to do it, but I would strongly caution against it unless you know what you are doing with .NET, as it will require some very specific code. Note that this is also not intended by design and Ranorex may change things in the future that would cause these methods to no longer work the way they do now.

If you need to update the test data in real-time, while the test is going on, you should really consider using a database instead, as that is what they are designed for. SQL Server Express Edition is free.

In addition, you should consider using CSV files instead of Excel's XLSX format, as they can be edited and read anywhere, including by Excel, and you won't need to install Excel on all of your test systems. If you use the Excel connector, Ranorex REQUIRES that Excel be installed on the system, which means you will need a license for Excel just for the test system.
Shortcuts usually aren't...