How to catenate string in robot framework

The function concatenates various items into a single string by combining them together. The default separator used between items is a space character, but this can be changed by including the string “SEPARATOR=<sep>” as the first item, where <sep> is the desired separator. The items to be concatenated may need to be converted to strings, depending on their data type. The resulting string is then returned.

***settings***
Documentation     catenates the given string together and returns the resulted string

*** Variables ***

*** Keywords ***

*** Test Cases ***
string catenate

  # by default, string will be separated by space 

  ${string} =   catenate   Welcome   to   tech-bloggers
  LOG   ${string}
  log to console   ${string}

  # using '-' as separator
 
  ${string} =   Catenate	SEPARATOR=-   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string} 

  # using '*' as separator

  ${string} =   Catenate	SEPARATOR=/   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string} 

  # using '*' as separator

  ${string} =   Catenate	SEPARATOR=*   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string} 
 
  # using '#' as separator

  ${string} =   Catenate	SEPARATOR=\#   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string} 


  # using '\' as separator

  ${string} =   Catenate       SEPARATOR=\\   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using '?' as separator

  ${string} =   Catenate       SEPARATOR=?   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}


  # using '_' as separator

  ${string} =   Catenate       SEPARATOR=_   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}


  # using '9' as separator

  ${string} =   Catenate       SEPARATOR=9   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using '+' as separator

  ${string} =   Catenate       SEPARATOR=+   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using '>' as separator

  ${string} =   Catenate       SEPARATOR=>   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using '<' as separator

  ${string} =   Catenate       SEPARATOR=<   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using ',' as separator

  ${string} =   Catenate       SEPARATOR=,   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using '.' as separator

  ${string} =   Catenate       SEPARATOR=.   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using ':' as separator

  ${string} =   Catenate       SEPARATOR=:   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using '"' as separator

  ${string} =   Catenate       SEPARATOR="   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using ';' as separator

  ${string} =   Catenate       SEPARATOR=;   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using '$' as separator

  ${string} =   Catenate       SEPARATOR=$   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using '&' as separator

  ${string} =   Catenate       SEPARATOR=&   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}


  # using '@' as separator

  ${string} =   Catenate       SEPARATOR=@   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using '/n' as separator

  ${string} =   Catenate       SEPARATOR=/n   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}


  # using without any separator

  ${string} =   Catenate       SEPARATOR=   Welcome   to   tech-bloggers
  LOG  ${string}
  log to console   ${string}

  # using without any separator

  ${string} =   Catenate       SEPARATOR=   9   10  11
  LOG  ${string}
  log to console   ${string}
tech-bloggers@tech-bloggers:~/robot_example$ robot string_catenate.robot 
==============================================================================
String Catenate :: catenates the given string together and returns the resu...
==============================================================================
string catenate                                                       ..Welcome to tech-bloggers
...Welcome-to-tech-bloggers
...Welcome/to/tech-bloggers
string catenate                                                       ...Welcome*to*tech-bloggers
...Welcome#to#tech-bloggers
string catenate                                                       .Welcome\to\tech-bloggers
...Welcome?to?tech-bloggers
...Welcome_to_tech-bloggers
string catenate                                                       ..Welcome9to9tech-bloggers
...Welcome+to+tech-bloggers
...Welcome>to>tech-bloggers
string catenate                                                       ...Welcome<to<tech-bloggers
...Welcome,to,tech-bloggers
string catenate                                                       .Welcome.to.tech-bloggers
...Welcome:to:tech-bloggers
...Welcome"to"tech-bloggers
string catenate                                                       ..Welcome;to;tech-bloggers
...Welcome$to$tech-bloggers
...Welcome&to&tech-bloggers
string catenate                                                       ...Welcome@to@tech-bloggers
...Welcome/nto/ntech-bloggers
string catenate                                                       .Welcometotech-bloggers
...91011
string catenate                                                       | PASS |
------------------------------------------------------------------------------
String Catenate :: catenates the given string together and returns... | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Output:  /home/tech-bloggers/robot_example/output.xml
Log:     /home/tech-bloggers/robot_example/log.html
Report:  /home/tech-bloggers/robot_example/report.html

Leave a Comment

Your email address will not be published.