From 38653d8cd220364ac7e617005545eac9c0d947e5 Mon Sep 17 00:00:00 2001 From: Eric Gentry Date: Thu, 19 Jan 2023 09:32:30 -0500 Subject: [PATCH 1/5] Modified selector --- nbclassic/tests/end_to_end/test_save.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 = [] From 4624eae30bdbfc3c943d5f3aa3592d926017e313 Mon Sep 17 00:00:00 2001 From: Eric Gentry Date: Thu, 19 Jan 2023 10:03:05 -0500 Subject: [PATCH 2/5] Modified save button selectors --- nbclassic/tests/end_to_end/test_save_as_notebook.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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..63a53dc20 100644 --- a/nbclassic/tests/end_to_end/test_save_as_notebook.py +++ b/nbclassic/tests/end_to_end/test_save_as_notebook.py @@ -30,12 +30,13 @@ 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) + dialog_element = notebook_frontend.locate_and_focus(".modal-footer", page=EDITOR_PAGE) + locator_element = dialog_element.locate('text=Save') locator_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.click() + locator_element.expect_not_to_be_visible() assert get_notebook_name(notebook_frontend) == "new_notebook.ipynb" From 7bc88764c258e200274f7253ae3cfac491cf5260 Mon Sep 17 00:00:00 2001 From: Eric Gentry Date: Thu, 19 Jan 2023 13:12:52 -0500 Subject: [PATCH 3/5] Modified selectors and test method. --- nbclassic/tests/end_to_end/test_save_as_notebook.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 63a53dc20..e35d1e0c6 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" @@ -31,13 +31,16 @@ def test_save_notebook_as(notebook_frontend): # TODO: Add a function for locator assertions to FrontendElement dialog_element = notebook_frontend.locate_and_focus(".modal-footer", page=EDITOR_PAGE) - locator_element = dialog_element.locate('text=Save') - locator_element.wait_for('visible') + save_element = dialog_element.locate('text=Save') + save_element.wait_for('visible') + + name_input_element = notebook_frontend.locate('.modal-body', page=EDITOR_PAGE).locate('.form-control') + name_input_element.click() notebook_frontend.insert_text('new_notebook.ipynb', page=EDITOR_PAGE) - locator_element.click() + save_element.click() - locator_element.expect_not_to_be_visible() + 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) From ace0c6d94e8803675058aaf84c51c486a39844b1 Mon Sep 17 00:00:00 2001 From: Eric Gentry Date: Thu, 19 Jan 2023 14:01:19 -0500 Subject: [PATCH 4/5] Modified input value modification, test method. --- .../tests/end_to_end/test_save_as_notebook.py | 3 ++- .../tests/end_to_end/test_save_readonly_as.py | 16 ++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) 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 e35d1e0c6..6f4d775bb 100644 --- a/nbclassic/tests/end_to_end/test_save_as_notebook.py +++ b/nbclassic/tests/end_to_end/test_save_as_notebook.py @@ -37,7 +37,8 @@ def test_save_notebook_as(notebook_frontend): name_input_element = notebook_frontend.locate('.modal-body', page=EDITOR_PAGE).locate('.form-control') name_input_element.click() - notebook_frontend.insert_text('new_notebook.ipynb', page=EDITOR_PAGE) + 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() 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..df302fdfb 100644 --- a/nbclassic/tests/end_to_end/test_save_readonly_as.py +++ b/nbclassic/tests/end_to_end/test_save_readonly_as.py @@ -34,20 +34,24 @@ def test_save_readonly_as(notebook_frontend): 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.locate_and_focus(".modal-footer", page=EDITOR_PAGE) + 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') 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) + + 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_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 ) From e71ee5d0691b05873c6448f44b0cdeda4c3402b6 Mon Sep 17 00:00:00 2001 From: Eric Gentry Date: Mon, 23 Jan 2023 10:19:05 -0500 Subject: [PATCH 5/5] Test method tweaks. --- .../tests/end_to_end/test_save_readonly_as.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) 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 df302fdfb..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,27 +30,30 @@ 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 - dialog_element = notebook_frontend.locate_and_focus(".modal-footer", page=EDITOR_PAGE) + 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') - modal_footer = notebook_frontend.locate('.modal-footer', page=EDITOR_PAGE) - modal_footer.wait_for('visible') - - name_input_element = notebook_frontend.locate('.modal-body', page=EDITOR_PAGE).locate('.form-control') + 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_btn = modal_footer.locate('text=Save') - save_btn.wait_for('visible') - save_btn.click() + save_element.wait_for('visible') + save_element.focus() + save_element.click() notebook_frontend.wait_for_condition( lambda: get_notebook_name(notebook_frontend) == "new_notebook.ipynb", timeout=120, period=5