Passing a parameter from Azure/devops into TestComplete
- 6 years ago
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.