Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

parameterization of xpath

Options
nidhi
nidhi Posts: 10

Can i parameterize the below path instead of hardcoding-

/root/item[type/Id/text()="123"]/Price/Amount

I want to parameterize id .

Tagged:

Answers

  • benken_parasoft
    benken_parasoft Posts: 1,258 ✭✭✭
    Options

    Yes! Parameterization works in XPaths the same as it does elsewhere in SOAtest. For example, if you have a variable or column named "id" you would reference it as ${id}. So, in an XPath you would have /root/item[type/Id/text()="${id}"]/Price/Amount.

  • nidhi
    nidhi Posts: 10
    Options

    Ya it’s working fine and I added a assertion as well but when i am
    Clicking on evaluate xpath its says no node found instead of giving value
    Can you tell why i am getting that
    @benken_parasoft

  • benken_parasoft
    benken_parasoft Posts: 1,258 ✭✭✭
    Options

    What type of variable is "id"? If it assigned a value dynamically, like a test variable or data bank column, then the tool wouldn't be able to resolve it outside of test execution. Otherwise, a static variable like an environment variable are generally the only type of variable that can be resolved outside of test execution.

  • nidhi
    nidhi Posts: 10
    edited October 2023
    Options

    It’s static, i am taking that value from csv file but still i am getting no nodes found @benken_parasoft

  • benken_parasoft
    benken_parasoft Posts: 1,258 ✭✭✭
    Options

    Data sources are dynamically loaded at runtime. If there is an "id" column, the value would also be different depending on the row. UI fields won't resolve that type of variable automatically but the value would be resolved at runtime.

  • nidhi
    nidhi Posts: 10
    Options

    No, i am giving fixed value, i have created id column in my csv file and have given my id value and that id i am parametrizing but its not fetching while clicking on evaluate xpath

  • benken_parasoft
    benken_parasoft Posts: 1,258 ✭✭✭
    Options

    i have created id column in my csv file

    This is a dynamic value. The value of "id" can be different depending on the row. The values from your CSV file will be loaded and available at runtime but not from any UI controls.

  • nidhi
    nidhi Posts: 10
    Options

    Got ii now, thank you @benken_parasoft

Tagged