### Initialize a New Project with Poetry Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Start a new project and let Poetry guide you through creating the pyproject.toml configuration file. ```shell poetry init ``` -------------------------------- ### Example Usage: Start PabotLib and Run in Parallel Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx Start a new PabotLib remote server on a specified host and port, then run tests in parallel using 10 processes. ```bash pabot --pabotlib --pabotlibhost 192.168.1.111 --pabotlibport 8272 --processes 10 tests ``` -------------------------------- ### Start PabotLib Server with Custom Host and Port Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx Example of starting a PabotLib remote server on a specific host and port for sharing resources. ```bash python -m pabot.pabotlib resource.txt 192.168.1.123 8271 ``` -------------------------------- ### Dockerfile for Basic Robot Framework Setup Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/docker.md A simple Dockerfile to create an image with Python and Robot Framework installed. Use this as a base for custom Robot Framework environments. ```Dockerfile FROM python:3 RUN pip install robotframework ``` -------------------------------- ### Poetry Project Initialization Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx An example of the prompts and expected input during 'poetry init' for project configuration. ```shell This command will guide you through creating your pyproject.toml config. Package name [your-project-name]: Version [0.1.0]: Description []: Author [Your Name , n to skip]: License []: Compatible Python versions [^3.10]: Would you like to define your main dependencies interactively? (yes/no) [yes] no Would you like to define your development dependencies interactively? (yes/no) [yes] no ``` -------------------------------- ### Install and Initialize Browser Library Source: https://context7.com/marketsquare/robotframeworkguides/llms.txt Installs the Browser Library and its dependencies, including Playwright browsers. ```bash pip install robotframework-browser rfbrowser init # installs Playwright (Chromium, Firefox, WebKit) ``` -------------------------------- ### Initialize Browser Library without Browser Installation Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/ci/jenkins.md Run `rfbrowser init` with the `--skip-browsers` flag to perform the initial setup of the Browser library without downloading browser binaries. This is useful when the Jenkins agent cannot directly download them due to firewall restrictions. ```bash rfbrowser init --skip-browsers ``` -------------------------------- ### Install Database Library Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/database.md Install the Robot Framework Database Library using pip. This command installs the library and its dependencies. ```bash pip install robotframework-databaselibrary ``` -------------------------------- ### Start Local Development Server Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/README.md Starts a local development server for live preview. Changes are reflected without a server restart. ```bash yarn start ``` -------------------------------- ### Install Robot Framework with pip Source: https://context7.com/marketsquare/robotframeworkguides/llms.txt Installs Robot Framework globally using pip and verifies the installation. Recommended to use a virtual environment for project isolation. ```bash pip install robotframework robot --version # Output: Robot Framework 5.x.y (Python 3.x.y) ``` -------------------------------- ### Check Node.js and npm Versions Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/browser.md Verify your Node.js and npm installations by checking their versions. Ensure you have compatible versions installed before proceeding with the library setup. ```shell $ node --version v18.12.0 $ npm --version 8.19.2 ``` -------------------------------- ### Install Robot Framework in a virtual environment Source: https://context7.com/marketsquare/robotframeworkguides/llms.txt Sets up a virtual environment and installs Robot Framework within it. This is the recommended approach for managing project dependencies. ```bash mkdir MyProject && cd MyProject python -m venv .venv source .venv/bin/activate # Linux/macOS # .venv\Scripts\activate.bat # Windows cmd pip install robotframework robot --version ``` -------------------------------- ### Install Python and Pip on Linux Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Update package lists and install Python 3 and pip using apt. ```bash sudo apt update sudo apt install python3 python3-pip python3 -V ``` -------------------------------- ### Install Dependencies Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/README.md Installs project dependencies using Yarn. Run this command after cloning the repository. ```bash yarn ``` -------------------------------- ### Example Usage: Parallel Execution with 10 Processes Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx An example of running tests in parallel using exactly 10 processes. ```bash pabot --processes 10 tests ``` -------------------------------- ### Example Usage: Basic Parallel Execution Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx A simple example demonstrating how to run tests in parallel using Pabot. ```bash pabot test_directory ``` -------------------------------- ### Install Robot Framework with Poetry Source: https://context7.com/marketsquare/robotframeworkguides/llms.txt Initializes a new project with Poetry, adds Robot Framework and related libraries, and runs Robot Framework commands using Poetry. ```bash poetry init poetry add robotframework robotframework-browser robotframework-requests poetry run robot --version poetry run rfbrowser init # install Playwright browsers ``` -------------------------------- ### Install Robot Framework in a Virtual Environment (Windows) Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Sets up a project-specific virtual environment on Windows using Python's venv module, installs Robot Framework, and activates the environment. ```cmd cd C:\projects mkdir MyProject cd MyProject python -m venv .venv .venv\Scripts\activate.bat pip install robotframework robot --version ``` -------------------------------- ### Install Robot Framework in a Virtual Environment (Linux) Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Sets up a project-specific virtual environment on Linux using Python's venv module, installs Robot Framework, and activates the environment. ```bash cd ~/projects mkdir MyProject cd MyProject python -m venv .venv source .venv/bin/activate pip install robotframework robot --version ``` -------------------------------- ### Robot Framework Example for Restful Booker Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/examples/restfulbooker.mdx This snippet demonstrates how to use Robot Framework to make requests to the Restful Booker API. It includes setup for the API URL and common operations. ```robotframework *** Settings *** Library RequestsLibrary *** Variables *** ${API_URL} https://restful-booker.herokuapp.com *** Test Cases *** Create Booking ${response} = Create ${API_URL}/booking json ${booking_data} Log ${response.json()} Should Be Equal ${response.status_code} 200 Get Booking ${booking_id} = Set Variable 1 ${response} = GET ${API_URL}/booking/${booking_id} Log ${response.json()} Should Be Equal ${response.status_code} 200 Update Booking ${booking_id} = Set Variable 1 ${response} = PUT ${API_URL}/booking/${booking_id} json ${updated_booking_data} Log ${response.json()} Should Be Equal ${response.status_code} 200 Delete Booking ${booking_id} = Set Variable 1 ${response} = DELETE ${API_URL}/booking/${booking_id} Log ${response.status_code} Should Be Equal ${response.status_code} 201 *** Keywords *** Create [Arguments] ${url} ${data} Create Session my_session ${url} ${response} = POST On Session my_session /booking json=${data} [Return] ${response} GET [Arguments] ${url} Create Session my_session ${url} ${response} = GET On Session my_session /booking/${booking_id} [Return] ${response} PUT [Arguments] ${url} ${data} Create Session my_session ${url} ${response} = PUT On Session my_session /booking/${booking_id} json=${data} [Return] ${response} DELETE [Arguments] ${url} Create Session my_session ${url} ${response} = DELETE On Session my_session /booking/${booking_id} [Return] ${response} ${booking_data} = Create Dictionary firstname=John lastname=Doe totalprice=111 depositpaid=true bookingdates={"checkin": "2024-01-01", "checkout": "2024-01-05"} additionalneeds=Breakfast ${updated_booking_data} = Create Dictionary firstname=Jane lastname=Doe totalprice=222 depositpaid=true bookingdates={"checkin": "2024-01-01", "checkout": "2024-01-05"} additionalneeds=Lunch ``` -------------------------------- ### Basic Database Connection and Query Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/database.md Demonstrates connecting to an Oracle database and executing SQL queries. Ensure the database connection details are correct. ```robotframework *** Settings *** Library DatabaseLibrary Test Setup Connect To My Oracle DB *** Keywords *** Connect To My Oracle DB Connect To Database ... oracledb ... db_name=db ... db_user=my_user ... db_password=my_pass ... db_host=127.0.0.1 ... db_port=1521 *** Test Cases *** Get All Names ${Rows}= Query select FIRST_NAME, LAST_NAME from person Should Be Equal ${Rows}[0][0] Franz Allan Should Be Equal ${Rows}[0][1] See Should Be Equal ${Rows}[1][0] Jerry Should Be Equal ${Rows}[1][1] Schneider Person Table Contains Expected Records ${sql}= Catenate select LAST_NAME from person Check Query Result ${sql} contains See Check Query Result ${sql} equals Schneider row=1 Wait Until Table Gets New Record ${sql}= Catenate select LAST_NAME from person Check Row Count ${sql} > 2 retry_timeout=5s Person Table Contains No Joe ${sql}= Catenate SELECT id FROM person ... WHERE FIRST_NAME= 'Joe' Check Row Count ${sql} == 0 ``` -------------------------------- ### Simple Project Test Suite Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/examples/project_structure.mdx An example of a Robot Framework test suite file within a simple project structure. It demonstrates how to import resources and libraries from the 'resources/' directory. ```robotframework *** Settings *** Resource resources/common.resource Resource resources/some_other.resource Library resources/custom_library.py Variables resources/variables.py ... ``` -------------------------------- ### Check Poetry Installation Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Verify that Poetry has been installed correctly by checking its version. ```shell poetry --version ``` -------------------------------- ### Project Structure Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/examples/project_structure.mdx Illustrates a recommended project structure with separate folders for tests and resources. This organization facilitates the use of the `--pythonpath` argument. ```text my_project ├── tests │ └── suiteA.robot └── resources ├── general.resource └── auth/ ├── login.resource └── totp.py ``` -------------------------------- ### Install Robot Framework Dashboard Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/reporting_test_results/robot_framework_dashboard.md Install the Robot Framework Dashboard using pip. Use the `[server]` or `[all]` extra for server or all features respectively. ```bash pip install robotframework-dashboard # for server/listener features pip install robotframework-dashboard[server] # or pip install robotframework-dashboard[all] ``` -------------------------------- ### Listener Implementation: Class Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/extending_robot_framework/listeners_prerun_api/listeners.md This example shows how to implement a listener using a class structure. Ensure the class name matches the file name for clarity. ```python Class ListenerClass: ROBOT_LISTENER_API_VERSION = 3 def __init__(self): pass def start_suite(self, data, result): pass ``` -------------------------------- ### Install Robot Framework Language Server in PyCharm Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/ide.mdx Follow these steps to install the Robot Framework Language Server extension in PyCharm. Ensure only one Robot Framework extension is installed at a time. ```text 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 6. Add a Debug Configuration for Robot Framework to run current test case (via selected text) ``` -------------------------------- ### Robot Framework Example with AppiumLibrary Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/appium.md This example demonstrates how to use AppiumLibrary to open a mobile application, interact with UI elements like search boxes, and verify text content. It requires Appium server to be running and a configured mobile environment. ```robotframework *** Settings *** Documentation Simple example using AppiumLibrary Library AppiumLibrary *** Variables *** ${ANDROID_AUTOMATION_NAME} UIAutomator2 ${ANDROID_APP} ${CURDIR}/demoapp/ApiDemos-debug.apk ${ANDROID_PLATFORM_NAME} Android ${ANDROID_PLATFORM_VERSION} %{ANDROID_PLATFORM_VERSION=11} *** Test Cases *** Should send keys to search box and then check the value Open Test Application Input Search Query Hello World! Submit Search Search Query Should Be Matching Hello World! *** Keywords *** Open Test Application Open Application http://127.0.0.1:4723/wd/hub automationName=${ANDROID_AUTOMATION_NAME} ... platformName=${ANDROID_PLATFORM_NAME} platformVersion=${ANDROID_PLATFORM_VERSION} ... app=${ANDROID_APP} appPackage=io.appium.android.apis appActivity=.app.SearchInvoke Input Search Query [Arguments] ${query} Input Text txt_query_prefill ${query} Submit Search Click Element btn_start_search Search Query Should Be Matching [Arguments] ${text} Wait Until Page Contains Element android:id/search_src_text Element Text Should Be android:id/search_src_text ${text} ``` -------------------------------- ### BuiltIn Library Examples Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/standard.mdx Examples showcasing the functionality of the BuiltIn library, which is available by default in Robot Framework. ```robotframework iframe src="https://robotframework.org/embed/?code-gh-url=https://github.com/MarketSquare/robotframeworkguides/tree/main/code-examples/standard_library/builtin" width="100%" height="600" ``` -------------------------------- ### Robot Framework Control Structures Examples Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/standard.mdx Examples demonstrating Robot Framework's control structures like IF, FOR, and WHILE loops. ```robotframework iframe src="https://robotframework.org/embed/?code-gh-url=https://github.com/MarketSquare/robotframeworkguides/tree/main/code-examples/standard_library/control_structures" width="100%" height="600" ``` -------------------------------- ### Install Requests Library Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/requests.md Install the stable version of the Requests Library using pip. ```sh pip install robotframework-requests ``` -------------------------------- ### DateTime Library Examples Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/standard.mdx Examples illustrating the capabilities of the DateTime library for handling dates and times. ```robotframework iframe src="https://robotframework.org/embed/?code-gh-url=https://github.com/MarketSquare/robotframeworkguides/tree/main/code-examples/standard_library/datetime" width="100%" height="600" ``` -------------------------------- ### Install Visual Studio Code on Linux (Snap) Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/ide.mdx Use this command to install Visual Studio Code on Linux via Snap. This method is quick and ensures you have the latest version. ```bash sudo snap install code --classic ``` -------------------------------- ### Install Hyper RobotFramework Support in PyCharm Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/ide.mdx Follow these steps to install the Hyper RobotFramework Support extension in PyCharm. Ensure only one Robot Framework extension is installed at a time. ```text 1. Press `Ctrl + Alt + S` to open the settings dialog 2. Select `Plugins` 3. Select the `Marketplace` tab 4. Search for `Hyper RobotFramework Support` and click on `Install` ``` -------------------------------- ### XML Library Examples Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/standard.mdx Examples showcasing the XML library for parsing and manipulating XML data. ```robotframework iframe src="https://robotframework.org/embed/?code-gh-url=https://github.com/MarketSquare/robotframeworkguides/tree/main/code-examples/standard_library/xml" width="100%" height="600" ``` -------------------------------- ### Executing Robot Framework Tests Source: https://context7.com/marketsquare/robotframeworkguides/llms.txt Command-line examples for running Robot Framework tests from the project root, including specifying an output directory and configuring the Python path. ```bash # Run all tests from project root robot --pythonpath . tests/ ``` ```bash # Run with output directory robot --pythonpath . --outputdir results tests/ ``` ```json # VS Code settings.json (with RobotCode extension) # "robotcode.robot.pythonPath": ["./", "./resources", "./libraries"] ``` -------------------------------- ### Install SeleniumLibrary Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/selenium.md Install or upgrade the SeleniumLibrary using pip. This is a prerequisite for using the library in Robot Framework. ```shell pip install --upgrade robotframework-seleniumlibrary ``` -------------------------------- ### Robot Framework Command Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/ci/gitlab.md A bash command to execute Robot Framework tests, specifying the output directory for reports. ```bash robot --outputdir reports tests/smoke ``` -------------------------------- ### Install Homebrew on macOS Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Install Homebrew, a package manager for macOS, using a curl script. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Install Robot Framework in a Virtual Environment (MacOS) Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Sets up a project-specific virtual environment on MacOS using Python's venv module, installs Robot Framework, and activates the environment. Includes pyenv version management. ```bash cd ~/projects mkdir MyProject cd MyProject pyenv global 3.10.6 pyenv local 3.10.6 python -m venv .venv source .venv/bin/activate pip install robotframework robot --version ``` -------------------------------- ### Example Usage: Collect Artifacts from Subfolders Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx Run tests and collect specified artifacts (png, mp4, txt) from both the output directory and its subfolders. ```bash pabot --artifacts png,mp4,txt --artifactsinsubfolders directory_to_tests ``` -------------------------------- ### Collections Library Examples Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/standard.mdx Examples demonstrating the usage of the Collections library for manipulating lists and dictionaries. ```robotframework iframe src="https://robotframework.org/embed/?code-gh-url=https://github.com/MarketSquare/robotframeworkguides/tree/main/code-examples/standard_library/collections" width="100%" height="600" ``` -------------------------------- ### Install Robot Framework Globally Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Installs Robot Framework globally using pip. This method is simple but not recommended for multi-project development. ```cmd pip install robotframework robot --version ``` -------------------------------- ### Example Usage: Custom Command with Include Filter Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx Demonstrates running tests using a custom command, including tests with the 'SMOKE' tag. ```bash pabot --command java -jar robotframework.jar --end-command --include SMOKE tests ``` -------------------------------- ### Install Python 3.10.6 using pyenv Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Install a specific Python version (3.10.6) using pyenv. ```bash pyenv install 3.10.6 ``` -------------------------------- ### BDD Example Scenario Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/testcase_styles/bdd.mdx Illustrates a simple user story using the Given-When-Then format. This syntax helps describe system behavior clearly. ```robotframework Given a user is on the login page When the user enters their username and password and clicks the login button Then the user should be directed to the home page. ``` -------------------------------- ### Importing Standard Libraries in Robot Framework Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/standard.mdx Demonstrates how to import various libraries from the Robot Framework Standard Library. Ensure these libraries are installed with your Robot Framework distribution. ```robotframework *** Settings *** Library Collections Library OperatingSystem Library Process Library String Library Telnet Library XML ``` -------------------------------- ### Install Dependencies and Run Robot Framework Tests Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/ci/gitlab.md A multi-command script for a CI job. It first installs dependencies from `requirements.txt`, creates a `reports` directory, and then runs Robot Framework tests. ```yaml script: - pip install -r requirements.txt - mkdir reports - robot --outputdir reports tests/smoke ``` -------------------------------- ### Start PabotLib Remote Server Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx Enable locking and resource distribution between parallel test executions by starting the PabotLib remote server with the --pabotlib option. ```bash --pabotlib ``` -------------------------------- ### Listener Implementation: Module Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/extending_robot_framework/listeners_prerun_api/listeners.md This example demonstrates implementing a listener as a standalone Python module. The functions directly correspond to the listener events. ```python def start_suite(data, result): pass ``` -------------------------------- ### Example Usage: Exclude Tags and Run Tests Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx An example showing how to exclude tests with a specific tag ('FOO') while running tests from a directory. ```bash pabot --exclude FOO directory_to_tests ``` -------------------------------- ### Example Usage: PabotLib with Specific Host and Port Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx Connect to an existing PabotLib remote server running on a specific IP address and port, and execute tests with 10 parallel processes. ```bash pabot --pabotlibhost 192.168.1.123 --pabotlibport 8271 --processes 10 tests ``` -------------------------------- ### Importing Resources and Variables in Robot Framework Source: https://context7.com/marketsquare/robotframeworkguides/llms.txt Example of a Robot Framework test file demonstrating how to import a common resource file and variables from a Python file. ```robotframework # tests/authentication/login.robot *** Settings *** Resource resources/common.resource Variables data/master-data/customers.py ``` -------------------------------- ### Install Robot Framework Browser and Dependencies Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/browser.md Install the robotframework-browser package using pip and then initialize the necessary Playwright browser binaries and dependencies using the rfbrowser init command. This step is crucial for the library to function correctly. ```shell $ pip install robotframework-browser $ rfbrowser init Installing playwright... Installing playwright-chromium... Installing playwright-firefox... Installing playwright-webkit... Done! ``` -------------------------------- ### Install Pabot Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx Install Pabot using pip. This command ensures you have the latest version for parallel test execution. ```bash pip install -U robotframework-pabot ``` -------------------------------- ### Robot Framework Library Grouping in Settings Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/style_guide.md Example of grouping libraries in the Settings section for better organization. ```robotframework *** Settings *** ... Library BuiltIn Library Collections Library DateTime Library OperatingSystem Library Browser Library JSONLibrary Library SSHLibrary Library Acustom Library Bcustom Library Ccustom Library Dcustom ... ``` -------------------------------- ### Install Visual Studio Code on Linux (Rpm) Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/ide.mdx Install Visual Studio Code on RPM-based Linux distributions using a .rpm package. Replace `` with the actual path to the downloaded file. ```bash sudo rpm -i e.g. sudo rpm -i ~/Downloads/code-1.65.2-1646927812.el7.x86_64.rpm ``` -------------------------------- ### Install DataDriver Library Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/testcase_styles/datadriven.mdx Install the DataDriver library using pip. This library extends Robot Framework's capabilities for data-driven testing with external data sources. ```bash pip install robotframework-datadriver ``` -------------------------------- ### Variable Scope and Casing Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/style_guide.md Demonstrates how Robot Framework handles variable casing and scope, showing that casing is ignored and how arguments and local variables can override suite variables. ```robotframework *** Variables *** ${I AM A VARIABLE} This is a SUITE scoped variables *** Test Cases *** Variable Casing Test [Documentation] Robot Framework ignores casing. Log To Console ${I AM A VARIABLE} Should Be Equal ${I AM A VARIABLE} ${i am a variable} Same Variable Different Scope Test [Documentation] The SUITE variable is overwritten by an argument then TEST scoped variable of same name. A Keyword With Arguments This will be printed. Should Not Be Equal ${I AM A VARIABLE} This is a SUITE scoped variables *** Keywords *** A Keyword With Arguments [Documentation] The argument will take precedence then the SUITE level variable will be overwritten by a TEST scope variable. [Arguments] ${i am a variable} Log To Console ${i am a variable} Set Test Variable ${i am a variable} ``` -------------------------------- ### Complex Project Test Suite Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/examples/project_structure.mdx An example of a Robot Framework test suite file within a complex project structure. It shows how to import resources and variables from various subfolders within 'resources/' and 'data/'. ```robotframework *** Settings *** Resource resources/common.resource Resource resources/search.resource Resource resources/master-data/customers.resource Variables data/master-data/customers.py ... ``` -------------------------------- ### Example GitLab CI Pipeline Configuration Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/ci/gitlab.md This is a complete example of a `.gitlab-ci.yml` file that defines stages, specifies a Docker image, and configures jobs to run Robot Framework smoke and regression tests. It also defines artifacts to store test reports. ```yaml stages: - smoke - regression image: marketsquare/robotframework-browser run-smoke-tests: stage: smoke script: - robot --outputdir reports tests/smoke artifacts: paths: - reports run-regression-tests: stage: regression script: - robot --outputdir reports tests/regression artifacts: paths: - reports ``` -------------------------------- ### Dockerfile for Robot Framework and Browser Library Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/docker.md This Dockerfile sets up an environment with Robot Framework and the Browser Library. It installs Python, pip, and the necessary Robot Framework packages, then initializes the Browser Library. ```Dockerfile FROM mcr.microsoft.com/playwright:focal USER root RUN apt-get update RUN apt-get install -y python3-pip USER pwuser RUN pip3 install --user robotframework RUN pip3 install --user robotframework-browser RUN ~/.local/bin/rfbrowser init ENV NODE_PATH=/usr/lib/node_modules ENV PATH="/home/pwuser/.local/bin:${PATH}" ``` -------------------------------- ### Importing a Library in Settings Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/how_to_write_rf.mdx Import the 'String' library in the Settings section to access its keywords. This is a common setup for test suites. ```robotframework *** Settings *** Library String ``` -------------------------------- ### Attach Listeners at Runtime Source: https://context7.com/marketsquare/robotframeworkguides/llms.txt Command-line examples for attaching one or multiple listeners to a Robot Framework execution. Listeners can be specified with default or custom configuration files. ```bash # Attach one or multiple listeners at runtime robot --listener ReportListener.py tests/ robot --listener StopOnFailureListener.py tests/ robot --listener ReportListener.py:custom_report.md tests/ ``` -------------------------------- ### Install Visual Studio Code on Linux (Deb) Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/ide.mdx Install Visual Studio Code on Debian-based Linux distributions using a .deb package. Ensure you replace `` with the actual path to the downloaded file. ```bash sudo dpkg -i e.g. sudo dpkg -i ~/Downloads/code_1.65.2-1646927742_amd64.deb ``` -------------------------------- ### Robot Framework Test Suite A with Setup/Teardown Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/parallel.mdx Defines test cases and suite/test level setup and teardown for Suite A. Demonstrates how these are handled during parallel execution. ```robotframework *** Settings *** Test Suite Setup Log Suite A Setup Test Suite Teardown Log Suite A Teardown Test Setup Log Test Setup Test Teardown Log Test Teardown *** Test Cases *** Test Case 1 Log Test Case 1 Sleep 10s Test Case 2 Log Test Case 2 Sleep 10s Test Case 3 Log Test Case 3 Sleep 10s ``` -------------------------------- ### Execute Robot Framework with SelectEveryXthTest Modifier Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/extending_robot_framework/listeners_prerun_api/prerunmodifier.md Command to run Robot Framework using the SelectEveryXthTest pre-run modifier. This example selects every third test, starting from the first test (index 0). ```bash robot --prerunmodifier SelectEveryXthTest:3:0 tests ``` -------------------------------- ### Install Poetry on Windows Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Use this command in PowerShell to install Poetry on Windows. Replace 'py' with 'python' if you installed Python from the Microsoft Store. ```powershell (Invoke-WebRequest -Uri https://install.python-poetry.org -UseBasicParsing).Content | py - ``` -------------------------------- ### Distribute Tests Using SelectEveryXthTest Source: https://context7.com/marketsquare/robotframeworkguides/llms.txt Command-line examples demonstrating how to use the `SelectEveryXthTest` PreRunModifier to distribute tests across multiple runners. Each runner receives a specific subset of tests. ```bash # Distribute tests across 3 runners — each runner gets 1/3 of tests robot --prerunmodifier SelectEveryXthTest:3:0 tests/ # Runner 1 robot --prerunmodifier SelectEveryXthTest:3:1 tests/ # Runner 2 robot --prerunmodifier SelectEveryXthTest:3:2 tests/ # Runner 3 ``` -------------------------------- ### Listener v3 Example: End Test Failure Notification Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/extending_robot_framework/listeners_prerun_api/listeners.md This example demonstrates a v3 listener that achieves similar functionality to the v2 example, printing a message and pausing on test failure. ```python ROBOT_LISTENER_API_VERSION = 3 def end_test(data, result): if not result.passed: print('Test "%s" failed: %s' % (result.name, result.message)) input('Press enter to continue.') ``` -------------------------------- ### Execute Robot Framework Tests Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/ci/gitlab.md Specifies the commands to run Robot Framework tests. This example executes tests in the `tests/smoke` directory and outputs results to the `reports` folder. ```yaml script: - robot --outputdir reports tests/smoke ``` -------------------------------- ### Install Robot Code Extension for VS Code Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/ide.mdx Follow these steps to install the RobotCode extension in Visual Studio Code for enhanced Robot Framework development. Ensure you only have one Robot Framework extension installed. ```bash Ctrl + Shift + X ``` -------------------------------- ### Install Playwright Dependencies Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Use 'poetry run' to install necessary Playwright dependencies for robotframework-browser. ```shell poetry run rfbrowser init ``` -------------------------------- ### Deploy Website (SSH) Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/README.md Builds the website and deploys it using SSH. Assumes SSH is configured for deployment. ```bash USE_SSH=true yarn deploy ``` -------------------------------- ### Simple Project Structure Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/examples/project_structure.mdx This is a basic project structure for a simple Robot Framework project. It includes a 'tests/' folder for test suites, a 'resources/' folder for common keywords and variables, and root-level configuration files. ```text my_project ├── tests │ ├── suiteA.robot │ ├── suiteB.robot │ ├── ... │ ├── resources │ ├── common.resource │ ├── some_other.resource │ ├── custom_library.py │ ├── variables.py │ ├── ... │ ├── .gitlab-ci.yml ├── .gitignore ├── README.md ├── requirements.txt ``` -------------------------------- ### Install RetryFailed Listener Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/flaky_tests.md Install the RetryFailed listener using pip for automatic test retries. ```shell pip install robotframework-retryfailed ``` -------------------------------- ### Install pyenv on macOS Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Install pyenv, a tool for managing multiple Python versions, using Homebrew. ```bash brew install pyenv ``` -------------------------------- ### Basic GET Request Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/requests.md Perform a simple GET request to a URL. The response is stored in a variable for further assertions. ```robotframework *** Settings *** Library RequestsLibrary *** Test Cases *** Quick Get Request Test ${response}= GET https://www.google.com ``` -------------------------------- ### Basic Browser Library Usage for ToDo App Source: https://context7.com/marketsquare/robotframeworkguides/llms.txt Demonstrates basic web interactions like navigating, filling forms, and verifying text using Browser Library. ```robotframework *** Settings *** Library Browser Library String Suite Setup New Browser browser=chromium headless=False Test Setup New Context viewport={'width': 1920, 'height': 1080} Test Teardown Close Context Suite Teardown Close Browser *** Variables *** ${BROWSER} chromium *** Test Cases *** Add ToDos And Verify Count [Tags] Add ToDo New Page https://todomvc.com/examples/react/dist/ Fill Text .new-todo Learn Robot Framework Press Keys .new-todo Enter Fill Text .new-todo Write Test Cases Press Keys .new-todo Enter Get Text span.todo-count == 2 items left! Mark ToDo As Complete New Page https://todomvc.com/examples/react/dist/ Fill Text .new-todo Learn Robot Framework Press Keys .new-todo Enter Click "Learn Robot Framework" >> .. >> input.toggle Get Text span.todo-count == 0 items left! Add 100 ToDos With FOR Loop New Page https://todomvc.com/examples/react/dist/ FOR ${index} IN RANGE 100 Fill Text .new-todo My ToDo Number ${index} Press Keys .new-todo Enter END Get Text span.todo-count == 100 items left! ``` -------------------------------- ### Install Python Build Dependencies on macOS Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Install necessary build dependencies for compiling Python versions using Homebrew. ```bash xcode-select --install brew install openssl readline sqlite3 xz zlib tcl-tk ``` -------------------------------- ### Jenkinsfile with Parameters and Multiple Stages for Robot Framework Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/ci/jenkins.md This Jenkinsfile demonstrates how to use parameters for test environment, tags, and folders, and defines multiple stages for checkout, argument definition, and test execution. It also shows how to use the `robot` Jenkins step for publishing results, distinguishing it from the `robot` command run within a `sh` step. ```groovy pipeline { properties([ parameters([ choice(choices: ['test','staging'], description: 'Environment to run the tests against', name: 'environment'), string(name: 'INCLUDE', defaultValue: 'valid_loginORinvalid_login', description: 'Specify which tags you want to run (e.g. valid_login)'), string(name: 'EXCLUDE', description: 'Specify if you want to exclude tests by category tags'), string(name: 'FOLDER', defaultValue: 'tests', description: 'Specify the folder for tests (e.g. . for current dir'), string(name: 'BRANCH', defaultValue: 'main', description: 'Specify the branch for tests (e.g. main') ]) ]) // -- Script arguments -------------------------------- def include = "${params.INCLUDE}" def exclude = "${params.EXCLUDE}" def folder = "${params.FOLDER}" def branch = "${params.BRANCH}" def args = "" // ---------------------------------------------------- agent { label 'robot' } // how is your Jenkins agent labeled, so that right kind of agent is used for execution stages { stage('Checkout') { steps { script { // checkout your code here } } } stage('Define args') { steps { script { if (!include.isEmpty()) { args += " -i $include" } if (!exclude.isEmpty()) { args += " -e $exclude" } if (!folder.isEmpty()) { args += " $folder" } else { args += " ." } } } } stage('Run Robot tests') { steps { sh """ robot -d test_results ${args} # etc. """ } post { always { // Note! Careful not to mix the Jenkins `robot` step with the `robot` command run inside the previous // `sh` step! The `robot` step _only_ publishes the results for Jenkins and the `robot` command // inside `sh` step runs the tests! robot( outputPath : 'test_results', outputFileName : "output.xml", reportFileName : 'report.html', logFileName : 'log.html', disableArchiveOutput: false, passThreshold : 95.0, unstableThreshold : 95.0, otherFiles : "**/*.png", ) } } } // Other stages... } } ``` -------------------------------- ### Install PyYAML for YAML Variable Files Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/variables.mdx Installs the necessary package for using YAML files as variable files in Robot Framework. ```shell pip install pyyaml ``` -------------------------------- ### Install Poetry on Linux/macOS Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Run this command in your terminal to install Poetry on Linux or macOS. Use 'python3' to ensure compatibility with Python 3. ```bash curl -sSL https://install.python-poetry.org | python3 - ``` -------------------------------- ### Run a Docker Container and Expose a Port Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/playground.md This command downloads the 'docker/getting-started:pwd' image and runs it in detached mode, exposing port 80. Use this to quickly test a Docker image. ```bash docker run -d -p 80:80 docker/getting-started:pwd ``` -------------------------------- ### Robot Framework Test Suite Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/playground.md A simple Robot Framework test suite using the Browser library to navigate to a page, assert text, and take a screenshot. Save this content in a .robot file. ```robotframework *** Settings *** Library Browser *** Test Cases *** Example Test New Page https://playwright.dev Get Text h1 contains Playwright Take Screenshot ``` -------------------------------- ### Run Robot Framework Tests with ppodgorsek/robot-framework Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/using_rf_in_ci_systems/docker.md This command runs Robot Framework tests using the `ppodgorsek/robot-framework` Docker image. It mounts local directories for tests and reports, and requires specifying the image version. ```bash docker run \ -v :/opt/robotframework/reports:Z \ -v :/opt/robotframework/tests:Z \ ppodgorsek/robot-framework: ``` -------------------------------- ### Running Robot Framework with a Listener Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/extending_robot_framework/listeners_prerun_api/listeners.md This command shows how to execute a Robot Framework test suite while enabling a specific listener file. ```bash robot --listener path/to/listener.py tests ``` -------------------------------- ### Complex Project Structure Example Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/examples/project_structure.mdx This illustrates a more complex project structure for larger Robot Framework projects. It features subfolders within 'tests/' and 'resources/', and introduces a 'data/' folder for test data files. ```text my_project ├── tests │ ├── authentication │ │ ├── login.robot │ │ ├── ... │ │ │ ├── master-data │ │ ├── customers.robot │ │ ├── products.robot │ │ ├── ... │ │ │ ├── order │ │ ├── order_creation.robot │ │ ├── order_processing.robot │ │ ├── ... │ ├── resources │ ├── common.resource │ ├── search.resource │ ├── master-data │ │ ├── customers.resource │ │ ├── products.resource │ │ ├── ... │ │ │ ├── ... │ ├── data │ ├── master-data │ │ ├── customers.py │ │ ├── products.py │ │ ├── ... │ │ │ ├── order │ │ ├── order_creation.yaml │ │ ├── order_processing.yaml │ │ ├── ... │ ├── .gitlab-ci.yml ├── .gitignore ├── README.md ├── requirements.txt ``` -------------------------------- ### Listener v2 Example: End Test Failure Notification Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/extending_robot_framework/listeners_prerun_api/listeners.md This example shows how to implement a v2 listener that prints a message and pauses execution when a test fails. ```python ROBOT_LISTENER_API_VERSION = 2 def end_test(name, attrs): if attrs['status'] == 'FAIL': print('Test "%s" failed: %s' % (name, attrs['message'])) input('Press enter to continue.') ``` -------------------------------- ### GET Request with Parameters Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/requests.md Execute a GET request with query parameters. The 'params' argument takes a string of key-value pairs. An expected status code can also be specified. ```robotframework Quick Get Request With Parameters Test ${response}= GET https://www.google.com/search params=query=ciao expected_status=200 ``` -------------------------------- ### Importing Resources and Libraries Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/examples/project_structure.mdx Shows how to import resource files and libraries using relative paths from the project root when `--pythonpath` is configured. This is the recommended approach for maintainability. ```robotframework *** Settings *** Resource resources/general.resource Resource resources/auth/login.resource Library resources/auth/totp.py ... ``` -------------------------------- ### Importing Resources with `--pythonpath` Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/examples/project_structure.mdx Demonstrates how to import resource files directly by name when their containing folders are added to the `--pythonpath` setting. This simplifies import statements. ```robotframework *** Settings *** Resource general.resource Resource auth/login.resource Library auth/totp.py ``` -------------------------------- ### Basic Web Login Test with SeleniumLibrary Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/different_libraries/selenium.md Demonstrates a basic test case for logging into a website. It opens a browser, inputs credentials, clicks a button, verifies successful login, and closes the browser. ```robotframework *** Settings *** Library SeleniumLibrary *** Test Cases *** Login with correct Username and Password Open Browser url=https://the-internet.herokuapp.com/login browser=chrome Input Text username tomsmith Input Text password SuperSecretPassword! Click Button class:radius Element Should Contain id=flash You logged into a secure area! Click Link Logout Close Browser ``` -------------------------------- ### Check Python Version on Windows Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/getting_started/testing.mdx Verify Python installation by checking its version in the command line. ```cmd python -V ``` -------------------------------- ### Importing Resource from Same Directory Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/examples/project_structure.mdx Demonstrates the Robot Framework syntax for importing a resource file that resides in the same directory as the test suite. The import is direct and does not require a path prefix. ```robotframework *** Settings *** Resource general.resource ... ``` -------------------------------- ### Indentation for Test Cases and Tasks Source: https://github.com/marketsquare/robotframeworkguides/blob/main/website/docs/style_guide.md Test case and task names start at the first character. Test steps and called keywords are indented. ```robot *** Test Cases *** My First Test Case Test Step One ${myvar} Test Step Two That Returns A Value ``` ```robot *** Tasks *** My First Task Task Step One ${myvar} Task Step Two That Returns A Value ```