Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add syntax basics #57

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions code-examples/core/bdd-syntax/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
{
"name": "BDD Syntax",
"description": "readme.md",
"requirements": [
"robotframework==7.0",
"robotframework-stacktrace",
"robotframework-retryfailed"
],
"robotArgs": {
"loglevel": "TRACE",
"listener": [
"RetryFailed",
"RobotStackTracer"
]
},
"files": [
{
"fileName": "BDD.robot"
Expand Down
8 changes: 8 additions & 0 deletions code-examples/my_first_test/MyFirstTest.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*** Settings ***
Library String

*** Test Cases ***
Create A Random String
Log To Console We are going to generate a random string
Generate Random String 10
Log To Console We finished generating a random string
12 changes: 12 additions & 0 deletions code-examples/my_first_test/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "MyFirstTest",
"description": "readme.md",
"requirements": [
"robotframework"
],
"files": [
{
"fileName": "MyFirstTest.robot"
}
]
}
91 changes: 91 additions & 0 deletions website/docs/getting_started/how_to_write_rf.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
sidebar_position: 4
sidebar_label: Writing Your First Code
title: Writing Your First Code
description: The beginnings of the Robot Framework syntax
tags:
- beginner
- syntax
---
import CodeBlock from '@theme/CodeBlock';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';


# Writing Your First Code
Robot Framework is a versatile and powerful automation framework that uses plain text syntax. It is designed to be easy to read and write, making it accessible to both technical and non-technical users. In this guide, we’ll cover the basics of Robot Framework syntax to get you started.
<br/>

:::note

In this guide, we will primarily focus on testing, specifically Test Cases and Test Suites. The same principles also apply when discussing RPA Tasks.
:::
## File name
You can name your files anything you like, as long as they have the .robot extension. For example: 'MyFirstTest.robot'.

## Sections
A Robot Framework test suite consists of multiple test cases organized within a single file. The basic structure of a test suite file includes the following sections:

1. Settings
1. Test Cases
{/* Ìf more content is added, the titles above should get deeplinks */}
Although there are additional sections available, the Test Cases section is mandatory for running a test.
### Settings
The Settings section is where you define the libraries, resource files, and other settings needed for your test suite.
```robotframework
*** Settings ***
Library String
```

The libraries contain the keywords (functions/steps) that Robot Framework uses to execute tests. Each library includes documentation of the keywords it provides. To use these, importing the library is necessary.

### Test Cases or Tasks
The Test Cases or Tasks section is where you define your individual test cases. Each test case/task is a sequence of keywords. These keywords determine the steps or actions that your test or task performs. There is no limit to the number of steps a testcase can have, but there are good practices and it is good to create conventions with your co-workers to ensure readability.
<Tabs>
<TabItem value="tests" label="Tests">
```robotframework
*** Test Cases ***
Create A Random String
Log To Console We are going to generate a random string
Generate Random String 10
Log To Console We finished generating a random string
```
</TabItem>
<TabItem value="tasks" label="Tasks">
```robotframework
*** Tasks ***
Create A Random String
Log To Console We are going to generate a random string
Generate Random String 10
Log To Console We finished generating a random string
```
</TabItem>
</Tabs>
## Indentation
In the provided examples, you can see that Robot Framework code is separated by spaces. To correctly differentiate elements, Robot Framework requires at least two spaces. Here are a few examples based on the code we've seen so far:
```robotframework
*** Settings ***
Library String
```
- The `Library` keyword in the Settings section is unindented. This indicates that `Library` is the setting being declared.
- Between `Library` and `String`, there are several spaces. This indicates that `String` is the name of the library needed for our tests.

```robotframework
*** Test Cases ***
Create A Random String
Log To Console We are going to generate a random string
Generate Random String 10
Log To Console We finished generating a random string
```
- `Create A Random String` in the Test Cases section is unindented, indicating that it is a test case name.
- The lines below `Create A Random String` are indented, showing that these are keywords used in the test case.
- Several spaces between `Generate Random String` and `10` indicate that `10` is an argument for the keyword, specifying that our random string will be 10 characters long.
- The `Log To Console` keywords are followed by a few spaces and a sentence. The spaces ensure that the following sentence is the text we want to log to our console.

You can see that spacing and indentation are extremely important in Robot Framework. They are necessary to distinguish between a keyword and its arguments, as well as to differentiate between test names and the keywords within the tests. Remember, Robot Framework needs at least two spaces to correctly differentiate elements. More spaces are also allowed. For more details on spacing conventions, refer to the [Style Guide](../style_guide.md#horizontal-spacing).
## Everything together
<iframe src="https://robotframework.org/embed/?code-gh-url=https://github.com/MarketSquare/robotframeworkguides/tree/main/code-examples/my_first_test" width="100%" height="600"></iframe>


{/* TODO: review newly added indentation text
TODO: add page on front page between RPA and IDE, same Icon as IDE */}
46 changes: 23 additions & 23 deletions website/docs/getting_started/ide.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import {
</Section>

## Install IDE and Extensions
Several IDEs and Code Editors support the development of Robot Framework tests.
The support ranges from simple code-highlighting, code-completion to test execution and debugging.
Several IDEs and Code Editors support the development of Robot Framework tests.
The support ranges from simple code-highlighting, code-completion to test execution and debugging.
We list several IDEs and Extensions here, but there are many more.

### Visual Studio Code
Expand All @@ -39,9 +39,9 @@ It provides extensions for a lot of different languages and technologies.

![VS Code](/img/vscode_site.png)

Popular extensions for Robot Framework:
Popular extensions for Robot Framework:
- [Robot Code](https://robotcode.io)
- [Robot Framework Language Server](https://marketplace.visualstudio.com/items?itemName=robocorp.robotframework-lsp)
- [Robot Framework Language Server](https://marketplace.visualstudio.com/items?itemName=robocorp.robotframework-lsp)
- ⚠️ No longer maintained and does not work with Robot Framework 7+

#### Install Visual Studio Code
Expand All @@ -61,7 +61,7 @@ See the [VS Code setup guide](https://code.visualstudio.com/docs/setup/setup-ove

<TabItem value="Linux Snap" label="Linux Snap">

1. Open a terminal
1. Open a terminal
2. Execute `sudo snap install code --classic`
3. Start Visual Studio Code by executing `code`

Expand All @@ -70,7 +70,7 @@ See the [VS Code setup guide](https://code.visualstudio.com/docs/setup/setup-ove

1. Download the deb package from [Visual Studio Code](https://code.visualstudio.com/download)
2. Open a terminal
3. Type `sudo dpkg -i <path_to_deb_package>`
3. Type `sudo dpkg -i <path_to_deb_package>`
e.g. `sudo dpkg -i ~/Downloads/code_1.65.2-1646927742_amd64.deb`
4. Start Visual Studio Code by executing `code`

Expand All @@ -79,7 +79,7 @@ e.g. `sudo dpkg -i ~/Downloads/code_1.65.2-1646927742_amd64.deb`

1. Download the rpm package from [Visual Studio Code](https://code.visualstudio.com/download)
2. Open a terminal
3. Type `sudo rpm -i <path_to_rpm_package>`
3. Type `sudo rpm -i <path_to_rpm_package>`
e.g. `sudo rpm -i ~/Downloads/code-1.65.2-1646927812.el7.x86_64.rpm`
4. Start Visual Studio Code by executing `code`

Expand All @@ -90,7 +90,7 @@ e.g. `sudo rpm -i ~/Downloads/code-1.65.2-1646927812.el7.x86_64.rpm`
#### Visual Studio Code Extensions

:::tip Only install one Robot Framework Extension
Make sure that only a **single** Robot Framework extension is installed.
Make sure that only a **single** Robot Framework extension is installed.
We strongly recommend to only install [RobotCode](https://robotcode.io)
:::

Expand All @@ -112,9 +112,9 @@ Check out this extended Tutorial about Robot Code
</TabItem>
<TabItem value="Robot Framework Language Server" label="Robot Framework Language Server">

[Robot Framework Language Server](https://marketplace.visualstudio.com/items?itemName=robocorp.robotframework-lsp) is a Visual Studio Code extension for Robot Framework.
[Robot Framework Language Server](https://marketplace.visualstudio.com/items?itemName=robocorp.robotframework-lsp) is a Visual Studio Code extension for Robot Framework.

⚠️ No longer maintained and does not work with Robot Framework 7+
⚠️ No longer maintained and does not work with Robot Framework 7+

![Robot Framework Language Server](/img/rflsp.png)

Expand Down Expand Up @@ -150,7 +150,7 @@ Make sure to install the free `PyCharm Community Edition` and not the `PyCharm P
#### PyCharm extensions

:::tip Only install one Robot Framework Extension
Make sure that only a **single** Robot Framework extension is installed.
Make sure that only a **single** Robot Framework extension is installed.
:::

##### Robot Framework Language Server
Expand All @@ -159,22 +159,22 @@ Make sure that only a **single** Robot Framework extension is installed.
2. Select `Plugins`
3. Select the `Marketplace` tab
4. Search for `Robot Framework Language Server` and click on `Install`
5. Add a Debug Configuration for Robot Framework to run current test suite
![Debug Config Current Test Suite](/img/getting_started/pycharm_conf_current_suite.png)
5. Add a Debug Configuration for Robot Framework to run current test suite
![Debug Config Current Test Suite](/img/getting_started/pycharm_conf_current_suite.png)
6. Add a Debug Configuration for Robot Framework to run current test case (via selected text)
![Debug Config Current Test Case](/img/getting_started/pycharm_conf_selected_test.png)

<Tabs>
<TabItem value="Robot Framework Language Server" label="Robot Framework Language Server">

⚠️ No longer maintained and does not work with Robot Framework 7+
⚠️ No longer maintained and does not work with Robot Framework 7+

1. Press `Ctrl + Alt + S` to open the settings dialog
2. Select `Plugins`
3. Select the `Marketplace` tab
4. Search for `Robot Framework Language Server` and click on `Install`
5. Add a Debug Configuration for Robot Framework to run current test suite
![Debug Config Current Test Suite](/img/getting_started/pycharm_conf_current_suite.png)
5. Add a Debug Configuration for Robot Framework to run current test suite
![Debug Config Current Test Suite](/img/getting_started/pycharm_conf_current_suite.png)
6. Add a Debug Configuration for Robot Framework to run current test case (via selected text)
![Debug Config Current Test Case](/img/getting_started/pycharm_conf_selected_test.png)

Expand All @@ -191,28 +191,28 @@ Make sure that only a **single** Robot Framework extension is installed.

</Tabs>

## Run and Debug Robot Framework Tests
## Run and Debug Robot Framework Tests

### Visual Studio Code with RobotCode

#### Run
![Run Tests](/img/getting_started/VSC_RBTCD_running_tests.gif)

#### Debug
Add a breakpoint to your test suite or resource file, by clicking on the left-hand side of the line.
Add a breakpoint to your test suite or resource file, by clicking on the left-hand side of the line.
![Breakpoint](/img/VSC_AddBreakpoint.png)

Right-Click on the `Play` button
Right-Click on the `Play` button
![Play Button](/img/VSC_RBTCD_PlayBtn.png)

Select `Debug Test` from the context menu.
Test Execution will begin and stop at the breakpoint.
Select `Debug Test` from the context menu.
Test Execution will begin and stop at the breakpoint.
![Debug Test](/img/VSC_RBTCD_Debug.png)

Use `Debug Toolbar` to select actions like step over, step into, step out, continue, pause, etc.
Use `Debug Toolbar` to select actions like step over, step into, step out, continue, pause, etc.
![Debug Toolbar](/img/VSC_DebugToolbar.png)

Run Robot Frameworm commands while debugging from `Debug Console`.
Run Robot Framework commands while debugging from `Debug Console`.
![Debug Console](/img/VSC_RBTCD_executeDebugCommands.png)

### PyCharm with Robot Framework Language Server
Expand Down
14 changes: 7 additions & 7 deletions website/docs/getting_started/videos.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
---
sidebar_position: 4
sidebar_position: 5
sidebar_label: Videos
title: Videos and Tutorials
description: Videos and Tutorials
---

## Official Robot Framework Tutorial

The official Robot Framework tutorial video presented by the Robot Framework creator **Pekka Klärck**.
The official Robot Framework tutorial video presented by the Robot Framework creator **Pekka Klärck**.
New videos will be added to this playlist in the future.

[Official Robot Framework Tutorial](https://youtube.com/playlist?list=PLSK6YK5OGX1AuQy0tbvdKBV9mrKi46kKH)
Expand All @@ -20,23 +20,23 @@ New videos will be added to this playlist in the future.

This channel is dedicated to those who want to start automating with Robot Framework but also to those who are already using this tool and want to find out new tips and tricks they might have missed.

[Robot Framework Tutorials Channel](https://www.youtube.com/@RobotFrameworkTutorials)
[Robot Framework Tutorials Channel](https://www.youtube.com/@RobotFrameworkTutorials)

---

[Complete Robot Framework Tutorial](https://www.youtube.com/playlist?list=PL4GZKvvcjS3u9FP3F9zW4ZbZB8pti2k37)
[Complete Robot Framework Tutorial](https://www.youtube.com/playlist?list=PL4GZKvvcjS3u9FP3F9zW4ZbZB8pti2k37)

<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PL4GZKvvcjS3u9FP3F9zW4ZbZB8pti2k37" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen" allowfullscreen></iframe>

---

[Web Automation With Robot Framework](https://www.youtube.com/playlist?list=PL4GZKvvcjS3sRKidOUNVQSR3aq7TEQglp)
[Web Automation With Robot Framework](https://www.youtube.com/playlist?list=PL4GZKvvcjS3sRKidOUNVQSR3aq7TEQglp)

<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PL4GZKvvcjS3sRKidOUNVQSR3aq7TEQglp" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen" allowfullscreen></iframe>

---

[Mobile Automation With Robot Framework And Appium](https://www.youtube.com/playlist?list=PL4GZKvvcjS3vAPWLqWbKZogkL5cD71yrT)
[Mobile Automation With Robot Framework And Appium](https://www.youtube.com/playlist?list=PL4GZKvvcjS3vAPWLqWbKZogkL5cD71yrT)

<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list=PL4GZKvvcjS3vAPWLqWbKZogkL5cD71yrT" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen" allowfullscreen></iframe>

Expand All @@ -46,6 +46,6 @@ This channel is dedicated to those who want to start automating with Robot Frame

Test Automation University is a free, online learning platform for software testers and developers. It is a community-driven project that is supported by the community. The goal of Test Automation University is to provide free, high-quality, and up-to-date training for software testers and developers.

[Introduction To Robot Framework](https://testautomationu.applitools.com/robot-framework-tutorial/)
[Introduction To Robot Framework](https://testautomationu.applitools.com/robot-framework-tutorial/)

<iframe width="560" height="315" src="https://www.youtube.com/embed/Kve1luX1rOQ" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; fullscreen" allowfullscreen></iframe>
6 changes: 6 additions & 0 deletions website/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ If you have any questions, please reach out to our awesome community on [Slack](
description="Install and set up your IDE for coding and debugging"
to="/docs/getting_started/ide"
/>
<Card
title="Your First Code"
icon={<Code2Icon/>}
description="How To Write Robot Framework Code"
to="/docs/getting_started/how_to_write_rf"
/>
<Card
title="Videos"
icon={<VideoIcon/>}
Expand Down
Loading