How to access environment variable in Databank
Hi Team
I am using concat function in databank xpath evaluation, where i need to fetch the environment variable value. How to do it?
These are the below things i tried.
${soa_env:Environment}
${Environment}
Note: Environment is a environment variable. ( I was able to refer in all the test clients.)
Comments
-
Any update on this??
0 -
To the best of my understanding, variables do work in XPaths used for extractions. You may want to contact Parasoft support if you need further help. Otherwise, you may want to provide more detail in case you are looking for an answer from someone in the community.
0 -
Hope this image helps for better understanding0 -
I can see you miss a closing } in environment variable.
concat(${variable}, "")0 -
That was a typo, still i am getting the error.
Cannot evaluate. Not a valid XPath expression.
Have you tried this option?0 -
Two things:
First, your XPath is not valid. The concat function takes a string. Put your variable reference in double quotes since you are passing it as an argument to concat.
Second, the UI won't resolve the variable, like when clicking Evaluate XPath. However, the variable will be resolved at runtime when your test suite is actually being executed. In other words, there may still be cases where clicking Evaluate XPath may show an error when the XPath will be valid at test suite execution when variables can be resolved. However, as mentioned, I suspect you probably want your variable in double quotes to make it a proper string unless the variable's value already happens to be quoted.
This works for any type of variable (environment variable, test suite variable, data bank column, data source column, etc.)
0 -
I tried all the possibilities and run time option as well.. it was not working..After the error is gone, I tried printing to console using extension tool and got nothing.
Have you tried accessing in this way??
0 -
Are you sure the variable is spelled correctly? Your active environment has a variable name "Environment"?
0 -
Yes it is..
0 -
After the error is gone, I tried printing to console using extension tool and got nothing.
You mentioned "error is gone". I assume you mean the XPath error is not being reported, right? If this is the case then perhaps you are doing something wrong in your extension tool.
0 -
Okay.....lets try this again. Can you please confirm this setup on your end?
concat( ' {"${myEnv}": ' , ' " ' , /root/pennywise[1]/text() , ' " ', ' } ' )
0 -
Your setup is correct.. But my expectation result after the evaluation is
{"pennywise":"pennywise"}
I need the value of myEnv variable to be replaced here in evaluation.
0 -
As stated by @benken_parasoft, the environment variable does not get resolved when you click "Evaluate XPath". But it will still get resolved at runtime if you have specified it correctly.
0 -
OOPS, Its working as expected.
There was a problem with extension tool.
I am terribly Sorry about it.0 -
Yes, the xpath may not evaluate successfully in the result window, but it will parameterize as expected during run time. Run your test with this updated setup and verify the result.
1