Issue with new line in output window with direct arguments

Hi Team,

I am trying to send the given pipe separated data as a whole string with single argument and want to see a report as a given format

Given Data as
Name | Title | Description
Jagan | Developer | Developer Job
Then I receive result as “xyz”

Can you help, how to achieve this

Thanks,
Jagan

Hi Jagan,

There’s a couple of ways you can do this, but first I’ll remind you that pipes (|) are a special charecter in robot framework, so you’ll need to escape them.

  1. First way is covered in the variable section of the user guide under Creating scalar variables. it would look something like:
*** Variables ***
${xyz}    SEPARATOR=\n
...       Name \| Title \| Description
...       Jagan \| Developer \| Developer Job

That great if you can define the variable before the test, which brings me to;

  1. The second way, you might have also have in escaping, that you can use \n for a new line, so combining this with Set Variable, will give you:
*** Test Cases ***
Jagans test
	${xyz}= 	Set Variable    Name \| Title \| Description\nJagans Bhaji \| Tester \| Test Team

But it might become a bit unwieldy if you have more than 5 lines of data, so when using this method it might be more readable (though also a bit slower) if you do it like this:

*** Test Cases ***
Jagans test
	${xyz}= 	Set Variable    Name \| Title \| Description
	${xyz}= 	Set Variable    ${xyz}\nJagans mate \| Guru \| Temple

Anyway that should give you some options,

Dave.

Thanks Dave for response,
In my scenario, I should not use any variables to keyword directly, I need to send the data to keyword directly.
Generated report shows the sending data in same line of keyword, I want to see the data in next line of keyword, can you help me with that. I found all the ways it didn’t worked(tried with \n etc)

Hi Jagan,

I’m really not sure what your asking?

Here is my example robot file:
Jagan.robot

*** Settings ***

*** Variables ***
${xyz}    SEPARATOR=\n
...       Name \| Title \| Description
...       Jagan \| Developer \| Developer Job
*** Test Cases ***
Jagans test
	Log    ${xyz}
	${xyz}= 	Set Variable    Name \| Title \| Description\nJagans Bhaji \| Tester \| Test Team
	Log    ${xyz}
	${xyz}= 	Set Variable    Name \| Title \| Description
	${xyz}= 	Set Variable    ${xyz}\nJagans mate \| Guru \| Temple
	Log    ${xyz}

And here is the log it generated:


In all 3 it’s a multi-line string, that you can pass to your keyword as ${xyz} just like I passed it to the Log keyword.

Dave.

Sure Dave, will explain more on my expected output, here is my sample code

And my current output report looks like in fig1

But I am expecting is

  1. When talking about code I am passing pipe separated data in 2 lines, it should accept as 2 arguments, but it is taking as multiple arguments because of space between the data, I want to avoid that each line should consider as a single argument
  2. When talking about report, The report shows the given data in same keyword display line, I want to see the data in new line, as same format how I give in Code
    Please check and let me know
    I want to see the report as below fig2, which I am not able to do and format as how we given in code, help me generate in same way

Fig1:

Fig2:

Hi Jagan,

The way to prevent this issue is to escape the tabs (see previously linked section on escaping), instead of:

...    CHP2|000000000000410621		|410621|EUROPE2		|OM		|PP4			|2023-03-17

you would send

...    CHP2|000000000000410621\t\t|410621|EUROPE2\t\t|OM\t\t|PP4\t\t\t|2023-03-17

I’m not sure if there’s anything you can do about that unless you post process the the HTML report.

Dave.

Thanks Dave, will check the possiblities

1 Like