Unable to replace embedded expression value inside a XML chunk read from a JS function, had a look at string to XML conversion. But unable to figure out what am I missing,
Scenario file has below, which calls a js function to get XML chunk containing a embedded expression,
* def customerNumber = functions.getRandomNumber()
* xml Security1 = functions.fetchSecExistMort()
* print Security1
Sharing JS function in my next comment.
Below is my javascript function,
function()
{
return {
fetchPrimaryResiAddress: function()
{
var PrimaryResidentialAddress =
`<Address>
<StreetNo>#(customerNumber)</StreetNo>
<Street Type="Street">RAWSON</Street>
<City>DEAKIN</City>
<State Name="ACT"/>
<Postcode>2600</Postcode>
<Country ISO3166="AU"/>
</Address>`;
return PrimaryResidentialAddress;
}
getRandomNumber: function()
{
var temp = '';
karate.repeat(14, function(){ temp += Math.floor(Math.random() * 9) + 1 });
return temp;
}
}
}
As part of print outcome, embedded expression #(customerNumber) isnt getting updated to customerNumber value