Forum Discussion

tgeliot's avatar
8 years ago

Using a File datasource to read a file full of JSON (and then to use that JSON with a JSON datasourc

My testing situation involves reading a file that contains JSON and examining particular items within that file using a JSONpath expression.  I have been writing Groovy scripts that use JSONSlurper to pull in the JSON, and then examining the resulting Map objects (not using JSONpath).  It was suggested that I could use a Datasource test step of type "File" to read in the JSON, and then a subsequent Datasource test step of type "JSON" to examine it.


I created a File Datasource test step, and have successfully read in the file (I believe this because I see the file contents in the Data Log tab).  But in the Properties for this test step, I see a property whose value is just a single squiggly bracket.  I've tried putting different things in the "separator" box (a comma, nothing, left or right squiggly brackets, xxxx) to no avail.


Can anyone direct me on how to use these Datasource test steps this way, or should I just go back to typing Groovy scripts?



I tried to use a File datasource, and the resulting property just contained the last line of the file.

My file is not comma-separated or anything like that, it’s JSON.  I couldn’t figure out any value to put in the “separator” box that would work.

Is this because I used File and not Filewait?

13 Replies

  • AntonE's avatar
    SmartBear Alumni (Retired)

    Hi, tgeliot


    I suggest you try File Wait test step for reading your JSON file instead. It can wait for a file to appear, but more importantly it reads its content to fileContent property, which you later can address to in JSON DataSource.


    File DataSource is useful when you have a file with easily separated property values (comma-separated, etc).

    • amarcilla's avatar
      Occasional Contributor

      hi  Anton Egorov


      I'm trying to use File Wait test step for reading a JSON request

      But don't know if I'm usinf well.

      What do you mean by  "it reads its content to fileContent property"?


      Thanks & regards




      • AntonE's avatar
        SmartBear Alumni (Retired)

        Hi Anna,


        File Wait test step has custom property fileContent. After the step is executed, this property will have the content of your file. You can access it in the following test steps using property expansion string - "${File Wait#fileContent}", where "File Wait" is the name of your File Wait step. In most cases Get Data item in context menu will generate this string for you.


        In case of JSON DataSource you should choose your File Wait step in Source Step and fileContent in Source property (see You should run the test case at least once to be able to select nodes from the actual file, using buttons next to Row Path and Column Paths fields.