From eb88960fbaa78a07efbbf9b769bd4ad390eba380 Mon Sep 17 00:00:00 2001 From: Gert Hengeveld Date: Thu, 8 Oct 2020 09:43:04 +0200 Subject: [PATCH] Ensure parent is expanded before trying to click an item. --- cypress/support/commands.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index d1c1d32af4f..5e2302d0574 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -98,8 +98,10 @@ Cypress.Commands.add('navigateToStory', (kind, name) => { cy.log(`navigateToStory ${kind} ${name}`); if (name !== 'page') { - // Section can be collapsed, click twice ensure expansion - cy.get(`#${kindId}`).click(); + // Section might be collapsed + cy.get(`#${kindId}`).then(($item) => { + if ($item.getAttribute('aria-expanded') === 'false') $item.click(); + }); } cy.get(storyLinkId).click();