From b15065f2a617fba0aa699baf9d3ff881bca2ef33 Mon Sep 17 00:00:00 2001 From: David Remer Date: Fri, 11 Aug 2023 09:57:29 +0300 Subject: [PATCH] Fix flaky test 'StaleElementReferenceException' seems to happen because the selector gets destroyed and created again. While the placeholder is visible the querySelector finds an element. This commit waits now until the placeholder DOM structure is removed before trying to access the values using the selecors. [MAILPOET-5526] --- mailpoet/tests/acceptance/Automation/AnalyticsCest.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mailpoet/tests/acceptance/Automation/AnalyticsCest.php b/mailpoet/tests/acceptance/Automation/AnalyticsCest.php index c376ae7b70..cedc6b582a 100644 --- a/mailpoet/tests/acceptance/Automation/AnalyticsCest.php +++ b/mailpoet/tests/acceptance/Automation/AnalyticsCest.php @@ -54,7 +54,8 @@ class AnalyticsCest { $i->amOnPage("/wp-admin/admin.php?page=mailpoet-automation-analytics&id=" . $this->automation->getId() . "&tab=automation-emails"); $i->see('Overview'); - $i->waitForText('Opened'); + + $i->waitForElement('.woocommerce-summary:not(.is-placeholder)'); $i->see('Opened', '.woocommerce-summary > .woocommerce-summary__item-container'); $i->see('0%', '.woocommerce-summary > .woocommerce-summary__item-container'); $i->see('Clicked', '.woocommerce-summary > .woocommerce-summary__item-container:nth-child(2n)'); @@ -96,7 +97,8 @@ class AnalyticsCest { $click2 = $this->createClickForNewsletter($this->newsletter1, $subscriber2); $i->amOnPage("/wp-admin/admin.php?page=mailpoet-automation-analytics&id=" . $this->automation->getId() . "&tab=automation-emails"); - $i->waitForText('Opened'); + + $i->waitForElement('.woocommerce-summary:not(.is-placeholder)'); $i->see('Opened', '.woocommerce-summary > .woocommerce-summary__item-container'); $i->see('1.5%', '.woocommerce-summary > .woocommerce-summary__item-container'); $i->see('Clicked', '.woocommerce-summary > .woocommerce-summary__item-container:nth-child(2n)'); @@ -126,8 +128,8 @@ class AnalyticsCest { $this->alterCreateDateForOpen($open2, $date); $i->amOnPage("/wp-admin/admin.php?page=mailpoet-automation-analytics&id=" . $this->automation->getId() . "&tab=automation-emails"); - $i->waitForText('Opened'); + $i->waitForElement('.woocommerce-summary:not(.is-placeholder)'); $i->see('Opened', '.woocommerce-summary > .woocommerce-summary__item-container:first-child'); $i->see('1%', '.woocommerce-summary > .woocommerce-summary__item-container:first-child .woocommerce-summary__item-value'); $i->see('-80%', '.woocommerce-summary > .woocommerce-summary__item-container:first-child .woocommerce-summary__item-delta');