From 35fb56169a06f36077162372af82e4e9a60881fe Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 15 Feb 2022 12:28:23 +0100 Subject: [PATCH] Bug 30063: Fix selenium tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Séverine Queune Signed-off-by: Martin Renvoize Signed-off-by: Fridolin Somers --- t/db_dependent/selenium/patrons_search.t | 5 +++-- t/lib/Selenium.pm | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/selenium/patrons_search.t b/t/db_dependent/selenium/patrons_search.t index 0d338298d9..dc09d70113 100755 --- a/t/db_dependent/selenium/patrons_search.t +++ b/t/db_dependent/selenium/patrons_search.t @@ -102,10 +102,11 @@ subtest 'Search patrons' => sub { is( scalar @adv_options, 12, 'Invalid option not added when DefaultPatronSearchFields is populated with an invalid field'); is( scalar @filter_options, 12, 'Invalid filter option not added when DefaultPatronSearchFields is populated with an invalid field'); C4::Context->set_preference('DefaultPatronSearchFields',""); - $s->fill_form( { searchmember_filter => 'test_patron' } ); + $s->fill_form( { search_patron_filter => 'test_patron' } ); $s->submit_form; my $first_patron = $patrons[0]; + $s->wait_for_datatable_visible('//table[@id="memberresultst"]'); my @td = $driver->find_elements('//table[@id="memberresultst"]/tbody/tr/td'); like ($td[2]->get_text, qr[\Q$firstname\E], 'Column "Name" should be the 3rd and contain the firstname correctly filtered' @@ -116,7 +117,7 @@ subtest 'Search patrons' => sub { like ($td[2]->get_text, qr[\Q$email\E], 'Column "Name" should be the 3rd and contain the email address correctly filtered' ); - is( $td[5]->get_text, $branchname, + is( $td[4]->get_text, $branchname, 'Column "Library" should be the 6th and contain the html tags - they have been html filtered' ); is( $td[9]->get_text, $borrowernotes_displayed, diff --git a/t/lib/Selenium.pm b/t/lib/Selenium.pm index 6d9afacdce..1b24e66975 100644 --- a/t/lib/Selenium.pm +++ b/t/lib/Selenium.pm @@ -193,6 +193,25 @@ sub wait_for_element_visible { return $elt; } +sub wait_for_datatable_visible { + my ( $self, $xpath_selector ) = @_; + + 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 . '//td[class="dataTables_empty"]')}; + $visible = $elt && $elt->get_text ne 'No data available in table'; + $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; +} + sub show_all_entries { my ( $self, $xpath_selector ) = @_; -- 2.39.5