Fix checking if kernel is running through Selenium

Avoid error "Jupyter.notebook.kernel is null"
This commit is contained in:
Thomas Kluyver 2019-10-18 15:12:52 +01:00
parent ed96937401
commit fb2286585c

View File

@ -300,7 +300,9 @@ class Notebook:
trigger_keystrokes(self.body, keys)
def is_kernel_running(self):
return self.browser.execute_script("return Jupyter.notebook.kernel.is_connected()")
return self.browser.execute_script(
"return Jupyter.notebook.kernel && Jupyter.notebook.kernel.is_connected()"
)
@classmethod
def new_notebook(cls, browser, kernel_name='kernel-python3'):
@ -455,4 +457,3 @@ def validate_dualmode_state(notebook, mode, index):
assert is_focused_on(index) #The specified cell is focused
assert is_only_cell_edit(index) #The specified cell is the only one in edit mode