Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keywords for working with multiple open notebook tabs #47

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
13 changes: 13 additions & 0 deletions src/JupyterLibrary/clients/jupyterlab/Output.resource
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,16 @@ Screenshot Each Output Of Active JupyterLab Document
Screenshot Each Output Of Active JupyterLab Cell ${prefix}_cell_${i}
Screenshot Markdown Of Active JupyterLab Cell ${prefix}_cell_${i}
END

Wait Until JupyterLab Code Cell Is Idle
[Documentation] Waits until the given cell in a specific JL tab no longer has an active prompt "[*]:".
... The cell index starts from 1 and you must count empty and markdown cells too.
[Arguments] ${tab_id_to_wait} ${cell_n} ${timeout}=30
Copy link
Collaborator

Choose a reason for hiding this comment

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

please include the unit, e.g 30s

Copy link
Collaborator

Choose a reason for hiding this comment

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

some default of cell_n (e.g. the last) might be helpful.

Wait Until Element Is Not Visible xpath=//div[@aria-labelledby="${tab_id_to_wait}"]/${JLAB XP NOTEBOOK CONTENT}/div[${cell_n}]/${JLAB XP CELL INPUT STATUS ICON} ${timeout}
Copy link
Collaborator

Choose a reason for hiding this comment

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

for consistency, first argument should problaby start with xpath: rather than xpath=


Get A JupyterLab Code Cell Output In a Given Tab
[Documentation] It returns the output of a given cell in a specific JL tab.
... The cell index starts from 1 and you must count empty and markdown cells too.
[Arguments] ${tab_id_to_read} ${cell_n}
${output_children}= Get Web Elements xpath=//div[@aria-labelledby="${tab_id_to_read}"]/${JLAB XP NOTEBOOK CONTENT}/div[${cell_n}]/${JLAB XP CELL OUTPUT GENERIC}
[Return] ${output_children}
13 changes: 12 additions & 1 deletion src/JupyterLibrary/clients/jupyterlab/Selectors.resource
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,16 @@ ${JLAB XP NB TOOLBAR} //div${JLAB XP NB TOOLBAR FRAG}
${JLAB XP BUSY KERNEL} //*[local-name() = 'div' and contains(@class, 'jp-FilledCircleIcon' or (local-name() = 'svg' and contains(@data-icon, 'ui-components:circle-filled')))]
# dock panel
${JLAB XP DOCK PANEL} //*[@id = 'jp-main-dock-panel']
${JLAB XP DOCK TAB} ${JLAB XP DOCK PANEL}//ul[contains(@class, 'p-TabBar-content')]/li[contains(@class, 'p-TabBar-tab')]
${JLAB XP DOCK TABBAR CONTENT} ${JLAB XP DOCK PANEL}//ul[contains(@class, 'p-TabBar-content')]
${JLAB XP DOCK TAB} ${JLAB XP DOCK TABBAR CONTENT}/li[contains(@class, 'p-TabBar-tab')]
${JLAB XP DOCK TAB LABEL} ${JLAB XP DOCK TAB}/div[contains(@class, 'p-TabBar-tabLabel')]
${JLAB XP DOCK TAB SELECTED} ${JLAB XP DOCK TABBAR CONTENT}/li[contains(@class,"lm-mod-current p-mod-current")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

please just use p-mod-current (the lm-mod-current ones won't work with lab 1)

# notebook
${JLAB XP CELL INPUT AREA} div[contains(@class, "p-Cell-inputWrapper")]/div[contains(@class,"jp-Cell-inputArea")]
${JLAB XP CELL INPUT STATUS ICON} ${JLAB XP CELL INPUT AREA}/div[contains(@class,"jp-InputArea-prompt") and (.="[*]:")]
${JLAB XP CELL OUTPUT AREA} div[contains(@class, "jp-Cell-outputWrapper")]/div[contains(@class,"jp-Cell-outputArea")]
${JLAB XP CELL OUTPUT TEXT} ${JLAB XP CELL OUTPUT AREA}//div[contains(@class,"jp-RenderedText")]
${JLAB XP CELL OUTPUT GENERIC} ${JLAB XP CELL OUTPUT AREA}//div[contains(@class,"jp-Rendered")]
${JLAB XP NOTEBOOK CONTENT} div[contains(@class, "jp-NotebookPanel-notebook")]


12 changes: 12 additions & 0 deletions src/JupyterLibrary/clients/jupyterlab/Shell.resource
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,15 @@ Close JupyterLab Dock Panel Tab
[Arguments] ${label} ${n}=1
${tab} = Get JupyterLab Dock Panel Tab ${label} ${n}
Click Element ${tab.find_element_by_xpath('./div[last()]')}

Get Selected JupyterLab Dock Panel Tab
[Documentation] Return the web element of selected notebook tab and its tab id
... It can be handful when working with more than one notebook file at time.
${selected_nb_tab} = Get WebElement xpath:${JLAB XP DOCK TAB SELECTED}
${tab_id} = Get Element Attribute ${selected_nb_tab} id
[Return] ${selected_nb_tab} ${tab_id}

Select JupyterLab Dock Panel Tab By FilePath
[Documentation] Select a notebook tab by filepath.
[Arguments] ${filepath}
Click Element xpath:${JLAB XP DOCK TABBAR CONTENT}/li[contains(@title, "${filepath}")]