Forum Discussion

AAB's avatar
AAB
Regular Contributor
6 years ago
Solved

Error message "The column path must start with a row path expression"

Hi everyone,

 

For my comparison testcase I need to compare the results of 2 different files with each other. For the POC I'm using mock data in files. One is an excel file the other is a json file. The question/error message is about the json file.

Set up:

TestSteps ==> Groovy Script for DataSource2 (to read out the json file)

                       DataSource2 (to point to the file, read it out and show the content for particular columns)

                       Property Transfer (to request)

                       REST Request

                       Property Transfer2-GetResponse

                       DataSource Loop (start again at Property Transfer)

                       DataSink2-Save compare results (in an excel file)

In the REST Request I have a parameter with

  • * Name = OId
  • * Value = ${#TestCase#tempNumber}

On TestCase Level in tab 'Custom Properties' I have 2 parameters without value as it will be filled through the loop:

  • * tempNumber
  • * tempName

I've searched information about DataSource and followed the steps to insert the properties, source step, source property, row path and column paths.

The groovy script is reading the json file without problems.

Configuration of my DataSource looks like this:

I have my 2 coloms in the Data Log but when I click on the play button, nothing happens.

When I click on the green/red stripes of the Column Paths    and I select the node I'm getting this error message as in title.

Can someone explain me what I'm doing wrong please?

 

Thanks in advance.

  • AAB,

     

    I've managed to get the cbe_number and denominations values with the following settings:

     

    Does it suit you?

     

    The expression in the Row Path field is the beginning of the full expression. It's common for properties.

    The expression in the Column Paths is the end of the expression.

     

    So, the full expressions will look like:

    $['cbe_number'] - for the cbe_number property

    and

    $['denominations'][0]['value'] - for the denomination property

12 Replies

  • richie's avatar
    richie
    Community Hero

    Hey AAB 

     

    I don't know if they've changed it - but I always used to have problems using the json datasource option - I always struggled with the json datasource step - I think it might be a little buggy or perhaps I was doing something wrong (I also find xpath easier to deal with and read than jsonpath)  - but I found setting it up was a lot easier if I used an XML datasource instead step instead of the json datasource.

     

    Despite the fact that the response of the request that I was using to populate my datasource was actually .json  - I added the XML datasource in and specified the 'source property' dropdown on the XML datasource as 'ResponseAsXML'.

     

    I was then able to build up a datasource of attributes successfully sourced from my  response without too much trouble - so if your groovy step is all good - this might help.

     

    Again - and I'm guilty of this myself - but if you provided the groovyscript code on your post - this will only add to the help people can provide!

     

    Just a suggestion,

     

    Cheers,

     

    richie

    • AAB's avatar
      AAB
      Regular Contributor

      Hello richie 

      I already had read your post somewhere, but in my case the file will expand proportionally (understand up to 35GB for starters) whereas I don't think this would be a good idea to use xml. Would it? I'm just thinking about performance.

      Now it's just a mock, but in the future it will be the 'real stuff' and far more bigger then now. It also could be that for the real project I need to point to a DB, I don't know, but like I said, I don't know what this would give performance wise......

      Nevertheless, might I try to parse it into XML, How should I do this please?

       

      Secondly, my groovy code is the simplicity itself (it's just fetching the file from my harddrive:

      def file1 = new File('PathToMyHarddrive/DataSource2-MOCKEnterprisePDC.json');
      return file1.text;

       

      Thirdly: why 'ResponseAsXML' specified in the 'source property' dropdown on the XML datasource? Is that a name you gave to your file?

      I'm noticing that the body in DataSource for JSON is almost the same as for XML, only the row and columns name are different. So yes, could be a little bug.

       

      Thanks already for your answer. Hoping you could elaborate on the parsing.  :-) 

       

      Cheers,

      AAB

      • richie's avatar
        richie
        Community Hero

        Hey AAB 

         

        aah - I made a mistake - I wasn't concentrating - those additional datasources can be used to inject testdata - but personally I think they rock after generating a response - and this was what I was talking about - so don't bother looking for the ResponseAsXML option because you won't find it if you're trying to source a file from your harddrive.

         

        In regards to your use of the JSON datasource - I'm not a groovy scripter - but looking at the groovy and what youre trying to do wiht the JSON datasource - you're trying to grab specific json attributes from the 'result' variable of the groovyscript - right?

         

        Yeah - I don't think that'll work - all your groovy is doing is pointing to a testdata file and the 'results' of your script (which you are using as the source property in your JSON datasource step) is being passed to the 'results' variable on the groovy script.  The trouble is - and I'm not sure - I'm not a scripter - but I don't believe the contents of the file you are passing equates to the 'results'

         

        Hence the reason why I don't think the jsonpath is working in your JSON Datasource.

         

        This is just what "I think" - I'm learning groovy slowly myself.

         

        As an aside = I understand using groovy shortcuts a lot - but is there a reason why you're not using say a file or directory datasource rather than the groovy to load in the file?

         

        Also - is it a GET or a POST REST request?

        can you confirm what you're actually passing to the REST request step?  are you passing the whole .json file's content or just a couple of parameters?

        If you're just passing a couple of parameters - are you talking about URI/Template, Header or Query parameters or are you talking about parameters within a payload body? (hence my question about GET or POST or whatever)

         

        If you can provide the above details we should be able to sort you out - I'm not understanding why you're doing a couple of things - (e.g. like using groovy to load in the file, etc.) and this is confusing me

         

        Thanks man,

         

        richie