Reputation: 265
I'm using Robot Framework via text format with a .robot file setup. I have been looking for a way to include a pipe character |
with a space on each side in the variable to be readable content in the variable, without it causing Robot Framework to treat it as a separator. The problem is that Robot Framework always treats a pipe character with at least one space on each side of it as a separator in text format.
The reason I am looking for this is because in my tests, using Selenium2Library, some page titles I am linking to have pipe characters in them with spaces that I need to verify, preferably with an exact text match.
My variable in Robot Framework looks like this:
| ${MY VARIABLE} | This site | Check it out |
In python, this would look like this:
MY_VARIABLE = "This site | Check it out"
The above variable should include the pipe character, but in the Robot Framework example, the middle pipe character acts as a separator in the variable (since it has a space on each side of it just like the other pipe character separators).
Is there a way to tell Robot Framework to include this " | " in the content, such as wrapping the content of the variable somehow? I've tried using brackets, parenthesis and curly braces, but it didn't seem to work.
Upvotes: 4
Views: 4155
Reputation: 386342
You can prefix the pipe with a backslash. The robot framework users guide has a section on escaping:
There is no need to escape empty cells (other than the trailing empty cells) when using the pipe and space separated format. The only thing to take into account is that possible pipes surrounded by spaces in the actual test data must be escaped with a backslash
Here's an example:
*** Variables ***
| ${MY VARIABLE} | THis site \| Check it out
*** Test Cases ***
| Example #1
| | log to console | ${MY VARIABLE}
Upvotes: 8