β Issue: TestManager Not Available in Python Script (AttributeError)
π Question:
Why does project.get_testmanager() not work in scripting, even though Test Manager is installed and licensed, and the script runs in GUI mode?
Is there a way to ensure the Test Manager interface is loaded or accessible from the scripting environment?
π§ Summary:
I'm trying to automate test execution using the CODESYS scripting engine (Python) via a script that opens a project, builds the application, and runs tests from a TestRepository.xml. Although the Test Manager works manually in the IDE, it fails when accessed via script with the following error:
AttributeError: 'ScriptObject' object has no attribute 'testmanager'
π§ͺ Test Setup:
CODESYS version: 3.5.21.10
Test Manager: Installed and licensed (works in the IDE manually)
Project: Contains a test repository, which can be executed via the GUI
testmanager = project.get_testmanager()
β Problem:
Calling project.get_testmanager() or application.testmanager throws an AttributeError, even though the same project and test repository work in the GUI.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you want to use the Test Manager, I prefer to start all the tests through the scripts of this manager. So open from there the projects, load it and run it. If you also want to use Python scripts to access CODESYS functionality, while executing a Test Manager script, then also start them from the Test Manager commands.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
What I'm ultimately trying to achieve is automated test execution as part of a CI/CD pipeline (e.g. in GitLab or Azure DevOps). For this, I need to:
Open a CODESYS project via script
Build the project
Run the Test Manager tests from a .TestRepository.xml
Collect test results (e.g., pass/fail + a report)
Exit with a proper return code (for pipeline success/failure)
To integrate this into automation, Iβm using the CODESYS scripting engine via Python (headless), but the issue is that the get_testmanager() function isn't available on the project object β even though Test Manager is installed, licensed, and works interactively in the IDE.
Are you suggesting that I should:
Use the Test Manager GUI to script the logic with its internal scripting language?
Or is there a way to launch the Test Manager in headless/scripted mode, while still being able to control things via Python?
If there's a supported way to automate tests with the Test Manager using scripting, especially from pipelines or headless environments, Iβd really appreciate any pointers or example workflows.
Thanks again!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
β Issue: TestManager Not Available in Python Script (AttributeError)
π Question:
Why does project.get_testmanager() not work in scripting, even though Test Manager is installed and licensed, and the script runs in GUI mode?
Is there a way to ensure the Test Manager interface is loaded or accessible from the scripting environment?
π§ Summary:
I'm trying to automate test execution using the CODESYS scripting engine (Python) via a script that opens a project, builds the application, and runs tests from a TestRepository.xml. Although the Test Manager works manually in the IDE, it fails when accessed via script with the following error:
AttributeError: 'ScriptObject' object has no attribute 'testmanager'
π§ͺ Test Setup:
CODESYS version: 3.5.21.10
Test Manager: Installed and licensed (works in the IDE manually)
Project: Contains a test repository, which can be executed via the GUI
Script execution method:
powershell
Start-Process -FilePath "C:\Program Files\CODESYS 3.5.21.10\CODESYS\Common\CODESYS.exe" `
-ArgumentList @(
'--profile="CODESYS V3.5 SP21 Patch 1"',
'--runscript="C:\Scripts\run_tests.py"'
) -Wait
π Script Summary:
python
project = projects.open(project_path)
application = project.active_application
application.build()
This fails:
testmanager = project.get_testmanager()
β Problem:
Calling project.get_testmanager() or application.testmanager throws an AttributeError, even though the same project and test repository work in the GUI.
If you want to use the Test Manager, I prefer to start all the tests through the scripts of this manager. So open from there the projects, load it and run it. If you also want to use Python scripts to access CODESYS functionality, while executing a Test Manager script, then also start them from the Test Manager commands.
Thank you for your input!
What I'm ultimately trying to achieve is automated test execution as part of a CI/CD pipeline (e.g. in GitLab or Azure DevOps). For this, I need to:
Open a CODESYS project via script
Build the project
Run the Test Manager tests from a .TestRepository.xml
Collect test results (e.g., pass/fail + a report)
Exit with a proper return code (for pipeline success/failure)
To integrate this into automation, Iβm using the CODESYS scripting engine via Python (headless), but the issue is that the get_testmanager() function isn't available on the project object β even though Test Manager is installed, licensed, and works interactively in the IDE.
Are you suggesting that I should:
Use the Test Manager GUI to script the logic with its internal scripting language?
Or is there a way to launch the Test Manager in headless/scripted mode, while still being able to control things via Python?
If there's a supported way to automate tests with the Test Manager using scripting, especially from pipelines or headless environments, Iβd really appreciate any pointers or example workflows.
Thanks again!