How to trim or strip white spaces from a String while using Robot Framework

binithb picture binithb · Jul 24, 2013 · Viewed 32.1k times · Source

How to trim or strip white spaces from a String while using Robot Framework

If I have a string " Hello How are you " how to convert it to "HelloHowareyou" (stripping all the white spaces)

Answer

kontulai picture kontulai · Jul 30, 2013

Also ${str.strip()} works. It uses the Extended variable syntax Example:

*** Variables ***
${str}=    ${SPACE}${SPACE}${SPACE}foo${SPACE}${SPACE}${SPACE}

*** Test cases ***
print string
    log    ${str}         # will be printed with spaces around it
    log    ${str.strip()} # will be printed without spaces around it

Run with pybot -L TRACE to see what is being passed to log keyword.