Skip to content

Commit fc4c212

Browse files
committed
initial notebook classic support
1 parent 28ffb9f commit fc4c212

File tree

10 files changed

+99
-4
lines changed

10 files changed

+99
-4
lines changed

atest/acceptance/01_server/00_basic.robot

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*** Settings ***
22
Suite Teardown Terminate All Jupyter Servers
3+
Force Tags server
34
Library JupyterLibrary
45
Library Process
56
Library OperatingSystem
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
*** Settings ***
2+
Test Teardown Close All Browsers
3+
Default Tags notebook
4+
Library JupyterLibrary
5+
Library Process
6+
7+
*** Test Cases ***
8+
IPython Notebook
9+
Open Jupyter Notebook Classic
10+
Launch a new Jupyter Notebook Classic Notebook
11+
Capture Page Screenshot ipython.png
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*** Settings ***
22
Suite Setup Wait for New Jupyter Server to be Ready
33
Suite Teardown Terminate All Jupyter Servers
4+
Force Tags classic
45
Library JupyterLibrary
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*** Settings ***
2+
Suite Setup Wait for New Jupyter Server to be Ready
3+
Suite Teardown Terminate All Jupyter Servers
4+
Force Tags jupyterlab
5+
Library JupyterLibrary

docs/KEYWORDS.ipynb

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
{
2727
"cell_type": "code",
28-
"execution_count": 6,
28+
"execution_count": 2,
2929
"metadata": {
3030
"jupyter": {
3131
"source_hidden": true
@@ -38,13 +38,21 @@
3838
},
3939
{
4040
"cell_type": "code",
41-
"execution_count": 7,
41+
"execution_count": 3,
4242
"metadata": {
4343
"jupyter": {
4444
"source_hidden": true
4545
}
4646
},
4747
"outputs": [
48+
{
49+
"name": "stderr",
50+
"output_type": "stream",
51+
"text": [
52+
"/home/weg/Documents/projects/robotframework-jupyterlibrary/envs/rfjl37/lib/python3.7/site-packages/IPython/core/display.py:689: UserWarning: Consider using IPython.display.IFrame instead\n",
53+
" warnings.warn(\"Consider using IPython.display.IFrame instead\")\n"
54+
]
55+
},
4856
{
4957
"data": {
5058
"text/html": [
@@ -54,7 +62,7 @@
5462
"<IPython.core.display.HTML object>"
5563
]
5664
},
57-
"execution_count": 7,
65+
"execution_count": 3,
5866
"metadata": {},
5967
"output_type": "execute_result"
6068
}
@@ -63,6 +71,41 @@
6371
"iframe(\"JupyterLibrary\")"
6472
]
6573
},
74+
{
75+
"cell_type": "markdown",
76+
"metadata": {},
77+
"source": [
78+
"## Jupyter Notebook Classic\n",
79+
"The Jupyter Notebook Classic keywords are themselves defined in `.robot` files, and are loaded dynamically. They all include _Notebook Classic_ in the keyword name."
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": 4,
85+
"metadata": {
86+
"jupyter": {
87+
"source_hidden": true
88+
}
89+
},
90+
"outputs": [
91+
{
92+
"data": {
93+
"text/html": [
94+
"<iframe src=\"_static/NotebookClassic.html\" id=\"NotebookClassic\" width=\"100%\"></iframe>"
95+
],
96+
"text/plain": [
97+
"<IPython.core.display.HTML object>"
98+
]
99+
},
100+
"execution_count": 4,
101+
"metadata": {},
102+
"output_type": "execute_result"
103+
}
104+
],
105+
"source": [
106+
"iframe(\"NotebookClassic\")"
107+
]
108+
},
66109
{
67110
"cell_type": "markdown",
68111
"metadata": {},

src/JupyterLibrary/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
RESOURCES = join(dirname(__file__), "resources")
12-
CLIENTS = ["JupyterLab"]
12+
CLIENTS = ["JupyterLab", "NotebookClassic"]
1313

1414

1515
class JupyterLibrary(SeleniumLibrary):
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*** Variables ***
2+
${JNC CSS TREE LIST} \#notebook_list
3+
${JNC CSS TREE NEW BUTTON} \#new-dropdown-button
4+
${JNC CSS TREE NEW MENU} \#new-menu
5+
${JNC CSS NB KERNEL ICON} \#kernel_indicator_icon
6+
${JNC CSS NB KERNEL IDLE} .kernel_idle_icon
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
*** Settings ***
2+
Resource JupyterLibrary/resources/NotebookClassic/Selectors.robot
3+
Documentation Keywords for working with the Jupyter Notebook Clasic web application
4+
... You should have already started a Jupyter Server, such as with
5+
... *Wait For New Jupyter Server To Be Ready*.
6+
7+
8+
*** Keywords ***
9+
Open Jupyter Notebook Classic
10+
[Arguments] ${browser}=headlessfirefox ${nbserver}=${None} ${url}=${EMPTY} &{configuration}
11+
[Documentation] Open Jupyter Notebook Classic, served from the given (or most-recently-started)
12+
... ``nbserver`` in a ``browser`` (or ``headlessfirefox``) or ``url``,
13+
... then wait for the splash screen.
14+
... Extra ``configuration`` is passed on to SeleniumLibrary's *Open Browser*.
15+
${nbserver_url} = Run Keyword If not "${url}" Get Jupyter Server URL ${nbserver}
16+
${token} = Run Keyword If not "${url}" Get Jupyter Server Token ${nbserver}
17+
${final_url} = Set Variable If "${url}" ${url} ${nbserver_url}tree?token=${token}
18+
Open Browser url=${final_url} browser=${browser} &{configuration}
19+
20+
Launch a new Jupyter Notebook Classic Notebook
21+
[Arguments] ${kernel}=Python 3
22+
[Documentation] Use the Jupyter Notebook Classic tree to launch a
23+
... Notebook with the given ``kernel``
24+
Click Element css:${JNC CSS TREE NEW BUTTON}
25+
Wait Until Page Contains Element css:${JNC CSS TREE NEW MENU}
26+
Click Element css:${JNC CSS TREE NEW MENU} a[title$="${kernel}"]
27+
Select Window NEW
28+
Wait Until Page Contains Element css:${JNC CSS NB KERNEL ICON}${JNC CSS NB KERNEL IDLE}

0 commit comments

Comments
 (0)