mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-24 12:05:22 +08:00
enrich signature for execute_cell to accept both index and cell directly
This commit is contained in:
parent
3571f1604f
commit
e183fc1627
@ -140,9 +140,15 @@ class Notebook:
|
||||
self.current_cell.send_keys(Keys.ENTER, "\n")
|
||||
self.current_cell.send_keys(Keys.ENTER, line)
|
||||
if render:
|
||||
|
||||
def execute_cell(self, index=0):
|
||||
self.execute_cell(self.current_index)
|
||||
|
||||
def execute_cell(self, cell_or_index = None):
|
||||
if isinstance(cell_or_index, int):
|
||||
index = cell_or_index
|
||||
elif isinstance(cell_or_index, WebElement):
|
||||
index = self[cell_or_index]
|
||||
else:
|
||||
raise TypeError("execute_cell only accepts a WebElement or an int")
|
||||
self.focus_cell(index)
|
||||
self.current_cell.send_keys(Keys.CONTROL, Keys.ENTER)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user