Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion anaconda-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ env_specs:

robotlab-test:
channels:
- https://conda.anaconda.org/anaconda
- https://conda.anaconda.org/conda-forge
- https://conda.anaconda.org/anaconda
- ./_artifacts/conda-bld
packages:
- robotlab
2 changes: 1 addition & 1 deletion ci/env-combine.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: robotlab-combine

channels:
- https://conda.anaconda.org/anaconda
- https://conda.anaconda.org/conda-forge
- https://conda.anaconda.org/anaconda

dependencies:
- robotframework
2 changes: 1 addition & 1 deletion ci/env-lab.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: robotlab-lab

channels:
- https://conda.anaconda.org/anaconda
- https://conda.anaconda.org/conda-forge
- https://conda.anaconda.org/anaconda

dependencies:
- black
Expand Down
34 changes: 33 additions & 1 deletion recipes/robotlab/builder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from pathlib import Path
import os, sys, shutil, json
import os, sys, shutil, json, platform, re

PLATFORM = platform.system().lower()

SRC_DIR = Path(os.environ["SRC_DIR"])
PREFIX = Path(os.environ["PREFIX"])
Expand All @@ -19,6 +21,13 @@
}
SVG = SRC_DIR / "robotlab" / "src" / "robotlab" / "icons" / "starter.svg"

OPENCV_OSX = """
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not prod of this: any thoughts of ways to make it cleaner? Can we add something at the RFSL layer?

${prefix} = Evaluate __import__("sys").prefix
Create WebDriver Firefox executable_path=${prefix}${/}bin${/}geckodriver firefox_binary=${prefix}${/}bin${/}firefox
Go To https://www.google.com/?hl=en
"""


print("making directories...")
[d.mkdir(exist_ok=True, parents=True) for d in [SHARE, ETC, WWW]]

Expand All @@ -33,6 +42,22 @@
for dest, src in NOTEBOOKS.items()
]

print("hacking OpenCV Notebook on OSX")

if PLATFORM == "darwin":
opencv = EXAMPLES / "OpenCV.ipynb"
nb = json.loads(opencv.read_text())
for cell in nb["cells"]:
if cell["cell_type"] == "code":
lines = cell["source"]
for i, line in enumerate(lines):
if re.findall(r"\s+Open browser", line, flags=re.I):
lines[i] = OPENCV_OSX
print(lines)
cell["source"] = lines

opencv.write_text(json.dumps(nb, indent=2))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeesh



print("making starters...")
(ETC / "robotlab-starters.json").write_text(json.dumps({
Expand All @@ -45,6 +70,13 @@
"py_src": "robotkernel",
"src": "resources/starter/quickstart-starter.ipynb"
},
"robotkernel-examples": {
"type": "copy",
"label": "More Robot Kernel Examples",
"description": "Examples of using robotkernel",
"icon": SVG.read_text().replace("jp-icon2", "jp-icon-contrast1"),
"src": str(EXAMPLES)
},
"robotkernel-tutorial": {
"label": "Tutorial",
"description": "Tutorial for Robot Framework on Jupyter",
Expand Down
9 changes: 6 additions & 3 deletions recipes/robotlab/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ requirements:
- jupyter-starters {{ robot_starters }}
- jupyterlab {{ robot_jupyterlab }}
- jupytext >=1.3.1
- matplotlib >=3.1.2
- matplotlib-base >=3.1.2
- nodejs {{ robot_node }}
- opencv
- py-opencv
- pyshortcuts
- python
- pywinpty {{ robot_pywinpty }} # [win]
Expand All @@ -75,8 +75,11 @@ test:
commands:
- robotlab --version
- robotlab-extension list
- robotlab-examples
- robotlab-tutorial
- robotlab-examples
- cd robotkernel-examples
- jupyter nbconvert --execute --ExecutePreprocessor.timeout=600 OpenCV.ipynb # [not osx]
- cd ..
- mkdir Desktop # [unix]
- HOME=$(pwd) robotlab-shortcuts # [unix]

Expand Down
4 changes: 2 additions & 2 deletions scripts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"--cache-dir",
CONDA_CACHE,
"-c",
"https://conda.anaconda.org/anaconda",
"-c",
"https://conda.anaconda.org/conda-forge",
"-c",
"https://conda.anaconda.org/anaconda",
"--python",
PY_MIN,
]
Expand Down
14 changes: 14 additions & 0 deletions tests/acceptance/RobotLab/1_CLI/10_examples.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,22 @@
Documentation robotlab-examples
Force Tags app:robotlab-examples
Resource ../../../resources/CLI.robot
Library Process

*** Variables ***
${NBCONVERT} jupyter nbconvert --execute --ExecutePreprocessor.timeout=600

*** Test Cases ***
Can I install the examples?
[Documentation] Does robotlab-examples work?
[Tags] example:opencv
Check a RobotLab CLI command robotlab-examples check_dir=robotkernel-examples

Can I run the examples?
[Documentation] Will they nbconvert?
[Tags] example:opencv
${log} = Set Variable ${OUTPUT DIR}${/}robotlab-example-nbconvert-opencv.log
${proc} = Run Process ${ACTIVATE} && ${NBCONVERT} OpenCV.ipynb shell=True cwd=${OUTPUT DIR}${/}robotkernel-examples stdout=${log} stderr=STDOUT
... env:PS1=[:|]
Should Be Equal As Numbers ${proc.rc} 0
Copy File ${OUTPUT DIR}${/}robotkernel-examples${/}OpenCV.html ${OUTPUT DIR}${/}nbconvert-OpenCV.html
12 changes: 0 additions & 12 deletions tests/acceptance/RobotLab/2_Lab/20_Robot_Notebook.robot
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,3 @@ Can RobotLab make a Robot Notebook?
Execute JupyterLab Command Save Notebook
Sleep 2s
Capture Page Screenshot ${prefix}_09_save.png

*** Keywords ***
The Robot Popup Should Contain
[Arguments] ${prefix} ${document} ${msg}
[Documentation] With an open Robot Notebook, take a look at the log or report
Click Link ${document}
Sleep 1s
Select Window Jupyter ${document}
Page Should Contain ${msg}
Capture Page Screenshot ${prefix}_10_${document.lower()}.png
Close Window
Select Window RobotLab
5 changes: 3 additions & 2 deletions tests/acceptance/RobotLab/2_Lab/30_Tutorial.robot
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Resource ../../../resources/Browser.robot
Resource ../../../resources/Selectors.robot

*** Variables ***
${KERNEL LANGUAGE} Python 3
${TOKEN CELL 00} .jp-CodeCell:nth-child(3) .CodeMirror

*** Test Cases ***
Expand Down Expand Up @@ -46,7 +47,7 @@ Open the Tutorial Notebook
Wait Until Page Contains Element ${XP FILE TREE TUTORIAL 00} timeout=10s
Double Click Element ${XP FILE TREE TUTORIAL 00}
Wait Until Page Contains Element css:.jp-Notebook table timeout=10s
Wait Until Page Contains Python 3 | Idle timeout=3s
Wait Until Page Contains ${KERNEL LANGUAGE} | Idle timeout=3s
Capture Page Screenshot ${prefix}_2_after_launch.png
Execute JupyterLab Command Clear All Outputs

Expand All @@ -60,6 +61,6 @@ Run the Tutorial Notebook
Click Element ${CSS NOTEBOOK SAVE}
Execute JupyterLab Command Run All Cells
Wait Until Page Does Not Contain [*] timeout=20s
Wait Until Page Contains Python 3 | Idle timeout=3s
Wait Until Page Contains ${KERNEL LANGUAGE} | Idle timeout=3s
Click Element ${CSS NOTEBOOK SAVE}
Execute JupyterLab Command Close All
66 changes: 66 additions & 0 deletions tests/acceptance/RobotLab/2_Lab/40_Examples.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
*** Settings ***
Documentation Try the Examples
Force Tags starter:example
Library JupyterLibrary
Resource ../../../resources/Browser.robot
Resource ../../../resources/Lab.robot
Resource ../../../resources/Selectors.robot

*** Variables ***
${KERNEL LANGUAGE} Robot Framework

*** Test Cases ***
Will the Example Starter Launch?
[Documentation] Start the Example
[Tags] example:opencv
Open RobotLab
${prefix} = Set Variable example_
Execute JupyterLab Command Close All
Wait Until Page Contains Element ${XP LAUNCH SECTION}
Capture Page Screenshot ${prefix}_0_before_starter.png
Click Element ${CSS LAUNCH CARD EXAMPLES}
Wait Until Page Contains Element ${XP FILE TREE EXAMPLE OPENCV} timeout=10s
Capture Page Screenshot ${prefix}_1_after_starter.png

Will the OpenCV Notebook Run?
[Documentation] Run the OpenCV Tutorial Notebook
[Tags] example:opencv
Open RobotLab
${prefix} = Set Variable example_opencv_
Open the Example Folder ${prefix}
Open the Example Notebook ${prefix} ${XP FILE TREE EXAMPLE OPENCV}
Run the Example Notebook ${prefix}
Capture Page Screenshot ${prefix}_6_after_run_all.png
The Robot Popup Should Contain ${prefix} Log passed, 0 failed
The Robot Popup Should Contain ${prefix} Report All tests passed
Capture Page Screenshot ${prefix}_7_reported.png
Screenshot Each Output of Active JupyterLab Document ${prefix}_8_all_

*** Keywords ***
Open the Example Folder
[Arguments] ${prefix}
[Documentation] Open the example folder
Execute JupyterLab Command Close All
Maybe Open JupyterLab Sidebar File Browser
Click Element ${CRUMBS HOME}
Double Click Element ${XP FILE TREE EXAMPLE}
Capture Page Screenshot ${prefix}_1_in_folder.png

Open the Example Notebook
[Arguments] ${prefix} ${example}
[Documentation] Open and prepare the example notebook
Wait Until Page Contains Element ${example} timeout=10s
Double Click Element ${example}
Wait Until Page Contains ${KERNEL LANGUAGE} | Idle timeout=10s
Capture Page Screenshot ${prefix}_2_after_launch.png
Execute JupyterLab Command Clear All Outputs
Sleep 1s
Capture Page Screenshot ${prefix}_3_after_clean.png

Run the Example Notebook
[Arguments] ${prefix}
[Documentation] Actually run the example notebook
Execute JupyterLab Command Run All Cells
Wait Until Page Does Not Contain [*] timeout=120s
Wait Until Page Contains ${KERNEL LANGUAGE} | Idle timeout=120s
Capture Page Screenshot ${prefix}_4_after_run.png
2 changes: 1 addition & 1 deletion tests/resources/Browser.robot
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Open RobotLab
Go To about:blank
Set Window Size 1920 1080
Go To ${final_url}
Wait for JupyterLab Splash Screen
Wait Until Keyword Succeeds 5x 5s Wait for JupyterLab Splash Screen

Really Close All Browsers
[Documentation] We might open lots of browsers... this might help
Expand Down
11 changes: 11 additions & 0 deletions tests/resources/Lab.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,14 @@ Start a new Notebook
Execute JupyterLab Command Close All
Launch a new JupyterLab Document ${kernel} Notebook
Wait Until JupyterLab Kernel Is Idle

The Robot Popup Should Contain
[Arguments] ${prefix} ${document} ${msg}
[Documentation] With an open Robot Notebook, take a look at the log or report
Click Link ${document}
Sleep 1s
Select Window Jupyter ${document}
Page Should Contain ${msg}
Capture Page Screenshot ${prefix}_10_${document.lower()}.png
Close Window
Select Window RobotLab
3 changes: 3 additions & 0 deletions tests/resources/Selectors.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
${XP LAUNCH SECTION} xpath://h2[contains(@class, 'jp-Launcher-sectionTitle')][text() = 'Starters']
${CSS LAUNCH CARD} css:[data-category\="Starters"]
${CSS LAUNCH CARD TUTORIAL} ${CSS LAUNCH CARD}\[title\="Tutorial for Robot Framework on Jupyter"]
${CSS LAUNCH CARD EXAMPLES} ${CSS LAUNCH CARD}\[title\="Examples of using robotkernel"]
${XP FILE TREE ITEM} xpath://span[contains(@class, 'jp-DirListing-itemText')]
${XP FILE TREE TUTORIAL} ${XP FILE TREE ITEM}\[text() = 'tutorial']
${XP FILE TREE TUTORIAL 00} ${XP FILE TREE ITEM}\[text() = '00 Keyboard Shortcuts.ipynb']
${XP FILE TREE EXAMPLE} ${XP FILE TREE ITEM}\[text() = 'robotkernel-examples']
${XP FILE TREE EXAMPLE OPENCV} ${XP FILE TREE ITEM}\[text() = 'OpenCV.ipynb']
${CSS NOTEBOOK SAVE} css:[data-icon="save"]
${JP STATUS BAR} id:jp-bottom-panel
${CRUMBS HOME} css:.jp-BreadCrumbs-home