Skip to content
Merged
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
4 changes: 2 additions & 2 deletions notebook/templates/notebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@
</li>
</ul>
</li>
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">{% trans %}Kernel{% endtrans %}</a>
<ul id="kernel_menu" class="dropdown-menu">
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown" id="kernellink">{% trans %}Kernel{% endtrans %}</a>
<ul id="kernel_menu" class="dropdown-menu" aria-labelledby="kernellink">
<li id="int_kernel"
title="{% trans %}Send Keyboard Interrupt (CTRL-C) to the Kernel{% endtrans %}">
<a href="#">{% trans %}Interrupt{% endtrans %}</a>
Expand Down
44 changes: 0 additions & 44 deletions notebook/tests/notebook/kernel_menu.js

This file was deleted.

4 changes: 3 additions & 1 deletion notebook/tests/selenium/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,6 @@ def authenticated_browser(selenium_driver, notebook_server):

@pytest.fixture
def notebook(authenticated_browser):
return Notebook.new_notebook(authenticated_browser)
tree_wh = authenticated_browser.current_window_handle
yield Notebook.new_notebook(authenticated_browser)
authenticated_browser.switch_to.window(tree_wh)
60 changes: 60 additions & 0 deletions notebook/tests/selenium/test_kernel_menu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from notebook.tests.selenium.utils import wait_for_selector

restart_selectors = [
'#restart_kernel', '#restart_clear_output', '#restart_run_all'
]
notify_interaction = '#notification_kernel > span'

shutdown_selector = '#shutdown_kernel'
confirm_selector = '.btn-danger'
cancel_selector = ".modal-footer button:first-of-type"


def test_cancel_restart_or_shutdown(notebook):
"""Click each of the restart options, then cancel the confirmation dialog"""
browser = notebook.browser
kernel_menu = browser.find_element_by_id('kernellink')

for menu_item in restart_selectors + [shutdown_selector]:
kernel_menu.click()
wait_for_selector(browser, menu_item, visible=True, single=True).click()
wait_for_selector(browser, cancel_selector, visible=True, single=True).click()
WebDriverWait(browser, 3).until(
EC.invisibility_of_element((By.CSS_SELECTOR, '.modal-backdrop'))
)
assert notebook.is_kernel_running()


def test_menu_items(notebook):
browser = notebook.browser
kernel_menu = browser.find_element_by_id('kernellink')

for menu_item in restart_selectors:
# Shutdown
kernel_menu.click()
wait_for_selector(browser, shutdown_selector, visible=True, single=True).click()

# Confirm shutdown
wait_for_selector(browser, confirm_selector, visible=True, single=True).click()

WebDriverWait(browser, 3).until(
lambda b: not notebook.is_kernel_running(),
message="Kernel did not shut down as expected"
)

# Restart
# Selenium can't click the menu while a modal dialog is fading out
WebDriverWait(browser, 3).until(
EC.invisibility_of_element((By.CSS_SELECTOR, '.modal-backdrop'))
)
kernel_menu.click()

wait_for_selector(browser, menu_item, visible=True, single=True).click()
WebDriverWait(browser, 10).until(
lambda b: notebook.is_kernel_running(),
message="Restart (%r) after shutdown did not start kernel" % menu_item
)