Passing a parameter from Azure/devops into TestComplete
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Passing a parameter from Azure/devops into TestComplete
Hi,
i am recently start using TestComplete. I wonder how can I use paramters from a VsTest (e.g. Override Parameters) in order to pass a url from the pipeline into TestComplete as a parameter.
Looking forward to your help!
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There may be some useful information in here:
Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks @Marsha_R for your reply. If a read the parent item of this article, it says that using TcItem is or will become obsolete.
I would rather use the Test Adapter, but i still dont know how to pass parameters through from azure.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i found a solution.
First, I entered an overriding paramter within the pipeline.
Then, I found a script to retrieve parameters from the commandline.
function ProcessCommandLine() {
var i;
for (i = 1; i <= BuiltIn.ParamCount(); i++) {
ProcessCommandLineArgument(BuiltIn.ParamStr(i));
}
}
function ProcessCommandLineArgument(arg) {
var items;
items = arg.split("=");
if (items.length != 2) {
return;
}
switch (aqString.ToLower(aqString.Trim(items[0]))) {
case "env":
Log.Message("The 'env' argument is found! The value is '" +
aqString.Trim(items[1]) + "'");
var url_deployment = items[1];
Project.Variables.url_loginscreen = url_deployment;
break;
}
}
now my persistent Variable url_loginscreen is changed and ready to be used with the given parameter from the commandline.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I Thought this would be solved, but VsTest is not allowing me to put in a parameter. So how can I pass the environment url from the deployment from the pipeline.
within the TestComplete.exe I am able to do it by commandline:
for example: "C:\Program Files (x86)\SmartBear\TestComplete 14\x64\Bin\TestComplete.exe" "D:\Project\project.pjs" /r "env=https://projectenvironment.dev.project.com/test"
This works fine with the code written above.
But now, I want it running through the pipeline.... how to put through the url??
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, I have the answer from:
Thank you for reaching out to us. Currently, it's not possible to control what parameters TestComplete will be launched with when using the Azure DevOps integration. So, I suggest that you pass the parameter to the agent machine using a scripting task (CMD or Powershell). For example, you can create a file and store the URL there or set an environment variable that will hold the value. Then, you need to modify the test accordingly so that the URL is ready from the file or obtained from the environment variable.
With this answer from SmartBear self in mind, I created an xml file in the directory:
<?xml version="1.0"?>
-<configurations>
-<settings>
-<setting>
<url>#{EnvironmentUrl}#</url>
</setting>
</settings>
</configurations>
The #{..}# are used to replace the url as token from Azure Pipeline.
Then i wrote this script:
function RetrieveUrlFromDeployment()
{
// Create a COM object
var configFileXML = Sys.OleObject("Msxml2.DOMDocument.6.0");
configFileXML.async = false;
// Load data from a XML file
configFileXML.load("../Project/ConfigTestComplete.xml");
// Set error message when failure
if(configFileXML.parseError.errorCode != 0)
{
var errorMessage = "Reason:\t" + configFileXML.parseError.reason + "\n" +
"Line:\t" + aqConvert.VarToStr(configFileXML.parseError.line) + "\n" +
"Pos:\t" + aqConvert.VarToStr(configFileXML.parseError.linePos) + "\n" +
"Source:\t" + configFileXML.parseError.srcText;
// Post an error to the log and exit
Log.Error("Cannot parse the document.", errorMessage);
return;
}
// Use an XPath expression to obtain a list of "url" nodes
var nodes = configFileXML.selectNodes("url");
// Set Project variable to environment url.
Project.Variables.url_loginscreen = nodes.context.text;
}
This will result that TC will be able to get indirectly receive a url from Azure pipeline.
