From a0b5cefdc88a3671a0310a90490be275bab46860 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 19 Aug 2020 07:19:09 +0200 Subject: [PATCH] Bug 26162: Don't fall into an infinite loop If something went wrong we do want to stop the script! Signed-off-by: Jonathan Druart --- t/lib/Selenium.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/t/lib/Selenium.pm b/t/lib/Selenium.pm index 3e871ec1ff..758470b668 100644 --- a/t/lib/Selenium.pm +++ b/t/lib/Selenium.pm @@ -193,7 +193,8 @@ sub show_all_entries { $self->driver->find_element( $xpath_selector . '//div[@class="dataTables_length"]/label/select/option[@value="-1"]' )->click; - my ($all_displayed); + my ($all_displayed, $i); + my $max_retries = $self->max_retries; while ( not $all_displayed ) { my $dt_infos = $self->driver->get_text( $xpath_selector . '//div[@class="dataTables_info"]' ); @@ -203,6 +204,9 @@ sub show_all_entries { } $self->driver->pause(1000) unless $all_displayed; + + die "Cannot show all entries from table $xpath_selector" + if $max_retries <= ++$i } } @@ -222,6 +226,8 @@ sub click_when_visible { $elt->click unless $clicked; # finally Raise the error } +sub max_retries { 10 } + =head1 NAME t::lib::Selenium - Selenium helper module -- 2.39.5