Skip to content

Robot Framework IPython kernel for Jupyter Notebook and JupyterLab

License

Notifications You must be signed in to change notification settings

pauloladimeji/robotkernel

 
 

Repository files navigation

Robotkernel

Robot Framework IPython kernel for Jupyter Notebook and JupyterLab. Check a video to see it in action.

Requires Python 3.6 or later with setuptools 40.5.0 later and Robot Framework 3.1 or later.

Log | Report -links on existing notebooks are only active on trusted notebooks.

Try Robotkernel at Binder

Jupyter Notebook: https://mybinder.org/v2/gh/robots-from-jupyter/robotkernel/master?urlpath=tree/example.ipynb

JupyterLab: https://mybinder.org/v2/gh/robots-from-jupyter/robotkernel/master?urlpath=lab/tree/example.ipynb

Install Robotkernel

$ pip install robotkernel

For JupyterLab you should also install the companion syntax highlighting and Jupyter widgets support:

$ jupyter labextension install jupyterlab_robotmode
$ jupyter labextension install @jupyter-widgets/jupyterlab-manager

For some environments it might be required to run the following command to manually register robotkernel as Jupyter kernel:

$ python -m robotkernel.install

Install Robotkernel from Python 3 notebook

!pip install robotkernel

After refreshing the notebook, it is possible change the kernel to Robot Framework kernel or create a new notebook with Robot Framework kernel.

For JupyterLab you should also install the companion syntax highlighting and Jupyter widgets support:

!jupyter labextension install jupyterlab_robotmode
!jupyter labextension install @jupyter-widgets/jupyterlab-manager

Export robot files

It is possible to export test suites direclty from Jupyter Notebook or JupyterLab user interface (into traditional .robot files), but also from command line:

$ jupyter nbconvert --to script example.ipynb

Execute notebooks

Robotkernel installs script named nbrobot, which the Robot Frameworks test runner robot with support for executing Jupyter notebooks created with Robotkernel:

$ nbrobot example.ipynb

In addition, it is also possible to execute notebooks as such, resulting into a new notebook with embedded execution logs and reports:

$ jupyter nbconvert --to notebook --execute example.ipynb

This will stop the execution at first failing test case.

When execution with errors, to also get a result notebook with execution logs saved, an extra flag --ExecutePreprocessor.allow_errors=True must be set:

$ jupyter nbconvert --ExecutePreprocessor.allow_errors=True --to notebook --execute example.ipynb

This may change in future versions of nbconvert.

Note that when executing a notebook, each cell with tests cases or tasks will be executed as its own suite. It might be more efficient to export notebook into a robot script and execute that with the traditional robot runner.

Local installation and development

See also: http:https://jupyter.readthedocs.io/en/latest/install.html

Create and activate clean Python virtual environment:

$ venv myenv
$ source myenv/bin/activate

Install Jupyter:

$ pip install --upgrade pip setuptools
$ pip install jupyter

Clone this kernel:

$ git clone https://github.com/robots-from-jupyter/robotkernel.git
$ cd robotkernel

Install the kernel into virtualenv in develop mode:

$ python setup.py develop

Launch the jupyter:

$ jupyter notebook

Reloading the kernel reloads the code.

This repository includes opinionated instructions for running and developing Robotkernel with Nix for Jupyter Notebook:

$ nix-shell -E 'import (fetchTarball https://github.com/robots-from-jupyter/robotkernel/archive/master.tar.gz + "/shell.nix")' --run "jupyter notebook"

And for Jupyter Lab:

$ nix-shell -E 'import (fetchTarball https://github.com/robots-from-jupyter/robotkernel/archive/master.tar.gz + "/shell.nix")'
$ jupyter labextension install jupyterlab_robotmode --app-dir=.jupyterlab
$ jupyter lab --app-dir=.jupyterlab
$ exit

Add --arg sikuli true to include SikuliLibrary.

Add --arg vim true to enable vim bindings.

Development environment with Nix:

$ git clone https://github.com/robots-from-jupyter/robotkernel.git
$ cd robotkernel
$ nix-build setup.nix -A env  # to generate ./result/bin/python for IDE
$ nix-shell setup.nix -A develop

About

Robot Framework IPython kernel for Jupyter Notebook and JupyterLab

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Jupyter Notebook 94.3%
  • Python 2.4%
  • Nix 2.1%
  • JavaScript 0.6%
  • TypeScript 0.5%
  • Makefile 0.1%