Forum Discussion

JackStoneS's avatar
JackStoneS
Occasional Contributor
8 years ago
Solved

NullPointerException on XPathContains (JDBC-teststep): why?

I have a JDBC-teststep, requesting some info from a database.

I get some rows back, and want to assert their validity with an XPathContains.

For the first row, this works: the data matches and the assertion is green.

 

On subsequent assertions I get the correct error if the data does not match, but I get an error if the data does match: XPathContains assertion failed for path [/Results/ResultSet/Row[2]] : NullPointerException:null (see screenshot)

 

What can I do to get the assertion to green?

  • nmrao's avatar
    nmrao
    8 years ago
    Glad to know that it worked.

    As mentionedarlier, list order of Rows may get changed.

    Below should have worked too(it is different from initial reply)
    //Results/ResultSet/Row[@rowNumber='2']

    I think you should rely on VISSOORT is DAB.

    Hope this helps. You can close it by accepting the solution if you wish.

6 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    Can you try the below

     

    //Results/ResultSet[Row[@rowNumber='2']]/Row

    • JackStoneS's avatar
      JackStoneS
      Occasional Contributor

      That expression seems to match all of the rows:

       

      XPathContains assertion failed for path [//Results/ResultSet[Row[@rowNumber='2']]/Row] : Exception:org.custommonkey.xmlunit.Diff [different] Expected attribute value '2' but was '6' - comparing at /Row[1]/@rowNumber to at /Row[1]/@rowNumber

       

      Select from current: "More than one match in current response"

       

      • nmrao's avatar
        nmrao
        Champion Level 3

        Sorry about it, try this one:

         

        //Results/ResultSet/Row[@rowNumber='2']

         

        Even the above may fail at times if the row order changes, in that case you may use below one as Value of VISSOORT is DAB

         

         

        //Results/ResultSet/Row[VISSOORT='DAB']