From 4b0d3be8dd131b9e1934262e9cfec16ee5cb40e8 Mon Sep 17 00:00:00 2001 From: Luca Giorgi Date: Thu, 23 Dec 2021 17:39:52 +0100 Subject: [PATCH 1/5] Better popup handling Signed-off-by: Luca Giorgi --- .../clients/jupyterlab/Selectors.resource | 3 +++ .../clients/jupyterlab/Shell.resource | 18 +++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/JupyterLibrary/clients/jupyterlab/Selectors.resource b/src/JupyterLibrary/clients/jupyterlab/Selectors.resource index 006458ce..a9b6b36a 100644 --- a/src/JupyterLibrary/clients/jupyterlab/Selectors.resource +++ b/src/JupyterLibrary/clients/jupyterlab/Selectors.resource @@ -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')] diff --git a/src/JupyterLibrary/clients/jupyterlab/Shell.resource b/src/JupyterLibrary/clients/jupyterlab/Shell.resource index 8b9488f5..6a98d3d6 100644 --- a/src/JupyterLibrary/clients/jupyterlab/Shell.resource +++ b/src/JupyterLibrary/clients/jupyterlab/Shell.resource @@ -61,9 +61,21 @@ 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). + ### TODO ### + # Check if the last button is always the confirmation one + # Server unavailable or unreachable modal has "Dismiss" as last button + + # 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()] + END Get JupyterLab Dock Panel Tab [Documentation] Get the ``n`` -th JupyterLab Dock Panel Tab with ``label`` as a ``WebElement``. From a208424fa117586a69feecb4d0ee3e470892477f Mon Sep 17 00:00:00 2001 From: Luca Giorgi Date: Thu, 23 Dec 2021 17:46:13 +0100 Subject: [PATCH 2/5] Fix spacing Signed-off-by: Luca Giorgi --- src/JupyterLibrary/clients/jupyterlab/Shell.resource | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JupyterLibrary/clients/jupyterlab/Shell.resource b/src/JupyterLibrary/clients/jupyterlab/Shell.resource index 6a98d3d6..89933486 100644 --- a/src/JupyterLibrary/clients/jupyterlab/Shell.resource +++ b/src/JupyterLibrary/clients/jupyterlab/Shell.resource @@ -68,8 +68,8 @@ Maybe Accept A JupyterLab Prompt # 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} + ${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} From ca38badee7be4ceb15c8e0220ffd87aac66b0075 Mon Sep 17 00:00:00 2001 From: Luca Giorgi Date: Thu, 23 Dec 2021 17:56:30 +0100 Subject: [PATCH 3/5] Remove TODO comment Signed-off-by: Luca Giorgi --- src/JupyterLibrary/clients/jupyterlab/Shell.resource | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/JupyterLibrary/clients/jupyterlab/Shell.resource b/src/JupyterLibrary/clients/jupyterlab/Shell.resource index 89933486..8d8749a6 100644 --- a/src/JupyterLibrary/clients/jupyterlab/Shell.resource +++ b/src/JupyterLibrary/clients/jupyterlab/Shell.resource @@ -62,10 +62,6 @@ Open With JupyterLab Menu Maybe Accept A JupyterLab Prompt [Documentation] Click the last button in a JupyterLab dialog (if one is open). - ### TODO ### - # Check if the last button is always the confirmation one - # Server unavailable or unreachable modal has "Dismiss" as last button - # 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} From 7e0ae3da30cfee35b2e79fffecfcea65a6bb1ed4 Mon Sep 17 00:00:00 2001 From: Luca Giorgi Date: Mon, 3 Jan 2022 12:29:22 +0100 Subject: [PATCH 4/5] Fix selector names and classes, split looping keyword Signed-off-by: Luca Giorgi --- .../clients/jupyterlab/Selectors.resource | 6 ++-- .../clients/jupyterlab/Shell.resource | 28 +++++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/JupyterLibrary/clients/jupyterlab/Selectors.resource b/src/JupyterLibrary/clients/jupyterlab/Selectors.resource index a9b6b36a..fcaf7f66 100644 --- a/src/JupyterLibrary/clients/jupyterlab/Selectors.resource +++ b/src/JupyterLibrary/clients/jupyterlab/Selectors.resource @@ -38,9 +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 ')] +${JLAB XP CONTENT XPATH} //div[contains(@class,"p-DockPanel-tabBar")]/ul[@class="p-TabBar-content"] +${JLAB XP NOT SELECTED XPATH} ${JLAB XP CONTENT XPATH}/li[not(contains(@class,"p-mod-current"))] +${JLAB 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')] diff --git a/src/JupyterLibrary/clients/jupyterlab/Shell.resource b/src/JupyterLibrary/clients/jupyterlab/Shell.resource index 8d8749a6..d80ea29d 100644 --- a/src/JupyterLibrary/clients/jupyterlab/Shell.resource +++ b/src/JupyterLibrary/clients/jupyterlab/Shell.resource @@ -62,16 +62,26 @@ Open With JupyterLab Menu Maybe Accept A JupyterLab Prompt [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()] + ${accept} = Get WebElements xpath:${JLAB POPUP} + ${len} = Get Length ${accept} + # Click the right most button of the popup + Run Keyword If ${accept} Click Element xpath:${JLAB POPUP}/button[last()] + [Return] ${len} + +Maybe Accept All JupyterLab Prompts + [Documentation] Try accepting all JL popups. + #${jl_tabs} = Get WebElements xpath:${JLAB XP NOT SELECTED XPATH} + #${len} = Get Length ${jl_tabs} + ${total} = ${0} + FOR ${i} IN RANGE 9999999 + ${closed} = Maybe Accept A JupyterLab Prompt + ${total} = ${total}+${closed} + Exit For Loop If ${closed}==0 END + [Return] ${total} + #FOR ${index} IN RANGE 0 2+${len} + # Maybe Accept A JupyterLab Prompt + #END Get JupyterLab Dock Panel Tab [Documentation] Get the ``n`` -th JupyterLab Dock Panel Tab with ``label`` as a ``WebElement``. From 4a3261d15957dc843afa153ac298f799eb565112 Mon Sep 17 00:00:00 2001 From: Luca Giorgi Date: Mon, 3 Jan 2022 12:34:52 +0100 Subject: [PATCH 5/5] Fix formatting Signed-off-by: Luca Giorgi --- src/JupyterLibrary/clients/jupyterlab/Shell.resource | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/JupyterLibrary/clients/jupyterlab/Shell.resource b/src/JupyterLibrary/clients/jupyterlab/Shell.resource index d80ea29d..53b9d105 100644 --- a/src/JupyterLibrary/clients/jupyterlab/Shell.resource +++ b/src/JupyterLibrary/clients/jupyterlab/Shell.resource @@ -70,18 +70,13 @@ Maybe Accept A JupyterLab Prompt Maybe Accept All JupyterLab Prompts [Documentation] Try accepting all JL popups. - #${jl_tabs} = Get WebElements xpath:${JLAB XP NOT SELECTED XPATH} - #${len} = Get Length ${jl_tabs} - ${total} = ${0} + ${total} = Set Variable ${0} FOR ${i} IN RANGE 9999999 ${closed} = Maybe Accept A JupyterLab Prompt ${total} = ${total}+${closed} Exit For Loop If ${closed}==0 END [Return] ${total} - #FOR ${index} IN RANGE 0 2+${len} - # Maybe Accept A JupyterLab Prompt - #END Get JupyterLab Dock Panel Tab [Documentation] Get the ``n`` -th JupyterLab Dock Panel Tab with ``label`` as a ``WebElement``.