1

Below is the data, I have maintained in the csv file

Data

"[{'label': ' Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework.\n 1. The syntax is language-neutral, and easy for even non-programmers. Assertions and HTML reports are built-in, and you can run tests in parallel for speed.','toolTip': 'Test'}]"

Below is my scenario inside feature

And set body
      | path        | values        |
      | DataFromCSV | <Data> |
    * print body

and it prints.

{
  "DataFromCSV": [
    {
      "label": " Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework.\n 1. The syntax is language-neutral, and easy for even non-programmers. Assertions and HTML reports are built-in, and you can run tests in parallel for speed.",
      "toolTip": "Test"
    }
  ]
}

There is single \n in the csv, is it possible to add a new line when we receive this data in feature file.

Expected output after printing in scenario -

{
  "DataFromCSV": [
    {
      "label": " Karate is the only open-source tool to combine API test-automation, mocks, performance-testing and even UI automation into a single, unified framework.
      1. The syntax is language-neutral, and easy for even non-programmers. Assertions and HTML reports are built-in, and you can run tests in parallel for speed.",
      "toolTip": "Test"
    }
  ]
}
Shreyansh Jain
  • 498
  • 4
  • 7
  • honest question. are you focused on doing testing or making pretty reports ? – Peter Thomas Jul 06 '23 at 11:12
  • 1
    I am focused on Testing only and I got some assignment to create the data in the UI using the apis, so in UI, it shows \ n instead of new line so thought of asking this question. – Shreyansh Jain Jul 06 '23 at 13:33

1 Answers1

0

That's to make it valid JSON. Read this please: https://stackoverflow.com/a/68411097/143475

When you "unpack" it, you get what you want, try this experiment:

* def data = { label: 'some \n text' }
* print data
* print data.label

You are most welcome to submit a change request to the JSON spec ;)

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248