Skip to content

Commit

Permalink
create new_notebook classmethod creating/switching to new Notebook page
Browse files Browse the repository at this point in the history
  • Loading branch information
mpacer committed Mar 23, 2018
1 parent a112ab6 commit ebef7ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
13 changes: 1 addition & 12 deletions notebook/tests/selenium/test_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,7 @@

@pytest.fixture(scope='module')
def notebook(authenticated_browser):
b = authenticated_browser
new_button = b.find_element_by_id('new-buttons')
new_button.click()
kernel_selector = '#kernel-python3 a'
kernel_list = wait_for_selector(b, kernel_selector)
kernel_list[0].click()
window_handle_list = b.window_handles
window_handle_list.remove(b.current_window_handle)
b.switch_to_window(window_handle_list[0])
kernel_list = wait_for_selector(b, ".cell")
b.execute_script("Jupyter.notebook.set_autosave_interval(0)")
return Notebook(b)
return Notebook.new_notebook(authenticated_browser)


def test_markdown_cell(notebook):
Expand Down
9 changes: 9 additions & 0 deletions notebook/tests/selenium/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ def add_markdown_cell(self, index=-1, content="", render=True):
self.add_cell(index, cell_type="markdown")
self.edit_cell(index=index, content=content, render=render)


@classmethod
def new_notebook(cls, browser, kernel_name='kernel-python3'):
# initial_window_handles = browser.window_handles
with new_window(browser, selector=".cell"):
select_kernel(browser, kernel_name=kernel_name)
browser.execute_script("Jupyter.notebook.set_autosave_interval(0)")
return cls(browser)


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

0 comments on commit ebef7ba

Please sign in to comment.