Forum Discussion

Philippe_Lebacq's avatar
Philippe_Lebacq
Contributor
15 years ago

Xpath match with custom property

I have a project custom property I'm using in the endpoint and that I want to verify in xpath match assertion.
This works OK when my property contains an integer, but not with a letter:
( ${#Project#testenv} = A ... ) ==> always returns false when property = A, I tried = A, = 'A', = "A" and also the string function.
Any idea for this to work?

property:
testenv=A

assertion:
declare namespace cwsgl="https://cwssoap.toyota-europe.com/cws/services/cws_global/1.xsd";
( ${#Project#testenv} = 1 and //cwsgl:errorNumber[1]/text()="W004" )
or ( ${#Project#testenv} = 8 and //cwsgl:AssessmentStatusAR[1]/text()="RE" )
or ( ${#Project#testenv} = A and //cwsgl:AssessmentStatusAR[1]/text()="RE" )

Kinds
Philippe.
  • Hi,

    The best way to perform the same is try to use Script assertion instead of Xpath match assertion.
    However, if you want to stick with Xpath match assertion try to use the following approach :

    To perform the string match also use the property variables. Like
    //cwsgl:errorNumber[1]/text() = ${#Project#new_propertry_w004}

    So whereever you have anything to match, just create a property variable for that & perform the logical operation.

    I hope this would be of some help.

    ~~ Pradeep Bishnoi ~~
  • Hi,

    unfortunately, same error as before:

    a test matching this condition (project properties testenv=8 and env8 = returns true :
    ( ${#Project#testenv} = ${#Project#env8} and //cwsgl:AssessmentStatusAR[1]/text()="RE" )

    but a test matching this condition (with project properties testenv=A and envA = A) returns false while I was expecting true :

    ( ${#Project#testenv} = ${#Project#envA} and //cwsgl:AssessmentStatusAR[1]/text()="XX" )

    Any help?
    Philippe.
  • Hi Philippe,

    As replied earlier, it worked for me that way.
    I noticed in your response that you are still using string to compare.
    Some minor checks you can do :
    1.> check the property variable name being called, is it env8 or envA ??
    2.> replace "RE" or "XX" with another new property and match that as a property.
    3.> check out for the spaces in the property values, tht will affect the response.

    Regards,
    ~~ Pradeep Bishnoi ~~
  • Hi

    well the 'right' part of the conditions (where I test the answer content) are OK - I think so - the problem comes from the 'left' part ( where I test the custom property value).

    What I'm trying to verify is different answer content based on the test environment inhich I ran the request (this environment is stored in the custom property as a alphanumeric value).

    So when the environment property contains an integer, my conditions (both left & right parts) returns true/false as expected, but when the environment property contains a letter, my condition always returns false.
    So in other words, when I test custom property content, a test such as if 1 = 1 returns true, but if "A" = "A" returns false.

    Any other idea ?
    Philippe.
  • Hi

    well the 'right' part of the conditions (where I test the answer content) are OK - I think so - the problem comes from the 'left' part ( where I test the custom property value).

    What I'm trying to verify is different answer content based on the test environment inhich I ran the request (this environment is stored in the custom property as a alphanumeric value).

    So when the environment property contains an integer, my conditions (both left & right parts) returns true/false as expected, but when the environment property contains a letter, my condition always returns false.
    So in other words, when I test custom property content, a test such as if 1 = 1 returns true, but if "A" = "A" returns false.

    Any other idea ?
    Philippe.
  • Don't forget to use quots around your property
    //cwsgl:errorNumber[1]/text() = '${#Project#new_propertry_w004}'