Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/Browser/Element/BaseElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

abstract class BaseElement implements BaseElementInterface
{
protected int $timeout = 1;
protected int $timeout = 3;

private ElementFactoryInterface $elementFactory;

Expand Down
19 changes: 15 additions & 4 deletions src/lib/Browser/Page/RedirectLoginPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

namespace Ibexa\Behat\Browser\Page;

use Exception;
use Ibexa\Behat\Browser\Exception\ElementNotFoundException;
use Ibexa\Behat\Browser\Locator\CSSLocator;
use PHPUnit\Framework\Assert;

Expand All @@ -25,10 +27,19 @@ public function verifyIsLoaded(): void

public function loginSuccessfully($username, $password): void
{
parent::loginSuccessfully($username, $password);
$this->getHTMLPage()
->findAll(new CSSLocator('loginSuccess', '#login-success'))
->assert()->hasElements();
for ($attempt = 0; $attempt < 3; ++$attempt) {
try {
parent::loginSuccessfully($username, $password);
$this->getHTMLPage()
->findAll(new CSSLocator('loginSuccess', '#login-success'))
->assert()->hasElements();

return;
} catch (Exception $e) {
// Retry on failure
}
}
throw new ElementNotFoundException('Login failed after multiple attempts.');
}

protected function getRoute(): string
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Browser/Element/ElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testFindElementWhenNotExists(): void
$element = $this->createElementWithMinkElement($minkElement);

$this->expectException(TimeoutException::class);
$this->expectExceptionMessage("CSS selector 'invalid-id': 'invalid-selector' not found in 1 seconds.");
$this->expectExceptionMessage("CSS selector 'invalid-id': 'invalid-selector' not found in 3 seconds.");
$element->find($this->invalidLocator);
}

Expand Down
Loading