String Concatenation

13,799 views
Skip to first unread message

sangeet

unread,
Apr 12, 2012, 2:32:40 AM4/12/12
to robotframe...@googlegroups.com
Hi,

Any idea on how to go about concatenating 2 strings into a new one in Robot? 

Thanks,
Sangeet

SOURABH TIWARI

unread,
Apr 12, 2012, 2:36:58 AM4/12/12
to mrsa...@gmail.com, robotframe...@googlegroups.com
Hi Sangeet,

You can use catenate .

Name: Catenate
Source: BuiltIn <test library>
Arguments: [ *items ]

Catenates the given items together and returns the resulted string.
By default, items are catenated with spaces, but if the first item
contains the string 'SEPARATOR=<sep>', the separator '<sep>' is used.
Items are converted into strings when necessary.
Examples:
${str1} = Catenate Hello world
${str2} = Catenate SEPARATOR=--- Hello world
${str3} = Catenate SEPARATOR= Hello world
=>
- ${str1} = 'Hello world'
- ${str2} = 'Hello---world'
- ${str3} = 'Helloworld'

Thanks
Sourabh

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/robotframework-users/-/cdipZelSdYcJ.
To post to this group, send email to robotframe...@googlegroups.com.
To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.



--

--
Thanks & Regards

SOURABH TIWARI

Tatu Aalto

unread,
Apr 12, 2012, 2:34:34 AM4/12/12
to robotframe...@googlegroups.com
Ugh

See the BuildIn library Catenate [1] keyword, that should do the trick

-Tatu

[1]
http://robotframework.googlecode.com/hg/doc/libraries/BuiltIn.html#Catenate

Pekka Klärck

unread,
Apr 12, 2012, 2:54:15 AM4/12/12
to mrsa...@gmail.com, robotframe...@googlegroups.com
2012/4/12 sangeet <mrsa...@gmail.com>:

>
> Any idea on how to go about concatenating 2 strings into a new one in
> Robot?

In addition to using the already proposed Catenate keyword, you can
also just use the strings together as a single argument for a keyword.
Assuming your have strings in variables ${str1} and ${str2}, you can
simply do something like this:

My Keyword ${str1} ${str2}

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

sangeet

unread,
Apr 12, 2012, 2:58:41 AM4/12/12
to robotframe...@googlegroups.com, mrsa...@gmail.com

Hey thanks for the quick reply Sourabh.

However i'm facing a problem using the separator. I'm not sure why.
I've attached a snippet of the report below

KEYWORD: ${b} = BuiltIn.Catenate SEPARATOR=--, Hello World
Documentation:
Catenates the given items together and returns the resulted string.
Start / End / Elapsed: 20120412 12:25:11.762 / 20120412 12:25:11.762 / 00:00:00.000
12:25:11.762 INFO ${b} = Hello World

As you can see, I'm not getting Hello--World as shown in the example. :(

What am i doing wrong?

Thanks,
Sangeet
To post to this group, send email to robotframework-users@googlegroups.com.
To unsubscribe from this group, send email to robotframework-users+unsub...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.

SOURABH TIWARI

unread,
Apr 12, 2012, 3:29:19 AM4/12/12
to mrsa...@gmail.com, robotframe...@googlegroups.com
Hi Sangeet,

I guess you are not passing Hello and World as separate parameters.

You should use catenate like below example :



or how pekka suggested .



Thanks

Sourabh

To view this discussion on the web visit https://groups.google.com/d/msg/robotframework-users/-/_g4uZVpZP0IJ.

To post to this group, send email to robotframe...@googlegroups.com.
To unsubscribe from this group, send email to robotframework-u...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.

sangeet

unread,
Apr 12, 2012, 3:53:07 AM4/12/12
to robotframe...@googlegroups.com, mrsa...@gmail.com
Yea, you were right  I got it working now. 

Thanks,
Sangeet
To unsubscribe from this group, send email to robotframework-users+unsubscrib...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.



--

--
Thanks & Regards

SOURABH TIWARI

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/robotframework-users/-/_g4uZVpZP0IJ.

To post to this group, send email to robotframework-users@googlegroups.com.
To unsubscribe from this group, send email to robotframework-users+unsub...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/robotframework-users?hl=en.
Reply all
Reply to author
Forward
0 new messages