Hello!
Thank you for investigating Ranorex!
Directly it is not possible at the time, but it is planned for the future versions.
Meanwhile, there are some possible workarounds.
Include file to your testsuite:In the dialog for managing Datasources (screenshot), check the checkbox
Include File in Test Suite. This will copy your file into the folder of your testsuite executable - and the executable will take the file from the folder of the exe. Info: To view all files within Project browser, use the
Show All Files button in the project browser (screenshot).
Own argument parameterThe more flexible workaround would be reading out your own argument parameters.
With this workaround it's possible to call the testsuite with e.g.
TestParameter.exe /datacsvconnector:DynamicCsvConnector=c:\MyDynamicCsv.csv
Basically, there are two steps: First you have to read out the parameters of the arguments in the main method. Therefore,
open Program.cs file and edit the class Program to
- Code: Select all
class Program
{
public static string dataCsvConnectorName
{
get;set;
}
public static string dataCsvConnectorPath
{
get;set;
}
[STAThread]
public static int Main(string[] args)
{
Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;
int error = 0;
foreach (string arg in args)
{
if (arg.StartsWith("/datacsvconnector"))
{
dataCsvConnectorName = arg.Substring(arg.IndexOf(':')+1, arg.IndexOf('=') - arg.IndexOf(':')-1);
dataCsvConnectorPath = arg.Substring(arg.IndexOf("=")+1);
}
}
try
{
error = TestSuiteRunner.Run(typeof(Program), Environment.CommandLine);
}
catch (Exception e)
{
Report.Error("Unexpected exception occurred: " + e.ToString());
error = -1;
}
return error;
}
}
Next, create a Code Module e.g. ReloadDataConnector.cs, alter the run method to:
- Code: Select all
void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
Report.Log(ReportLevel.Info,"Datasource '" + Program.dataCsvConnectorName + "' changed to '" + Program.dataCsvConnectorPath + "'");
(DataSources.Get(Program.dataCsvConnectorName).Connector as Ranorex.Core.Data.CsvDataConnector).FileName = Program.dataCsvConnectorPath;
TestSuite.Current.GetTestCase("AddPerson").DataContext.ReloadData();
}
Last step, create a testcase in your testsuite, add the ReloadDataConnector Codemodule to this testcase and after that add YOUR specific testcase with the dynamic data connector (structure in screenshot 3)
As I wrote above, these are two workarounds, in future version the the parameterization of the dataconnectors should work out of the box
Best Regards,
Martin
Ranorex Support Team