Bug 30063: Fix selenium tests

Signed-off-by: Séverine Queune <severine.queune@bulac.fr>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Jonathan Druart 2022-02-15 12:28:23 +01:00 committed by Fridolin Somers
parent e24172bbe9
commit 35fb56169a
2 changed files with 22 additions and 2 deletions

View file

@ -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,

View file

@ -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 ) = @_;