From 6625c94c6dc791c4bb508e6c945028a59760520d Mon Sep 17 00:00:00 2001 From: VsevolodX <79542055+VsevolodX@users.noreply.github.com> Date: Tue, 16 Apr 2024 12:48:40 -0700 Subject: [PATCH] update: click menu --- .../jupyterlite/I Run All Cells.ts | 3 +-- .../support/widgets/JupyterLiteSession.ts | 19 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/tests/cypress/support/step_definitions/jupyterlite/I Run All Cells.ts b/tests/cypress/support/step_definitions/jupyterlite/I Run All Cells.ts index bc470aa7..9b46b5e3 100644 --- a/tests/cypress/support/step_definitions/jupyterlite/I Run All Cells.ts +++ b/tests/cypress/support/step_definitions/jupyterlite/I Run All Cells.ts @@ -5,6 +5,5 @@ import MaterialDesignerPage from "../../widgets/MaterialDesignerPage"; When("I Run All Cells", () => { const { jupyterLiteSession } = new MaterialDesignerPage().designerWidget; jupyterLiteSession.waitForKernelIdleWithRestart(); - jupyterLiteSession.clickMenuTab("Run"); - jupyterLiteSession.clickMenuTab("Run All Cells"); + jupyterLiteSession.clickMenu("Run", "Run All Cells"); }); diff --git a/tests/cypress/support/widgets/JupyterLiteSession.ts b/tests/cypress/support/widgets/JupyterLiteSession.ts index 68c9fade..42a47bcf 100644 --- a/tests/cypress/support/widgets/JupyterLiteSession.ts +++ b/tests/cypress/support/widgets/JupyterLiteSession.ts @@ -8,6 +8,7 @@ const selectors = { cellInIndex: (index: number) => `.jp-Notebook .jp-Cell:nth-child(${index}) .jp-InputArea-editor .CodeMirror`, menuItem: 'li[role="menuitem"]', + menuItemNew: (tabName: string) => `li[role="menuitem"] > div:contains("${tabName}")`, runTab: 'li[role="menuitem"] > div:contains("Run")', runAllCells: 'li[role="menuitem"] > div:contains("Run All Cells")', }; @@ -64,17 +65,13 @@ export default class JupyterLiteSession extends Widget { }); } - clickMenuTab(tabName: string) { - return this.browser - .iframe(selectors.iframe) - .waitForVisible(selectors.menuItem) - .contains(tabName) - .click() - .then(($li) => { - if ($li.find(".lm-Menu").length > 0) { - cy.contains(selectors.menuItem, tabName).should("be.visible").click(); - } - }); + clickMenu(tabName: string, subItemName?: string) { + const menuTabSelector = selectors.menuItemNew(tabName); + this.browser.iframe(selectors.iframe).clickFirst(menuTabSelector); + if (subItemName) { + const submenuItemSelector = selectors.menuItemNew(subItemName); + this.browser.iframe(selectors.iframe).clickFirst(submenuItemSelector); + } } getKernelStatus() {