Skip to main content

RobotFramework debug shell

Project description

Introduction

This Library is a Fork by René Rohner from the original robotframework-debuglibrary by Xie Yanbo

Robotframework-RobotDebug is a debug library for RobotFramework, which can be used as an interactive shell(REPL) also.

Maintainability Test Coverage test Latest version Support robotframework versions Support python versions PyPI Downloads License

Installation

To install using pip:

pip install robotframework-debug

Usage

You can use this as a library, import RobotDebug and call Debug or Debug If keywords in your test files like this:

*** Settings ***
Library         RobotDebug

** test case **
SOME TEST
    # some keywords...
    Debug
    # some else...
    ${count} =  Get Element Count  name:div_name
    Debug If  ${count} < 1

Or you can run it standalone as a RobotFramework shell:

$ rfdebug
[...snap...]
>>>>> Enter interactive shell
> help
Input Robotframework keywords, or commands listed below.
Use "libs" or "l" to see available libraries,
use "keywords" or "k" to see the list of library keywords,
use the TAB keyboard key to autocomplete keywords.

Documented commands (type help <topic>):
========================================
EOF  continue  docs  help  keywords  libs  ll        n     pdb  selenium
c    d         exit  k     l         list  longlist  next  s    step
> log  hello
> get time
< '2011-10-13 18:50:31'
> # use TAB to auto complete commands
> BuiltIn.Get Time
< '2011-10-13 18:50:39'
> import library  String
> get substring  helloworld  5  8
< 'wor'
> # define variables as you wish
> ${secs} =  Get Time  epoch
# ${secs} = 1474814470
> Log to console  ${secs}
1474814470
> @{list} =  Create List    hello    world
# @{list} = ['hello', 'world']
> Log to console  ${list}
['hello', 'world']
> &{dict} =  Create Dictionary    name=admin    email=admin@test.local
# &{dict} = {'name': 'admin', 'email': 'admin@test.local'}
> Log  ${dict.name}
> # print value if you input variable name only
> ${list}
[u'hello', u'world']
> ${dict.name}
admin
> # start a selenium server quickly
> help selenium
Start a selenium webdriver and open url in browser you expect.

        s(elenium)  [<url>]  [<browser>]

        default url is google.com, default browser is firefox.
> selenium  google.com  chrome
# import library  SeleniumLibrary
# open browser  http://google.com  chrome
< 1
> close all browsers
> Ctrl-D
>>>>> Exit shell.

The interactive shell support auto-completion for robotframework keywords and commands. Try input BuiltIn. then type <TAB> key to feeling it. The history will save at ~/.rfdebug_history default or any file defined in environment variable RFDEBUG_HISTORY.

In case you don’t remember the name of keyword during using rfdebug, there are commands libs or ls to list the imported libraries and built-in libraries, and keywords <lib name> or k to list keywords of a library.

rfdebug accept any pybot arguments, but by default, rfdebug disabled all logs with -l None -x None -o None -L None -r None.

Step debugging

RobotDebug support step debugging since version 2.1.0. You can use step/s, next/n, continue/c, list/l and longlist/ll to trace and view the code step by step like in pdb:

$ robot some.robot
[...snap...]
>>>>> Enter interactive shell
> l
Please run `step` or `next` command first.
> s
.> /Users/xyb/some.robot(7)
-> log to console  hello
=> BuiltIn.Log To Console  hello
> l
  2         Library  RobotDebug
  3
  4         ** test case **
  5         test
  6             debug
  7 ->          log to console  hello
  8             log to console  world
> n
hello
.> /Users/xyb/some.robot(8)
-> log to console  world
=> BuiltIn.Log To Console  world
> c
>>>>> Exit shell.
world

Note: Single-step debugging does not support FOR loops currently.

Submitting issues

Bugs and enhancements are tracked in the issue tracker.

Before submitting a new issue, it is always a good idea to check is the same bug or enhancement already reported. If it is, please add your comments to the existing issue instead of creating a new one.

Development

If you want to develop and run RobotDebug locally, you can use

$ python RobotDebug/shell.py tests/step.robot

shell.py is calling robot through a child process, so it will interrupt python debugging capabilities. If you want to debug in tools like vscode, pdb, you should run

$ python -m robot tests/step.robot

If you want to run the test, please install the dependency packages first and then execute the test

$ python setup.py develop
$ python setup.py test

Since RF takes over stdout, debugging information can be output with

import sys
print('some information', file=sys.stdout)

License

This software is licensed under the New BSD License. See the LICENSE file in the top distribution directory for the full license text.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

robotframework-debug-3.3.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

robotframework_debug-3.3.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file robotframework-debug-3.3.0.tar.gz.

File metadata

  • Download URL: robotframework-debug-3.3.0.tar.gz
  • Upload date:
  • Size: 22.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.9

File hashes

Hashes for robotframework-debug-3.3.0.tar.gz
Algorithm Hash digest
SHA256 0c0d5ce3044cc78e5f206451cc2661912d79177158f74c9a6c168eb834d1fe1c
MD5 750a6c832e0662025cc1ef4e435e4908
BLAKE2b-256 1e2d8e1bb65a8ca37552adfcd614f9fe20cba382aa81721c3dcdf9f9f151e96b

See more details on using hashes here.

File details

Details for the file robotframework_debug-3.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robotframework_debug-3.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29d15e244c14ce21703e965dbb57e666a0e6b3d7ee1e8375b13e09a990ee68df
MD5 cd18a1ba67cab89776159fcc570cb3ea
BLAKE2b-256 82ad24380ff5082bcd743e7e7af2cfdd2377c3c62b539c0da06b407fe8fdb2ce

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page