|
1 | 1 | # Get Started |
2 | 2 |
|
3 | | -TODO |
| 3 | +Welcome to RobotCode! In this section, we will get your Visual Studio Code set up and go through the basics: installing the extension, setting up your environment, and verifying everything is working smoothly. |
| 4 | + |
| 5 | +## Requirements |
| 6 | +- Python 3.8 or above |
| 7 | +- Robotframework version 4.1 and above |
| 8 | +- VSCode version 1.82 and above |
| 9 | + |
| 10 | +## Installing RobotCode |
| 11 | + |
| 12 | +1. Open Visual Studio Code. |
| 13 | +2. Inside Visual Studio Code, create a new project folder or open an existing one where you want to set up your Robot Framework project. |
| 14 | +3. Go to the **Extensions** tab (Shortcut key `CTRL + SHIFT + X`). |
| 15 | +4. Search for **RobotCode** and install the extension {.inline-icon} [RobotCode - Robot Framework Support](https://marketplace.visualstudio.com/items?itemName=d-biehl.robotcode "RobotCode Extension"). This will also install the **Python** and **Python Debugger** extensions. |
| 16 | +5. **(Recommended)** Install the **Even Better TOML** extension for handling `.toml` files more effectively. This will be helpful when setting up your project settings in the [Configuration](./configuration) section. |
| 17 | + |
| 18 | +After installation: |
| 19 | + - Right-click on the RobotCode extension in the Extensions tab. |
| 20 | + - Click **Add to Workspace Recommendations** to ensure that all team members working on this project are prompted to install the RobotCode extension, creating a consistent development environment for everyone. |
| 21 | + |
| 22 | +{style="width: 30%;"} |
| 23 | + |
| 24 | +## Initialize an Empty Project |
| 25 | + |
| 26 | +To get started with your Robot Framework project, we'll create a `requirements.txt` file to list all necessary dependencies, and set up a virtual Python environment to ensure these dependencies are installed in an isolated space, avoiding conflicts with other projects. |
| 27 | + |
| 28 | +1. **Create a `requirements.txt` file** in the root folder of your project and add the following dependencies: |
| 29 | +::: code-group |
| 30 | +```txt:line-numbers [requirements.txt] |
| 31 | +robotframework |
| 32 | +robotframework-tidy |
| 33 | +``` |
| 34 | +::: |
| 35 | + |
| 36 | +2. **Set up your Python environment:** |
| 37 | + |
| 38 | +A virtual environment is a self-contained directory that contains a Python installation for a particular version of Python, plus a number of additional packages. This helps keep your project dependencies isolated from other projects. In this step we will let Visual Studio Code create a virtual environment using the selected Python version, install the dependencies listed in requirements.txt, and activate the virtual environment. This ensures that your project has all the necessary packages and an isolated environment for development. |
| 39 | + |
| 40 | +1. Click on **Create Environment** in Visual Studio Code. If this button isn't visible, you can alternatively open the Command Palette by pressing `CTRL + SHIFT + P`, then search for **Python: Create Environment**, and select it. |
| 41 | +2. Choose **Venv**, which stands for Virtual Environment. |
| 42 | +3. Select your preferred Python version. |
| 43 | +4. Check the box for requirements.txt and click OK. |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | +## Verifying the Installation |
| 48 | +1. Open the terminal in Visual Studio Code. Make sure you are in the root folder of your project. |
| 49 | +2. Run the command `robot --version` to check if Robot Framework is installed correctly. |
| 50 | + |
| 51 | +If the command returns the Robot Framework version number, your installation is successful! If you encounter any errors, ensure that your virtual environment is activated and that all dependencies in `requirements.txt` have been installed. |
| 52 | + |
| 53 | +## Create and Run Your First Suite/Test |
| 54 | +Create a `first.robot` file in your project with the following code to demonstrate a basic example of logging a string message to the debug console: |
| 55 | + |
| 56 | +::: code-group |
| 57 | +```robot:line-numbers [first.robot] |
| 58 | +*** Test Cases *** |
| 59 | +First Test Case |
| 60 | + Log Hello world |
| 61 | +
|
| 62 | +``` |
| 63 | +::: |
| 64 | + |
| 65 | +To run this test file, press the green play button next to the `First Test Case` keyword in the code. |
| 66 | +You should see the `Hello world` output displayed in the **Debug Console** of Visual Studio Code. |
| 67 | + |
| 68 | +{style="width: 70%;"} |
| 69 | + |
| 70 | +And that's it! If you have any questions or run into issues, check out the RobotCode documentation or join our community in slack for support. Happy coding! |
0 commit comments