You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This keyword checks for a jupyterlab modal using a css selector, and, if found, tries clicking a button (the first one).
The problem seems to be that the selector returns an element every time, even when there's no modal open in the JL UI. In fact, using the dev console, I get two hits with that selector all the time.
The keyword does work when there's a modal/prompt open, but it will also fail whenever it is called and no prompt is available.
I believe that changing the selector from the css based one to an xpath one would solve this issue. Specifically, reworking the keyword like this is currently working fine for me:
[Documentation] Click the save button in a JupyterLab dialog (if one is open).
${accept} = Get WebElements xpath://div[contains(concat(' ',normalize-space(@class),' '),' jp-Dialog-footer ')]
Run Keyword If ${accept} Click Element ${accept[-1]}
Note that I also changed from accept[0] to accept[-1], since the last button is usually the confirmation one (e.g. saving a file when closing it has three buttons, Dismiss, Cancel and Save in that order).
If you agree that the behaviour of the keyword is currently not working as expected I can open a PR to merge my changes.
The text was updated successfully, but these errors were encountered:
I've modified the keyword further in my own workflow, let me know if this is something that you'd be interested in merging in the library itself:
*** Variables ***
${JL_TABBAR_CONTENT_XPATH} = //div[contains(@class,"lm-DockPanel-tabBar")]/ul[@class="lm-TabBar-content p-TabBar-content"]
${JL_TABBAR_SELECTED_XPATH} = ${JL_TABBAR_CONTENT_XPATH}/li[contains(@class,"lm-mod-current p-mod-current")]
${JL_TABBAR_NOT_SELECTED_XPATH} = ${JL_TABBAR_CONTENT_XPATH}/li[not(contains(@class,"lm-mod-current p-mod-current"))]
Maybe Close Popup
[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
# Sometimes there are multiple tabs already open when logging into the server and each one might
# Open a pop-up. Closing all tabs at once also 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://div[contains(concat(' ',normalize-space(@class),' '),' jp-Dialog-footer ')]
# Click the right most button of the popup
Run Keyword If ${accept} Click Element xpath://div[contains(concat(' ',normalize-space(@class),' '),' jp-Dialog-footer ')]/button[last()]
Capture Page Screenshot
END
This keyword checks for a jupyterlab modal using a css selector, and, if found, tries clicking a button (the first one).
The problem seems to be that the selector returns an element every time, even when there's no modal open in the JL UI. In fact, using the dev console, I get two hits with that selector all the time.
The keyword does work when there's a modal/prompt open, but it will also fail whenever it is called and no prompt is available.
I believe that changing the selector from the css based one to an xpath one would solve this issue. Specifically, reworking the keyword like this is currently working fine for me:
Note that I also changed from accept[0] to accept[-1], since the last button is usually the confirmation one (e.g. saving a file when closing it has three buttons, Dismiss, Cancel and Save in that order).
If you agree that the behaviour of the keyword is currently not working as expected I can open a PR to merge my changes.
The text was updated successfully, but these errors were encountered: