%reload_ext JupyterLibrary
The %%robot
magic runs a cell of code as you would write in a .robot
file. No funny stuff (by default).
%%robot -o _static
*** Tasks ***
Log Something
Log Something
The interactive help is pretty good.
%%robot?
Of note: you can specify extra arguments to robot.run
with -a
, the name of a local variable.
args = dict(include=["mytag:a"])
%%robot -a args -o _static
*** Tasks ***
Do thing A
[Tags] mytag:a
Log A
Do thing B
[Tags] mytag:b
Log B
Do thing AB
[Tags] mytag:a mytag:b
Log AB
JupyterLibrary
¶The line below is a Markdown Cell... change it to a Code Cell to run it
%%robot
*** Settings ***
Documentation A nice task suite
Library JupyterLibrary
Suite Setup Wait For New Jupyter Server To Be Ready
Test Teardown Reset JupyterLab And Close
Suite Teardown Run Keyword And Ignore Error Terminate All Jupyter Servers
*** Tasks ***
A Notebook in JupyterLab
Open JupyterLab
Launch A New JupyterLab Document
Add And Run JupyterLab Code Cell print("hello" + " world")
Wait Until page Contains hello world
Capture Page Screenshot ran-code.png
There is some more stuff coming with
%%robot
, but for now,ipywidgets.interact
can be used to quickly build UI around robot-generated artifacts
from pathlib import Path
from IPython.display import display, Image
ipywidgets = None
try:
import ipywidgets
except:
pass
if ipywidgets:
@ipywidgets.interact
def show_image(i=(0, 100)):
all_images = sorted(Path("_robot_magic_").rglob("*.png"), key=lambda p: p.stat().st_mtime)
if not all_images:
return
start = all_images[0].stat().st_mtime
i = min(len(all_images) - 1, i)
img = all_images[i]
delta = img.stat().st_mtime - start
display(f"[{round(delta)}s][{i} of {len(all_images)}] {img.name}", Image(img))