How to access environment variable in Databank

ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

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.

Note: Environment is a environment variable. ( I was able to refer in all the test clients.)


  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

    Any update on this??

  • benken_parasoftbenken_parasoft Posts: 708 ✭✭✭

    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.

  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭
    edited September 2017

    Hope this image helps for better understanding

  • grigorbgrigorb Posts: 17

    I can see you miss a closing } in environment variable.
    concat(${variable}, "")

  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

    That was a typo, still i am getting the error.
    Cannot evaluate. Not a valid XPath expression.
    Have you tried this option?

  • benken_parasoftbenken_parasoft Posts: 708 ✭✭✭
    edited September 2017

    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.)

  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

    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??

  • benken_parasoftbenken_parasoft Posts: 708 ✭✭✭

    Are you sure the variable is spelled correctly? Your active environment has a variable name "Environment"?

  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

    Yes it is..

  • benken_parasoftbenken_parasoft Posts: 708 ✭✭✭

    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.

  • OmarROmarR Posts: 214 admin
    edited September 2017

    Okay.....lets try this again. Can you please confirm this setup on your end?

    concat( ' {"${myEnv}": ' , ' " ' , /root/pennywise[1]/text() , ' " ', ' } ' )

  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

    Your setup is correct.. But my expectation result after the evaluation is


    I need the value of myEnv variable to be replaced here in evaluation.

  • jakubiakjakubiak Posts: 517 admin

    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.

  • ParasofttoudayaParasofttoudaya Posts: 232 ✭✭

    OOPS, Its working as expected.
    There was a problem with extension tool.
    I am terribly Sorry about it.

  • OmarROmarR Posts: 214 admin

    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.

Sign In or Register to comment.