Forum Discussion
try
7 years agoNew Contributor
I have a groovy scripts which needs to fetch two env variables say A and B set by me. How can i access it. I tried it with context.expand('${#Env#windir}' ) but does not work.
Brian_Mowbraywrote:
I would like to read an environment variable from within a groovy test step.
I saw this posting: http://www.soapui.org/userguide/properties.html
I tried to follow this as an example and wrote the following, but I think my formatting is off:
def value = "${#Env#windir}";
I get an ugly error, I assume to be complaining about the "#"
@org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, Script34.groovy: 7: unexpected char: '#' @ line 7, column 16.org.codehaus.groovy.syntax.SyntaxException: unexpected char: '#' @ line 7, column 16. at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:87) at org.codehaus.groovy.antlr.AntlrParserPlugin.parseCST(AntlrParserPlugin.java:61) at org.codehaus.groovy.control.SourceUnit.parse(SourceUnit.java:249) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:160) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:798) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:464) at groovy.lang.GroovyClassLoader.parseClass(GroovyClassLoader.java:278) at groovy.lang.GroovyShell.parseClass(GroovyShell.java:590) at groovy.lang.GroovyShell.parse(GroovyShell.java:602) at groovy.lang.GroovyShell.parse(GroovyShell.java:582) at groovy.lang.GroovyShell.parse(GroovyShell.java:621) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.compile(SoapUIGroovyScriptEngine.java:85) at com.eviware.soapui.support.scripting.groovy.SoapUIGroovyScriptEngine.run(SoapUIGroovyScriptEngine.java:56) at com.eviware.soapui.support.scripting.groovy.SoapUIProGroovyScriptEngineFactory$SoapUIProGroovyScriptEngine.run(SourceFile:50) at com.eviware.soapui.impl.wsdl.teststeps.WsdlGroovyScriptTestStep.run(WsdlGroovyScriptTestStep.java:148) at com.eviware.soapui.impl.wsdl.panels.teststeps.GroovyScriptStepDesktopPanel$RunAction$1.run(GroovyScriptStepDesktopPanel.java:273) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: Script34.groovy:7:16: unexpected char: '#' at org.codehaus.groovy.antlr.parser.GroovyLexer.nextToken(GroovyLexer.java:687) at org.codehaus.groovy.antlr.parser.GroovyLexer$1.nextToken(GroovyLexer.java:248) at groovyjarjarantlr.TokenBuffer.fill(TokenBuffer.java:69) at groovyjarjarantlr.TokenBuffer.LA(TokenBuffer.java:80) at groovyjarjarantlr.LLkParser.LA(LLkParser.java:52) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.nls(GroovyRecognizer.java:777) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.openOrClosableBlock(GroovyRecognizer.java:8526) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.stringConstructorValuePart(GroovyRecognizer.java:13078) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.stringConstructorExpression(GroovyRecognizer.java:11591) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.primaryExpression(GroovyRecognizer.java:10767) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.pathExpression(GroovyRecognizer.java:10598) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.postfixExpression(GroovyRecognizer.java:12732) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.unaryExpressionNotPlusMinus(GroovyRecognizer.java:12701) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.powerExpressionNotPlusMinus(GroovyRecognizer.java:12405) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.multiplicativeExpression(GroovyRecognizer.java:12337) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.additiveExpression(GroovyRecognizer.java:12007) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.shiftExpression(GroovyRecognizer.java:9564) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.relationalExpression(GroovyRecognizer.java:11912) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.equalityExpression(GroovyRecognizer.java:11852) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.regexExpression(GroovyRecognizer.java:11800) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.andExpression(GroovyRecognizer.java:11768) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.exclusiveOrExpression(GroovyRecognizer.java:11736) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.inclusiveOrExpression(GroovyRecognizer.java:11704) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.logicalAndExpression(GroovyRecognizer.java:11672) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.logicalOrExpression(GroovyRecognizer.java:11640) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.conditionalExpression(GroovyRecognizer.java:4919) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.assignmentExpression(GroovyRecognizer.java:7840) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.expression(GroovyRecognizer.java:8214) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.varInitializer(GroovyRecognizer.java:2644) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.variableDeclarator(GroovyRecognizer.java:7741) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.listOfVariables(GroovyRecognizer.java:7695) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.variableDefinitions(GroovyRecognizer.java:2240) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.declaration(GroovyRecognizer.java:2102) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.statement(GroovyRecognizer.java:1198) at org.codehaus.groovy.antlr.parser.GroovyRecognizer.compilationUnit(GroovyRecognizer.java:741) at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:83) ... 18 more 1 error
Related Content
- 11 years ago
Recent Discussions
- 2 days ago