Hi everyone, I’m currently developing test step which needs to list all available external parameters from test plan settings for user to select from combo box. So far I’ve only managed to do this in PrePlanRun/Run phases. How would it be/is it possible to load these external parameters when test plan is loaded, test step is added to the test plan and test step is selected in the test plan?
Hi @juhani.tormanen, and welcome!
So it sounds like you’ve already developed a function which lists the external parameters as desired, and that function works when called from PrePlanRun and Run, correct?
Can you stick that same function into the getter of a List which is used by an AvailableValues attributed property? Something like this:
[xmlignore]
public List<string> AvailableExternalParams
{
get
{
return GetAllExternalParams();
}
}
[AvailableValues(nameof(AvailableExternalParams))]
public List<string> SelectedExternalParams {get;set;}
Thanks, this code example did the trick
Hi
Would you please show me how to change and save an external parameter of a test plan in code?
I can get the list of parameters from ExternalParameters.Entries of a loaded testplan but this list is read only.
Is there any API to save edited ExternalParameters to the test plan? However I can manually open testplan file (.TapPlan) and edit xml file.
Hi @teder.ted
I am not sure this is what you want but you can get the parameter you want from ExternalParameters.Entries list. Then you can edit its value.
Following code is inside a test step’s Run() method. Time Delay is the name of the parameter and its value can be set. To save it though, you need to save the test plan by calling TestPlan.Save().
var parameterList = ((TestPlan)this.Parent).ExternalParameters; // Get ExternalParameters
var parameter = parameterList.Get("Parameters \\ Time Delay"); // Get specific parameter by its name
parameter.Value = 5; // Edit value
Thanks
calling testPlan.Save() cause this error:
Method not found: ‘System.collections,generic.IEnumerable’1<System.String> OpenTap.TapSerializer.GetUsedFiles()’
I works fine in my test step. Can you clean the solution and run it again? Multiple assemblies containing the same method inside the project output may cause this issue.
If that doesn’t work can you give more information? Where do you call the Save() method, is the error occurs during runtime or compilation?
Thanks, that’s the point. I clean the project and delete all assemblies and just worked!