Ask a Question

How to NOT expand within context.expand


How to NOT expand within context.expand

I'm creating a string that I'm passing via a project-level variable, and inserting into the body of another string. Problem is, this string includes text that looks like a property expansion. The text disappears when I retrieve it using context.expand.


Here's the setup:


def properties = '''
<cm:property name="configName" value="''' + configName + '''"/>
<cm:property name="sendEventsQuery" value="${query.allMemberEvents}" />
<cm:property name="productFilter" value="''' + productFilter + '''" />

Note that I want the text ${query.allMemberEvents} to be treated as a literal, because it's being used by another process. This works fine when I look at the "properties" variable in my code.


I save that into a project-level variable:


testRunner.testCase.testSuite.project.setPropertyValue("blueprintProperties", properties)

However, when I do this in another script:



def blueprintProperties = context.expand('${#Project#blueprintProperties}')


the method treats the ${query.allMemberEvents} as a property expansion, and since it isn't, the result is an empty string.


I tried variations of single quotes, backslashes, etc., but nothing has worked thus far. 


Any ideas? 








SmartBear Alumni (Retired)



You can use the getPropertyValue method to get data from a project property instead of context.expand.

Does this work for you?

Tanya Yatskovskaya
SmartBear Community and Education Manager

Thank you! Can't believe I missed that one...


Showing results for 
Search instead for 
Did you mean: