Reputation: 307
Is there is any way to comment multiple lines in Robot framework.
In python we have option like ''' and ''''.
Upvotes: 18
Views: 84614
Reputation: 1
We can use #
to comment out multiple lines of code.
You can simple use ctrl + /
Upvotes: 0
Reputation:
Ideally, if you want to comment a line of Robot code, please put your cursor on that line and press ctrl+/, it will comment the line from the beginning of the line. like:
#<<Your Code lines here>>
If you want to specify what particular robot line or keyword does in front of that line or keyword, just type # and type your comment.Like:
Click &{Locator} #This keyword clicks on the locator specified.
Also, you have the option to write the documentation for the test case. For example: If your test case is all about validating login positive scenario, then you can write a documentation as:
Test case name
[Tags] Valid_credentials
[Documentation] This test case validates Login functionality with valid credentials.
Your keywords or variable declaration will start here
.....
.....
finish your test case
Hope this simple tip help.
Upvotes: 2
Reputation: 11
To comment and uncomment use Ctrl+? after selecting multiple lines.
Upvotes: 1
Reputation: 173
Ctrl + Q if you are using VS code to comment /uncomment Multiple lines of code
Upvotes: 0
Reputation: 51
Add a section *** Comment *** and put bellow all lines you want to be commented
Upvotes: 0
Reputation: 11
I just found that you can do multi line comments like this:
*** Test Cases ***
test1
${var1} Set Variable someVariable
Comment This is a comment
... with multiple
... lines.
Upvotes: 1
Reputation: 538
As of Robot Framework 3.1 there is a dedicated section/table *** Comments ***
Comments: Additional comments or data. Ignored by Robot Framework.
This was introduced because, as of 3.1 unrecognized sections/tables causes an error. For more information, see https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#test-data-syntax
Upvotes: 1
Reputation: 6935
No, you have to use #
in front of every line you want to comment.
Nevertheless note that:
Upvotes: 17
Reputation: 639
One other trick for those who want to comment in and out a lot of lines is to use ctrl + /
. That will comment out either the line that your cursor is on, or whatever lines you have highlighted. You can then highlight the lines and use ctrl + /
again to un-comment them.
Upvotes: 1
Reputation: 386342
There is no block comment feature. However, there's a subtle little trick you can use to comment out whole blocks. It's not documented to be a multiline comment feature but it can be used like that.
This trick works by knowing that robot will ignore any data in tables that are not one of the four recognized tables: keywords, tests, settings or variables. If you have some other table, anything under it up until the next table will be ignored.
The relevant section of the user guide says this:
2.1.4 Rules for parsing the data
Ignored data
When Robot Framework parses the test data, it ignores:
- All tables that do not start with a recognized table name in the first cell.
- ...
For example:
*** Test Cases ***
| test 1
| | log | this is test one
*** comment ***
| test 2
| | log | this is test two
*** Test Cases ***
| test 3
| | log | this is test three
If you run the above test you'll see that only test 1 and test3 are executed. Everything in the "comment" table are ignored.
Upvotes: 34