diff --git a/nbclassic/tests/end_to_end/test_save.py b/nbclassic/tests/end_to_end/test_save.py index 29c8d32af..0a34781fd 100644 --- a/nbclassic/tests/end_to_end/test_save.py +++ b/nbclassic/tests/end_to_end/test_save.py @@ -45,7 +45,7 @@ def test_save(notebook_frontend): checkpoints = notebook_frontend.evaluate("() => Jupyter.notebook.checkpoints", page=EDITOR_PAGE) assert len(checkpoints) == 1 - notebook_frontend.try_click_selector('#ipython_notebook a', page=EDITOR_PAGE) + notebook_frontend.try_click_selector('#ipython_notebook', page=EDITOR_PAGE) notebook_frontend.wait_for_selector('.item_link', page=EDITOR_PAGE) hrefs_nonmatch = [] diff --git a/nbclassic/tests/end_to_end/test_save_as_notebook.py b/nbclassic/tests/end_to_end/test_save_as_notebook.py index f90787812..6f4d775bb 100644 --- a/nbclassic/tests/end_to_end/test_save_as_notebook.py +++ b/nbclassic/tests/end_to_end/test_save_as_notebook.py @@ -21,7 +21,7 @@ def set_notebook_name(nb, name): def test_save_notebook_as(notebook_frontend): set_notebook_name(notebook_frontend, name="nb1.ipynb") - notebook_frontend.locate('#notebook_name', page=EDITOR_PAGE) + notebook_frontend.wait_for_selector('#notebook_name', page=EDITOR_PAGE) assert get_notebook_name(notebook_frontend) == "nb1.ipynb" @@ -30,13 +30,18 @@ def test_save_notebook_as(notebook_frontend): notebook_frontend.wait_for_selector('.save-message', page=EDITOR_PAGE) # TODO: Add a function for locator assertions to FrontendElement - locator_element = notebook_frontend.locate_and_focus('//input[@data-testid="save-as"]', page=EDITOR_PAGE) - locator_element.wait_for('visible') + dialog_element = notebook_frontend.locate_and_focus(".modal-footer", page=EDITOR_PAGE) + save_element = dialog_element.locate('text=Save') + save_element.wait_for('visible') - notebook_frontend.insert_text('new_notebook.ipynb', page=EDITOR_PAGE) - notebook_frontend.try_click_selector('//html//body//div[8]//div//div//div[3]//button[2]', page=EDITOR_PAGE) - - locator_element.expect_not_to_be_visible() + name_input_element = notebook_frontend.locate('.modal-body', page=EDITOR_PAGE).locate('.form-control') + name_input_element.click() + + name_input_element.evaluate(f'(elem) => {{ elem.value = "new_notebook.ipynb"; return elem.value; }}') + # notebook_frontend.insert_text('new_notebook.ipynb', page=EDITOR_PAGE) + save_element.click() + + save_element.expect_not_to_be_visible() assert get_notebook_name(notebook_frontend) == "new_notebook.ipynb" assert "new_notebook.ipynb" in notebook_frontend.get_page_url(page=EDITOR_PAGE) diff --git a/nbclassic/tests/end_to_end/test_save_readonly_as.py b/nbclassic/tests/end_to_end/test_save_readonly_as.py index 6b6bde96d..2c9d3ae4d 100644 --- a/nbclassic/tests/end_to_end/test_save_readonly_as.py +++ b/nbclassic/tests/end_to_end/test_save_readonly_as.py @@ -30,24 +30,31 @@ def test_save_readonly_as(notebook_frontend): # Wait for Save As modal, save save_as(notebook_frontend) - # Wait for modal to pop up - notebook_frontend.wait_for_selector('//input[@data-testid="save-as"]', page=EDITOR_PAGE) + # # Wait for modal to pop up + # notebook_frontend.wait_for_selector('//input[@data-testid="save-as"]', page=EDITOR_PAGE) # TODO: Add a function for locator assertions to FrontendElement - locator_element = notebook_frontend.locate_and_focus('//input[@data-testid="save-as"]', page=EDITOR_PAGE) - locator_element.wait_for('visible') + dialog_element = notebook_frontend.wait_for_selector(".modal-footer", page=EDITOR_PAGE) + dialog_element.focus() + save_element = dialog_element.locate('text=Save') + save_element.wait_for('visible') + # locator_element = notebook_frontend.locate_and_focus('//input[@data-testid="save-as"]', page=EDITOR_PAGE) + # locator_element.wait_for('visible') + + name_input_element = notebook_frontend.wait_for_selector('.modal-body .form-control', page=EDITOR_PAGE) + name_input_element.focus() + name_input_element.click() + print('::::NAME1') + print(name_input_element.evaluate(f'(elem) => {{ return elem.value; }}')) + name_input_element.evaluate(f'(elem) => {{ elem.value = "new_notebook.ipynb"; return elem.value; }}') + print('::::NAME2') + print(name_input_element.evaluate(f'(elem) => {{ return elem.value; }}')) + # notebook_frontend.insert_text('new_notebook.ipynb', page=EDITOR_PAGE) + + save_element.wait_for('visible') + save_element.focus() + save_element.click() - modal_footer = notebook_frontend.locate('.modal-footer', page=EDITOR_PAGE) - modal_footer.wait_for('visible') - - notebook_frontend.insert_text('new_notebook.ipynb', page=EDITOR_PAGE) - - save_btn = modal_footer.locate('text=Save') - save_btn.wait_for('visible') - save_btn.click() - # notebook_frontend.try_click_selector('//html//body//div[8]//div//div//div[3]//button[2]', page=EDITOR_PAGE) - - # locator_element.expect_not_to_be_visible() notebook_frontend.wait_for_condition( lambda: get_notebook_name(notebook_frontend) == "new_notebook.ipynb", timeout=120, period=5 )