### robotcode discover info command examples Source: https://robotcode.io/03_reference/discovering-tests Shows how to get environment and version information, optionally with JSON output using --format json. ```bash robotcode discover info robotcode --format json discover info ``` -------------------------------- ### Quick start: wrapper usage examples Source: https://robotcode.io/03_reference/wrapper Shows three ways to use the wrapper: with a ready-made tool like xvfb-run, with a configured profile, and ignoring the wrapper for one run. The wrapper command is appended to the real robotcode command line. ```bash # A ready-made tool, for a single run (the value is split like a shell command) robotcode --wrapper "xvfb-run -a" run tests/ # Your own environment script, configured once in a profile robotcode -p integration run tests/ # Ignore a configured wrapper for one run robotcode -p integration --no-wrapper run tests/ ``` -------------------------------- ### Quick start: .robotignore patterns Source: https://robotcode.io/03_reference/ignoring-files Create a .robotignore file in the project root and add one pattern per line. The syntax is identical to .gitignore. This example excludes results/, node_modules/, and any generated/ directory. ```gitignore results/ node_modules/ **/generated/ ``` -------------------------------- ### robotcode config show examples Source: https://robotcode.io/03_reference/cli Examples of using `robotcode config show` to display the current configuration. ```text robotcode config show robotcode config show tests/acceptance/first.robot robotcode --format json config show ``` -------------------------------- ### robotcode discover info example Source: https://robotcode.io/03_reference/cli Example of using `robotcode discover info` to show information about the current Robot Framework environment. ```text robotcode discover info ``` -------------------------------- ### robotcode config info list examples Source: https://robotcode.io/03_reference/cli Examples of using `robotcode config info list` to list configuration settings. ```text robotcode config info list robotcode config info list rebot.* robotcode config info list *tag* ``` -------------------------------- ### RobotCode REPL command-line examples Source: https://robotcode.io/03_reference/repl Shows common ways to invoke `robotcode repl`: interactive prompt, script execution, inspect mode, variable pre-setting, library path addition, and log/output capture. Use these to start a REPL session or run a script. ```bash # Interactive prompt robotcode repl # Execute a REPL script, then exit robotcode repl spike.robotrepl # Execute a REPL script, then drop into the prompt robotcode repl --inspect spike.robotrepl # Pre-set variables for the whole session robotcode repl -v BASE_URL:https://staging.example.com -v RETRIES:3 # Add a directory to the library search path robotcode repl -P ./resources # Capture a log.html / output.xml from the session robotcode repl -d ./repl-output -o output.xml -l log.html ``` -------------------------------- ### robotcode config files examples Source: https://robotcode.io/03_reference/cli Examples of using `robotcode config files` to search for configuration files. ```text robotcode config files robotcode config files tests/acceptance/first.robot ``` -------------------------------- ### robotcode discover examples Source: https://robotcode.io/03_reference/cli Example invocations of the discover command: basic usage and with a profile flag. ```text robotcode discover tests ``` ```text robotcode --profile regression discover tests ``` -------------------------------- ### robotcode config info desc examples Source: https://robotcode.io/03_reference/cli Examples of using `robotcode config info desc` to show descriptions of configuration settings. ```text robotcode config info desc robotcode config info desc python-path robotcode config info desc rebot.* robotcode config info desc *tag* ``` -------------------------------- ### Install robotcode repl package Source: https://robotcode.io/03_reference/repl Install the optional `repl` package to enable `robotcode repl` and `robotcode robot-debug` commands. Use `robotcode[repl]` for the minimal install or `robotcode[all]` for all extras. ```bash pip install robotcode[repl] # or: pip install robotcode[all] ``` -------------------------------- ### robotcode config root examples Source: https://robotcode.io/03_reference/cli Examples of using `robotcode config root` to find the project root folder. ```text robotcode config root robotcode config root tests/acceptance/first.robot ``` -------------------------------- ### Example stats output for tag and suite Source: https://robotcode.io/03_reference/analyzing-results Example output from `stats` showing tables for `By Tag` and `By Suite`. The output is illustrative and shows the format of the tables. ```text By Tag: NAME TOTAL PASS FAIL SKIP ELAPSED regression 24 19 5 0 4m 12s smoke 18 18 0 0 47s slow 7 5 1 1 2m 03s bug-1842 2 0 2 0 8s By Suite: NAME TOTAL PASS FAIL SKIP ELAPSED MyProject.Checkout 14 10 4 0 3m 11s MyProject.Login 12 12 0 0 1m 02s MyProject.Search 8 7 0 1 52s ``` -------------------------------- ### robotcode discover tasks examples Source: https://robotcode.io/03_reference/cli Example invocations for the `robotcode discover tasks` command, showing basic usage and filtering with profiles and tags. ```text robotcode discover tasks robotcode --profile regression discover tasks robotcode --profile regression discover tasks --include regression --exclude wipANDnotready ``` -------------------------------- ### testdoc.doc TOML example Source: https://robotcode.io/03_reference/config Overrides the top-level suite documentation. The first example sets a literal documentation string; the second reads documentation from a file. ```toml doc = "Very *good* example" ``` ```toml # read documentation from a file doc = "doc_from_file.txt" ``` -------------------------------- ### rebot.start-time TOML example Source: https://robotcode.io/03_reference/config Sets execution start time. Timestamp must be in format 2007-10-01 15:12:42.268 with optional separators. Corresponds to the --starttime timestamp option of rebot. ```toml start-time = "2024-12-15 14:30:00.000" ``` -------------------------------- ### Robot Framework Suite Settings Example Source: https://robotcode.io/04_tip_and_tricks/01_avoiding_a_global_resource_file Declares libraries and resources in the Settings section to document the suite's purpose. This example shows a suite dealing with login processes, customer management, and database validation. ```robot *** Settings *** Library LoginProcess Resource CustomerManagement.resource Resource DatabaseValidation.resource ``` -------------------------------- ### Recipes for robotcode results log Source: https://robotcode.io/03_reference/analyzing-results A set of example commands for common log analysis tasks: drilling into a failing test, filtering by failure level, limiting depth, extracting screenshots, diagnosing suite errors, and getting a full structured view. ```bash # Drill into one failing test robotcode results log -bl MyProject.Login.Bad_Password # Walk only the FAIL-level messages of every failed test robotcode results log --failed --level FAIL # Top-level keyword calls only, with everything nested collapsed robotcode results log --max-depth 1 # Pull screenshots out of a failed run robotcode results log --failed --extract ./extracted # Diagnose suites that broke before they even ran robotcode results log --execution-messages --level WARN # Full structured view — suite headers + per-keyword doc/tags/timeout robotcode results log --suite-info --keyword-info ``` -------------------------------- ### robotcode discover suites examples Source: https://robotcode.io/03_reference/cli Examples of using `robotcode discover suites` to discover suites. Shows basic usage, using a profile, and combining profile with tag filters. ```text robotcode discover suites ``` ```text robotcode --profile regression discover suites ``` ```text robotcode --profile regression discover suites --include regression --exclude wipANDnotready ``` -------------------------------- ### robotcode discover files example Source: https://robotcode.io/03_reference/cli Example of using `robotcode discover files` to show all files used to discover tests. Note: currently only `.robot` and `.resource` files are shown. ```text robotcode discover files . ``` -------------------------------- ### Robot Framework Test Case: Log Hello World Source: https://robotcode.io/02_get_started/ Create a file named first.robot with this content to define a simple test case that logs 'Hello world' to the debug console. Run it by pressing the green play button next to the 'First Test Case' keyword; the output appears in the Debug Console. ```robot *** Test Cases *** First Test Case Log Hello world ``` -------------------------------- ### extend-tag-stat-link TOML example Source: https://robotcode.io/03_reference/config Appends entries to the --tagstatlink option. Add external links into 'Statistics by Tag'. Pattern can use '*', '?' and '[]' as wildcards like --test. Characters matching to '*' and '?' wildcards can be used in link and title with syntax %N, where N is index of the match (starting from 1). ```toml [extend-tag-stat-link] mytag = "http://my.domain:Title" "bug-*" = "http://url/id=%1:Issue Tracker" ``` -------------------------------- ### nvim-lspconfig RobotCode configuration Source: https://robotcode.io/04_tip_and_tricks/04_neovim_lsp_setup Configuration for nvim-lspconfig to set up RobotCode as a language server. It specifies the command, filetypes, root markers, and language ID. This setup uses the first 'robotcode' binary in PATH, typically installed via Mason, which may cause import errors for project-specific libraries. ```lua return { cmd = { 'robotcode', 'language-server' }, filetypes = { 'robot', 'resource' }, root_markers = { 'robot.toml', 'pyproject.toml', 'Pipfile', '.git' }, get_language_id = function(_, _) return 'robotframework' end, } ``` -------------------------------- ### Extending vs. replacing settings Source: https://robotcode.io/02_get_started/configuration Shows how to use the extend- prefix to add to list and dictionary settings instead of completely replacing them. The example demonstrates default settings, a profile that replaces variables, and a profile that extends variables and include. ```toml # Default settings variables = { BROWSER = "chrome", TIMEOUT = "20s" } include = ["smoke"] [profiles.api] # Completely replaces the default variables variables = { API_KEY = "123456" } # BROWSER and TIMEOUT are removed [profiles.extended] # Adds to the default variables extend-variables = { API_KEY = "123456" } # Results in {BROWSER = "chrome", TIMEOUT = "20s", API_KEY = "123456"} extend-include = ["api"] # Results in ["smoke", "api"] ``` -------------------------------- ### Install robotcode with runner package Source: https://robotcode.io/03_reference/discovering-tests Install the optional `runner` package required for the `robotcode discover` command. Use `pip install robotcode[runner]` or `pip install robotcode[all]`. ```bash pip install robotcode[runner] # or: pip install robotcode[all] ``` -------------------------------- ### Robot Framework: Configuration Builder Pattern with RETURN Source: https://robotcode.io/04_tip_and_tricks/02_why_variable_not_found Shows a keyword that builds a configuration dictionary based on environment and returns it, plus a keyword that initializes an API client using that config. The test case demonstrates using the staging configuration. ```robot *** Keywords *** Create Test Configuration [Arguments] ${environment}=test ${config}= Create Dictionary IF "${environment}" == "production" Set To Dictionary ${config} ... url=https://api.production.example.com ... timeout=60 ... retry=5 ELSE IF "${environment}" == "staging" Set To Dictionary ${config} ... url=https://api.staging.example.com ... timeout=30 ... retry=3 ELSE Set To Dictionary ${config} ... url=https://api.test.example.com ... timeout=10 ... retry=1 END RETURN ${config} Initialize API Client [Arguments] ${config} ${client}= Create API Client ... base_url=${config}[url] ... timeout=${config}[timeout] RETURN ${client} *** Test Cases *** API Test With Configuration ${config}= Create Test Configuration staging ${client}= Initialize API Client ${config} ${response}= Call API ${client} /health Should Be Equal ${response.status} 200 ``` -------------------------------- ### extend-includes TOML example with AND pattern Source: https://robotcode.io/03_reference/config Example TOML configuration for extend-includes, appending entries to the --include option. This example matches tests with both 'foo' and 'bar*' tags. ```toml # tests with both "foo" and "bar*" tags extend-includes = ["fooANDbar*"] ``` -------------------------------- ### extend-includes TOML example with OR pattern Source: https://robotcode.io/03_reference/config Example TOML configuration for extend-includes, appending entries to the --include option. This example matches tests tagged 'foo' or 'bar*'. ```toml # match tests tagged "foo" or "bar*" extend-includes = ["foo", "bar*"] ``` -------------------------------- ### Example TEXT output with suite and keyword info Source: https://robotcode.io/03_reference/analyzing-results Shows the TEXT output format when --suite-info and --keyword-info are combined. Suite headers include documentation and metadata; keyword entries show their own documentation, tags, and timeout. ```text Suite: MyProject.Login (tests/login.robot) PASS [Documentation] Exercises the login flow against the staging environment. [Metadata] OwnerTeam = identity-squad Test: MyProject.Login.Bad Password (tests/login.robot:42) FAIL [SETUP] Open Browser PASS [Documentation] Launches a fresh Chromium with our shared profile. [Tags] browser setup ... ``` -------------------------------- ### randomize TOML examples Source: https://robotcode.io/03_reference/config Configures test execution randomization in TOML. The first example randomizes all suites and tests. The second example randomizes tests with a fixed seed. Corresponds to the --randomize option of robot. ```toml randomize = "all" ``` ```toml # randomize tests with a fixed seed randomize = "tests:1234" ``` -------------------------------- ### Sample trace output for Log To Console Source: https://robotcode.io/03_reference/repl Example REPL session showing the KEYWORD line printed before the keyword's own output when --show-keywords is active. ```text >>> Log To Console hi KEYWORD BuiltIn.Log To Console hi hi ``` -------------------------------- ### Syntax example: .robotignore patterns Source: https://robotcode.io/03_reference/ignoring-files Full example of .robotignore pattern syntax, identical to .gitignore. Demonstrates comments, directory matching, wildcards, anchoring, ** globs, and re-including a file inside an excluded folder's contents. ```gitignore # a comment starts with '#' # match a directory anywhere in the tree (trailing slash = directories only) results/ node_modules/ coverage/ # match by name at any depth (no slash) *.bak *.tmp # anchor to this directory only (leading slash) /legacy/ # match nested paths with '**' **/generated/ tests/**/snapshots/ # exclude a folder's contents but keep one file # (use '/*', not 'fixtures/' — '!' can't re-include inside a fully excluded folder) fixtures/* !fixtures/shared.resource ``` -------------------------------- ### Install robotcode core package Source: https://robotcode.io/03_reference/cli Installs the core robotcode CLI tool using pip. ```bash pip install robotcode ``` -------------------------------- ### Install all robotcode packages Source: https://robotcode.io/03_reference/cli Installs all robotcode packages including optional dependencies, such as robocop for linting and formatting. ```bash pip install robotcode[all] ``` -------------------------------- ### Install robotcode-runner package Source: https://robotcode.io/02_get_started/configuration Install the robotcode-runner package using pip. This is required to execute tests with RobotCode. ```bash pip install robotcode[runner] ``` -------------------------------- ### Sample output of robotcode discover files Source: https://robotcode.io/03_reference/discovering-tests Example output listing discovered .robot and .resource files. Files under ignored directories are excluded automatically. ```text tests/login/test_login.robot tests/login/resources/login_keywords.resource tests/checkout/test_checkout.robot ``` -------------------------------- ### extend-paths TOML example Source: https://robotcode.io/03_reference/config Appends extra entries to the paths argument. The example shows a list of paths. ```toml extend-paths = ["tests"] ``` -------------------------------- ### wrapper TOML example Source: https://robotcode.io/03_reference/config Configures the wrapper command prefix for the integration profile. The actual 'robotcode' command line is appended to the wrapper. The selected profile's 'env' is applied first. The example shows using './with-test-services.sh' or a ready-made tool like 'xvfb-run -a' for headless UI tests. ```toml [profiles.integration] wrapper = ["./with-test-services.sh"] # or a ready-made tool, e.g. ["xvfb-run", "-a"] for headless UI tests ``` -------------------------------- ### extend-wrapper TOML example Source: https://robotcode.io/03_reference/config Appends extra entries to the wrapper command prefix. The example adds a single flag. ```toml extend-wrapper = ["--some-flag"] ``` -------------------------------- ### stats recipes Source: https://robotcode.io/03_reference/analyzing-results Practical examples for common aggregation tasks: worst tags by failure count, top 5 tags, CI time by suite, and status breakdown for a specific tag. ```bash # Worst tags by failure count (default sort) robotcode results stats --by tag # Five worst tags only robotcode results stats --by tag --top 5 # Where is the CI time going? robotcode results stats --by suite --sort elapsed # Status breakdown for one specific tag robotcode results stats --include flaky --by status ``` -------------------------------- ### Sample TEXT output of robotcode discover info Source: https://robotcode.io/03_reference/discovering-tests Example output showing versions and platform details. Environment variables like ROBOT_OPTIONS are echoed back under robotEnv. ```text robotVersionString: 7.4.2 robotcodeVersionString: 1.6.0 pythonVersionString: 3.13.2 executable: .venv/bin/python platform: linux system: Linux … ``` -------------------------------- ### extend-pre-rebot-modifiers TOML example Source: https://robotcode.io/03_reference/config Appends entries to the --prerebotmodifier option. The example defines a modifier class with arguments. ```toml [extend-pre-rebot-modifiers] "path/to/Modifier.py" = ["arg1"] ``` -------------------------------- ### Activate virtual environment and start Neovim (Windows CMD) Source: https://robotcode.io/04_tip_and_tricks/04_neovim_lsp_setup Before starting Neovim, activate the virtual environment created in the .venv folder using Command Prompt. This ensures the robotcode binary from the project's environment is first in PATH. ```cmd .venv\Scripts\activate.cmd nvim ``` -------------------------------- ### extend-args TOML example Source: https://robotcode.io/03_reference/config Appends extra arguments to be passed to Robot Framework. The example adds the -t and abc arguments. ```toml extend-args = ["-t", "abc"] ``` -------------------------------- ### Activate virtual environment and start Neovim (Mac/Linux) Source: https://robotcode.io/04_tip_and_tricks/04_neovim_lsp_setup Before starting Neovim, activate the virtual environment created in the .venv folder. This ensures the robotcode binary from the project's environment is first in PATH. ```shell source .venv/bin/activate nvim ```