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

Possible bug in Maybe Accept a JupyterLab Prompt keyword #44

Open
lugi0 opened this issue Nov 10, 2021 · 1 comment
Open

Possible bug in Maybe Accept a JupyterLab Prompt keyword #44

lugi0 opened this issue Nov 10, 2021 · 1 comment

Comments

@lugi0
Copy link
Contributor

lugi0 commented Nov 10, 2021

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.

@lugi0
Copy link
Contributor Author

lugi0 commented Nov 12, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant