From 1fa3bb0e23bba97bba101841e1e0ea988cf6c602 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 --- t/lib/Selenium.pm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/t/lib/Selenium.pm b/t/lib/Selenium.pm index ee25a649f7..4c3d7c1553 100644 --- a/t/lib/Selenium.pm +++ b/t/lib/Selenium.pm @@ -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; -- 2.39.5