Refresh Data source for test iteration

Best practices, code snippets for common functionality, examples, and guidelines.
_adrian_
Posts: 2
Joined: Wed Oct 30, 2019 4:35 pm

Refresh Data source for test iteration

Post by _adrian_ » Wed Oct 30, 2019 4:56 pm

Hi,
I have a test case that i connected a CVS data source to have few iteration with different values of few parameters.
After I update the database rows from a User Code module functions that write new data,
seems i can not refresh the Data source so, :wink: when it runs it reflects the new changes.

User Code module is added in the SETUP block of the test case.

Code: Select all

DataSources.Get(db).Load();

McTurtle
Posts: 268
Joined: Thu Feb 23, 2017 10:37 am
Location: Benedikt, Slovenia

Re: Refresh Data source for test iteration

Post by McTurtle » Thu Oct 31, 2019 1:55 pm

Hi _adrian_,

I think its more like this:
var tc = (TestCase) TestSuite.Current.GetTestCase("TestCase");  
tc.DataContext.Source.Load();  
Where TestCase is the name of the test case for which you want to reload the connector. It is important that the code runs before TC is started.

Does it work?

Regards,
McTurtle

_adrian_
Posts: 2
Joined: Wed Oct 30, 2019 4:35 pm

Re: Refresh Data source for test iteration

Post by _adrian_ » Thu Oct 31, 2019 3:51 pm

I am using version 9.2 - that is giving error as

Code: Select all

Error	CS0246	The type or namespace name 'TestCase' could not be found 

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5459
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Refresh Data source for test iteration

Post by odklizec » Mon Nov 04, 2019 3:24 pm

Hi,

The code should look like this:

Code: Select all

var TC = (TestCaseNode)TestSuite.Current.GetTestContainer("TestCaseName"); 
TC.DataContext.Source.Load();
The one provided by McTurtle is correct, but only for older Ranorex versions (7.0 and older).
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration