[go: nahoru, domu]

[e2e] fix event listeners test

Wait for the body element to be expanded before trying to navigate to its child

Bug: 1181777
Change-Id: Ieac775fdd6be42b2908fc7a0f899292ce6399db8
Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3925633
Auto-Submit: Philip Pfaffe <pfaffe@chromium.org>
Reviewed-by: Ergün Erdoğmuş <ergunsh@chromium.org>
Commit-Queue: Ergün Erdoğmuş <ergunsh@chromium.org>
diff --git a/test/e2e/helpers/elements-helpers.ts b/test/e2e/helpers/elements-helpers.ts
index 06a8d56..4fea710 100644
--- a/test/e2e/helpers/elements-helpers.ts
+++ b/test/e2e/helpers/elements-helpers.ts
@@ -90,6 +90,10 @@
   });
 };
 
+export const waitForSelectedNodeToBeExpanded = async () => {
+  await waitFor(`${SELECTED_TREE_ELEMENT_SELECTOR}[aria-expanded="true"]`);
+};
+
 export const waitForAdornerOnSelectedNode = async (expectedAdornerText: string) => {
   await waitForFunction(async () => {
     const selectedNode = await waitFor(SELECTED_TREE_ELEMENT_SELECTOR);
diff --git a/test/e2e/helpers/event-listeners-helpers.ts b/test/e2e/helpers/event-listeners-helpers.ts
index bc35549..781ed55 100644
--- a/test/e2e/helpers/event-listeners-helpers.ts
+++ b/test/e2e/helpers/event-listeners-helpers.ts
@@ -4,7 +4,11 @@
 
 import {$$, click, getBrowserAndPages, goToResource, waitFor} from '../../shared/helper.js';
 
-import {waitForContentOfSelectedElementsNode, waitForElementsStyleSection} from './elements-helpers.js';
+import {
+  waitForContentOfSelectedElementsNode,
+  waitForElementsStyleSection,
+  waitForSelectedNodeToBeExpanded,
+} from './elements-helpers.js';
 
 export const loadEventListenersAndSelectButtonNode = async () => {
   const {frontend} = getBrowserAndPages();
@@ -14,6 +18,9 @@
   // Check to make sure we have the correct node selected after opening a file
   await waitForContentOfSelectedElementsNode('<body class=\u200B"test-js-loaded">\u200B');
 
+  // Wait for element to be expanded
+  await waitForSelectedNodeToBeExpanded();
+
   // Select the button that has the events and make sure it's selected
   await frontend.keyboard.press('ArrowRight');
   await waitForContentOfSelectedElementsNode('<button id=\u200B"test-button">\u200Bhello world\u200B</button>\u200B');