Bug 28249: Prevent Selenium->wait_for_element_visible to fall in an infinite loop

Stop if max_retries is reached

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-04-28 14:52:20 +02:00
parent df9d0a849d
commit e751ce8cf2
1 changed files with 5 additions and 0 deletions

View File

@ -179,10 +179,15 @@ sub wait_for_element_visible {
my ($visible, $elt);
$self->remove_error_handler;
my $max_retries = $self->max_retries;
my $i;
while ( not $visible ) {
$elt = eval {$self->driver->find_element($xpath_selector) };
$visible = $elt && $elt->is_displayed;
$self->driver->pause(1000) unless $visible;
die "Cannot wait more for element '$xpath_selector' to be visible"
if $max_retries <= ++$i
}
$self->add_error_handler;
return $elt;