Merge pull request #4101 from dubielt1/test-kernel-menu
Translated kernel menu javascript test to seleniumpull/5043/head
commit
9640e1f943
@ -1,44 +0,0 @@
|
||||
|
||||
casper.notebook_test(function () {
|
||||
var that = this;
|
||||
|
||||
var menuItems = ['#restart_kernel', '#restart_clear_output', '#restart_run_all', '#shutdown_kernel']
|
||||
var cancelSelector = ".modal-footer button:first-of-type"
|
||||
|
||||
menuItems.forEach( function(selector) {
|
||||
that.thenClick(selector);
|
||||
that.waitForSelector(cancelSelector);
|
||||
that.thenClick(cancelSelector);
|
||||
|
||||
that.waitWhileSelector(".modal-content", function() {
|
||||
that.test.assert(true, selector + " confirmation modal pops up and is cancelable");
|
||||
});
|
||||
});
|
||||
|
||||
var shutdownSelector = menuItems.pop();
|
||||
var confirmSelector = ".modal-footer .btn-danger"
|
||||
|
||||
menuItems.forEach( function(selector) {
|
||||
that.thenClick(shutdownSelector);
|
||||
that.waitForSelector(confirmSelector);
|
||||
that.thenClick(confirmSelector);
|
||||
|
||||
// wait for shutdown to go through
|
||||
that.waitFor(function() { return this.evaluate(function() {
|
||||
return IPython.notebook.kernel.is_connected() === false;
|
||||
})});
|
||||
|
||||
// Click on one of the restarts
|
||||
that.thenClick(selector);
|
||||
|
||||
// Kernel should get connected, no need for confirmation.
|
||||
that.waitFor(function() { return this.evaluate(function() {
|
||||
return IPython.notebook.kernel.is_connected() === true;
|
||||
})});
|
||||
that.then(function() {
|
||||
that.test.assert(true, "no confirmation for " + selector + " after session shutdown")
|
||||
})
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@ -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
|
||||
)
|
||||
Loading…
Reference in new issue