Search code examples
robotframework

Remove newline from string with robotframework


I need to remove newline from string with robotframework

Here is my string looks like

line 1 &
line 2

I try to use robotframework keywords Replace String ${a} ${\n} ${SPACE}, it doesn't works it my cases, got this error from the log

Argument types are:
<type 'unicode'>
<type 'unicode'>

It seems & unicode char causes this issue, my full string inside the log is line 1 &\nline 2 I just want to replace \n with space in this cases


Solution

  • The correct way to pass the newline character is without the curly brackets:

    ${a}=  Replace String    ${a}    \n    ${SPACE}
    Log To Console    ${a}   # prints    line 1 & line 2