Skip to content

Commit 9e00eb2

Browse files
committed
[Behat] Added retry for switchToFieldGroup
1 parent c768afb commit 9e00eb2

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/lib/Behat/Page/ContentUpdateItemPage.php

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Ibexa\Behat\Browser\Element\Condition\ElementHasTextCondition;
1717
use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion;
1818
use Ibexa\Behat\Browser\Element\Criterion\ElementTextFragmentCriterion;
19+
use Ibexa\Behat\Browser\Exception\TimeoutException;
1920
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;
2021
use Ibexa\Behat\Browser\Page\Page;
2122
use Ibexa\Behat\Browser\Routing\Router;
@@ -239,13 +240,24 @@ private function getFieldtypeIdentifier(VisibleCSSLocator $fieldLocator, string
239240

240241
public function switchToFieldGroup(string $tabName): void
241242
{
242-
$this->getHTMLPage()->setTimeout(3)
243-
->findAll($this->getLocator('navigationTabs'))
244-
->getByCriterion(new ElementTextCriterion($tabName))
245-
->click();
246-
$this->getHTMLPage()
247-
->setTimeout(10)
248-
->waitUntilCondition(new ElementHasTextCondition($this->getHTMLPage(), new VisibleCSSLocator('activeSection', '.ibexa-anchor-navigation-menu__sections-item-btn--active'), $tabName));
243+
for ($attempt = 0; $attempt < 2; ++$attempt) {
244+
try {
245+
$this->getHTMLPage()->setTimeout(3)
246+
->findAll($this->getLocator('navigationTabs'))
247+
->getByCriterion(new ElementTextCriterion($tabName))
248+
->click();
249+
$this->getHTMLPage()
250+
->setTimeout(10)
251+
->waitUntilCondition(new ElementHasTextCondition($this->getHTMLPage(), new VisibleCSSLocator('activeSection', '.ibexa-anchor-navigation-menu__sections-item-btn--active'), $tabName));
252+
253+
return;
254+
} catch (TimeoutException $e) {
255+
// Retry on failure
256+
}
257+
}
258+
throw new TimeoutException(
259+
sprintf("The expected text %s matching CSS locator 'activeSection': '.ibexa-anchor-navigation-menu__sections-item-btn--active' was not found.", $tabName)
260+
);
249261
}
250262

251263
public function switchToFieldTab(string $tabName): void

0 commit comments

Comments
 (0)