Running Python TestPlan/Steps with .Net Api for Custome GUI

I want to use a custome GUI to Run Testplans, that I make in the Editor. I have a custom Avalonia GUI. I can run example Testplans, and even Testplans, containing my own plugins that I have written in C#, from this GUI. I also can run any Testplan including Python ones, in the Community Editor, which I’m using to make the Testplans. But for some reason I can’t run TestPlans containing Python TestSteps, throught the .Net API. I get an error like this:

“XML Line 4: Unable to locate type ‘PythonExamples.BasicFunctionality.BasicFunctionality’. Are you missing a plugin?\nXML Line 4: Unable to deserialize test step.\nXML Line 19: Unable to locate type ‘PythonExamples.BasicFunctionality.BasicFunctionality’. Are you missing a plugin?\nXML Line 19: Unable to deserialize test step.”

So it looks like the .NET API can’t recognize Python-based plugins, even though they work perfectly in the Editor. Is there some setting that I’m missing? Or is it simply not supported to run Python TestSteps through the .NET API?

A bit more about my goal, and my setup:

I want to make a multiplatform GUI (Win/Linux) for testing. I have made a few teststeps, duts, and instruments already, both in C# and Python. Every python package I need is globaly installed on the PC, not in a VE as well as Python. Using OpenTap 9.29. with the new Community Editor.

Smaller extra question:

When loading a Testplan using the .NET API, I also get issues if the Testplan XML contains <Package.Dependencies> section like this:

 <Package.Dependencies> 
 <Package Name="OpenTAP" Version="^9.29.1+335b2cbe" /> 
<Package Name="PythonExamples" Version="^3.1.0+73e66d85" /> 
 </Package.Dependencies> 

It’s automaticly generating if I make TestPlans throught the Editor. If I comment it out, everything loads fine — but it feels unnecessary. Is there a recommended way to handle package dependencies in custom runners?

You probably need to initialize the plugin manager.

 PluginManager.Initialize();

Otherwise, did you install the Python plugin itself? Or just the Python Examples?

Thanks, for the fast reply. I have the python plugin installed, thought its 3.1. Where do you suggest putting this PluginManager.Initialize(); ? My code looks very similar to the example code:

  1. Load package locations
  2. Set log file
  3. Add an absolute testplan path
  4. Add settings path
  5. Add result listeners
  6. OpenTap.PluginManager.SearchAsync();
  7. Add settings profile, dut and instruments
  8. l Load the testplan
  9. Execute

I always get the error at the Load step(8). I tried it before the 1st step and before the 8th step. Neither worked.

I also checked with PluginManager.GetAllPlugins(): It couldnt list my python packages, nor the example package, but could list the Opentap.python package itself, and my C# packages, or other Opentap packages.

I just saw that pythonnet is being used for the Opentap.python project. Could it be that I also have to init that?

Ok, since you already use the plugin manager, it should be initialized properly.

Maybe you can try loading your custom GUI as a command line action. If you implement the ICliAction and add a appropriate display name, then you can get the tap executable to launch the UI from the command line. e.g “> tap my-ui”, if that works its because OpenTAP got properly initialized.

Otherwise, did you see any warnings or errors during startup? Did the python plugin say which version of python it found?

@rolf_madsen It looks like it can only detect plugins that contain dll files. Those plugins that contain only .py files remain undetected. Any idea what should be done?