Skip to content

Commit ebef7ba

Browse files
committed
create new_notebook classmethod creating/switching to new Notebook page
1 parent a112ab6 commit ebef7ba

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

notebook/tests/selenium/test_markdown.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,7 @@
1010

1111
@pytest.fixture(scope='module')
1212
def notebook(authenticated_browser):
13-
b = authenticated_browser
14-
new_button = b.find_element_by_id('new-buttons')
15-
new_button.click()
16-
kernel_selector = '#kernel-python3 a'
17-
kernel_list = wait_for_selector(b, kernel_selector)
18-
kernel_list[0].click()
19-
window_handle_list = b.window_handles
20-
window_handle_list.remove(b.current_window_handle)
21-
b.switch_to_window(window_handle_list[0])
22-
kernel_list = wait_for_selector(b, ".cell")
23-
b.execute_script("Jupyter.notebook.set_autosave_interval(0)")
24-
return Notebook(b)
13+
return Notebook.new_notebook(authenticated_browser)
2514

2615

2716
def test_markdown_cell(notebook):

notebook/tests/selenium/utils.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,15 @@ def add_markdown_cell(self, index=-1, content="", render=True):
130130
self.add_cell(index, cell_type="markdown")
131131
self.edit_cell(index=index, content=content, render=render)
132132

133+
134+
@classmethod
135+
def new_notebook(cls, browser, kernel_name='kernel-python3'):
136+
# initial_window_handles = browser.window_handles
137+
with new_window(browser, selector=".cell"):
138+
select_kernel(browser, kernel_name=kernel_name)
139+
browser.execute_script("Jupyter.notebook.set_autosave_interval(0)")
140+
return cls(browser)
141+
133142

134143
def select_kernel(browser, kernel_name='kernel-python3'):
135144
"""Clicks the "new" button and selects a kernel from the options.

0 commit comments

Comments
 (0)