Skip to content

Commit

Permalink
[Behat] Added retry for switchToFieldGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
micszo committed Feb 19, 2025
1 parent c768afb commit 9e00eb2
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/lib/Behat/Page/ContentUpdateItemPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Ibexa\Behat\Browser\Element\Condition\ElementHasTextCondition;
use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion;
use Ibexa\Behat\Browser\Element\Criterion\ElementTextFragmentCriterion;
use Ibexa\Behat\Browser\Exception\TimeoutException;
use Ibexa\Behat\Browser\Locator\VisibleCSSLocator;
use Ibexa\Behat\Browser\Page\Page;
use Ibexa\Behat\Browser\Routing\Router;
Expand Down Expand Up @@ -239,13 +240,24 @@ private function getFieldtypeIdentifier(VisibleCSSLocator $fieldLocator, string

public function switchToFieldGroup(string $tabName): void
{
$this->getHTMLPage()->setTimeout(3)
->findAll($this->getLocator('navigationTabs'))
->getByCriterion(new ElementTextCriterion($tabName))
->click();
$this->getHTMLPage()
->setTimeout(10)
->waitUntilCondition(new ElementHasTextCondition($this->getHTMLPage(), new VisibleCSSLocator('activeSection', '.ibexa-anchor-navigation-menu__sections-item-btn--active'), $tabName));
for ($attempt = 0; $attempt < 2; ++$attempt) {
try {
$this->getHTMLPage()->setTimeout(3)
->findAll($this->getLocator('navigationTabs'))
->getByCriterion(new ElementTextCriterion($tabName))
->click();
$this->getHTMLPage()
->setTimeout(10)
->waitUntilCondition(new ElementHasTextCondition($this->getHTMLPage(), new VisibleCSSLocator('activeSection', '.ibexa-anchor-navigation-menu__sections-item-btn--active'), $tabName));

return;
} catch (TimeoutException $e) {
// Retry on failure
}
}
throw new TimeoutException(
sprintf("The expected text %s matching CSS locator 'activeSection': '.ibexa-anchor-navigation-menu__sections-item-btn--active' was not found.", $tabName)
);
}

public function switchToFieldTab(string $tabName): void
Expand Down

0 comments on commit 9e00eb2

Please sign in to comment.