Is there is any way to comment multiple lines in Robot framework.
In python we have option like ''' and ''''.
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.
Lines starting with the # character are ignored by Robot Framework and are used for comments like in this example: # This is a code comment.
To comment out multiple code lines right-click and select Source > Add Block Comment. ( CTRL+SHIFT+/ ) To uncomment multiple code lines right-click and select Source > Remove Block Comment. ( CTRL+SHIFT+\ )
Unlike other programming languages such as JavaScript, Java, and C++ which use /*... */ for multi-line comments, there's no built-in mechanism for multi-line comments in Python. To comment out multiple lines in Python, you can prepend each line with a hash ( # ).
No, you have to use #
in front of every line you want to comment.
Nevertheless note that:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With