From e6d1444ce2a93c8f66216e80aaeec09783ddc0ef Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 28 Apr 2021 14:52:20 +0200 Subject: [PATCH] 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 (cherry picked from commit e751ce8cf2be1648fe424d08d9eefeb75d639967) Signed-off-by: Fridolin Somers (cherry picked from commit 1fa3bb0e23bba97bba101841e1e0ea988cf6c602) Signed-off-by: Andrew Fuerste-Henry (cherry picked from commit ef8eae9b0d691b7cac07656d00acd9b8baf2792c) Signed-off-by: Victor Grousset/tuxayo --- t/lib/Selenium.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/t/lib/Selenium.pm b/t/lib/Selenium.pm index 7e8f61d5d1..42de3631eb 100644 --- a/t/lib/Selenium.pm +++ b/t/lib/Selenium.pm @@ -173,10 +173,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; -- 2.39.5