Skip to content

Improve popup handling #53

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions src/JupyterLibrary/clients/jupyterlab/Selectors.resource
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ ${JLAB XP NB FRAG} ${JLAB XP MAIN AREA FRAG}\[contains(@cla
${JLAB XP NB TOOLBAR FRAG} [contains(@class, 'jp-NotebookPanel-toolbar')]
${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')))]
${JL_TABBAR_CONTENT_XPATH} //div[contains(@class,"lm-DockPanel-tabBar")]/ul[@class="lm-TabBar-content p-TabBar-content"]
${JL_TABBAR_NOT_SELECTED_XPATH} ${JL_TABBAR_CONTENT_XPATH}/li[not(contains(@class,"lm-mod-current p-mod-current"))]
${JL_POPUP} //div[contains(concat(' ',normalize-space(@class),' '),' jp-Dialog-footer ')]
# 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')]
Expand Down
14 changes: 11 additions & 3 deletions src/JupyterLibrary/clients/jupyterlab/Shell.resource
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@ Open With JupyterLab Menu
END

Maybe Accept A JupyterLab Prompt
[Documentation] Click the accept button in a JupyterLab dialog (if one is open).
${accept} = Get WebElements css:${JLAB CSS ACCEPT}
Run Keyword If ${accept} Click Element ${accept[0]}
[Documentation] Click the last button in a JupyterLab dialog (if one is open).
# Closing all tabs at once might create a pop-up for each tab. Let's get the
# Number of open tabs and try closing popups for each one.
${jl_tabs} = Get WebElements xpath:${JL_TABBAR_NOT_SELECTED_XPATH}
${len} = Get Length ${jl_tabs}
FOR ${index} IN RANGE 0 2+${len}
# Check if a popup exists
${accept} = Get WebElements xpath:${JL_POPUP}
# Click the right most button of the popup
Run Keyword If ${accept} Click Element xpath:${JL_POPUP}/button[last()]
Copy link
Collaborator

Choose a reason for hiding this comment

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

the ordering of buttons is not as indicative as their semantic classes. the "blue" one should have the jp-mod-accept or whatever.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not enough to correctly identify the button we want to use. As an example, the popup for saving changes to a file has the jp-mod-accept class on both the Discard and Save buttons.
accept

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have kept using the position of the button for now, since that is consistent in all cases I've seen. Perhaps we should raise a bug to jupyter for the usage of jp-mod-accept?

END

Get JupyterLab Dock Panel Tab
[Documentation] Get the ``n`` -th JupyterLab Dock Panel Tab with ``label`` as a ``WebElement``.
Expand Down