I have been using Visual Studio Code(Mac-version) for my RF tests. Only two issues I encounter are:
My indentation is all wrong. I cant seem to line anything up with my tabs. It only seems to happen with .robot -files and not with .py etc.
I tried making changes to my settings.json file for indentation but nothing seems to work.
Please help me with this because its very frustrating.
A copy of my settings.json is added as an appendix
When I run my tests from the testrunner button (Run Tests/Suite, upper right button)
it seems to store the output.xml and report.html file in the project folder. I have a “Results” directory which I can use to store the output.xml and report.html-files if I run the tests with “robot -d results tests/crm.robot”.
Using a button seems easier and faster. Is there a way I can change the directory in which the results are stored to /Users/laurens/projects/robotframework/Results automatically?
Many thanks in advance!
which extension you are using for robotframework?
@LaurensRobot can you show some code showing a sample code with an example so that I can help you diagnose what’s actually happening?
i.e.: Something as: given code: xxx when I press tab at: xxx I’d like to have the code: xxx as a result.
As a note, the setting related to:
robot.editor.4spacesTab is the one that makes a tab enter 4 spaces (instead of using the default indent which would add spaces up to a multiple of 4). Perhaps setting it to false is what you want?
For number 2 (customizing the output), you need to configure your launch configuration for those shortcuts (i.e.: you need to add arguments to the launch configuration used in this case).
See: robotframework-lsp/faq.md at master · robocorp/robotframework-lsp · GitHub for details on how to do that.
Here’s an example.
The first four lines line up perfectly, but when I use a different keyword it doesn’t.
It seems that when I first use the tab after the keyword it only moves 2 spaces, but when I press TAB a second time it moves 4…
@LaurensRobot I believe that what you want is really setting robot.editor.4spacesTab to false.
In that case it’ll always indent the cursor to a multiple of your indent size (so, yes, when you press tab the first time it’ll indent up to the next multiple and then it’ll add 4) – if you use it consistently you’ll note that the indent will end up matching because it’ll always be a multiple of 4 (but you have to adjust existing text…).
But still, I’d actually recommend against using that (because it’ll always indent to a multiple of 4 sometimes it’ll add just 1 space and you’ll have to use tab again to actually add a separator… note that this is the default VSCode indent behavior and it’s the reason for the robot.editor.4spacesTab setting) and just using the formatter that comes with the Robot Framework Language Server – the bundled formatter is actually robotframework-tidy (you can see Robotidy 3.3.2 for its docs).
Personally what I do is enabling format on save and let the formatter deal with it (you can configure the formatter creating a pyproject.toml which is then picked up by robotframework-tidy – its page has more info).
To enable format on save just for robot files you could use something as: