Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test using a non-specific selector #2475

Merged
merged 5 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions tests/common/navigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def reset_workspace(self):
self._set_environment_via_popup(kernel=None)

# go to Kernel menu
kernel_menuitem = self.page.get_by_text("Kernel", exact=True)
kernel_menuitem = self.page.get_by_role("menuitem", name="Kernel", exact=True)
kernel_menuitem.click()
# shut down multiple running kernels
with contextlib.suppress(Exception):
Expand Down Expand Up @@ -320,14 +320,23 @@ def _set_environment_via_popup(self, kernel=None):
# failure here indicates that the environment doesn't exist either
# because of incorrect naming syntax or because the env is still
# being built
self.page.get_by_role("combobox").nth(1).select_option(kernel)
# click Select to close popup (deal with the two formats of this dialog)
try:
self.page.get_by_role("button", name="Select Kernel").click()
except Exception:
self.page.locator("div").filter(has_text="No KernelSelect").get_by_role(
"button", name="Select Kernel"
).click()

new_launcher_popup = self.page.locator(
".jp-KernelSelector-Dialog .jp-NewLauncher-table table"
).nth(0)
if new_launcher_popup.is_visible():
# for when the jupyterlab-new-launcher extension is installed
new_launcher_popup.locator("td").nth(0).click()
else:
# for when only the native launcher is available
self.page.get_by_role("combobox").nth(1).select_option(kernel)
# click Select to close popup (deal with the two formats of this dialog)
try:
self.page.get_by_role("button", name="Select Kernel").click()
except Exception:
self.page.locator("div").filter(
has_text="No KernelSelect"
).get_by_role("button", name="Select Kernel").click()

def set_environment(self, kernel):
"""Set environment of a jupyter notebook.
Expand All @@ -350,7 +359,7 @@ def set_environment(self, kernel):
popup = self._check_for_kernel_popup()
# if there is not a kernel popup, make it appear
if not popup:
self.page.get_by_text("Kernel", exact=True).click()
self.page.get_by_role("menuitem", name="Kernel", exact=True).click()
self.page.get_by_role("menuitem", name="Change Kernel…").get_by_text(
"Change Kernel…"
).click()
Expand Down
2 changes: 1 addition & 1 deletion tests/common/run_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def _get_outputs(self) -> List[str]:

def _restart_run_all(self):
# restart run all cells
self.nav.page.get_by_text("Kernel", exact=True).click()
self.nav.page.get_by_role("menuitem", name="Kernel", exact=True).click()
self.nav.page.get_by_role(
"menuitem", name="Restart Kernel and Run All Cells…"
).get_by_text("Restart Kernel and Run All Cells…").click()
Expand Down
Loading