|
16 | 16 | use Ibexa\Behat\Browser\Element\Condition\ElementHasTextCondition; |
17 | 17 | use Ibexa\Behat\Browser\Element\Criterion\ElementTextCriterion; |
18 | 18 | use Ibexa\Behat\Browser\Element\Criterion\ElementTextFragmentCriterion; |
| 19 | +use Ibexa\Behat\Browser\Exception\TimeoutException; |
19 | 20 | use Ibexa\Behat\Browser\Locator\VisibleCSSLocator; |
20 | 21 | use Ibexa\Behat\Browser\Page\Page; |
21 | 22 | use Ibexa\Behat\Browser\Routing\Router; |
@@ -239,13 +240,24 @@ private function getFieldtypeIdentifier(VisibleCSSLocator $fieldLocator, string |
239 | 240 |
|
240 | 241 | public function switchToFieldGroup(string $tabName): void |
241 | 242 | { |
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 | + ); |
249 | 261 | } |
250 | 262 |
|
251 | 263 | public function switchToFieldTab(string $tabName): void |
|
0 commit comments