#!/usr/bin/perl
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use C4::Biblio qw( AddBiblio DelBiblio );
use C4::Context;
use MARC::Record;
use MARC::Field;
use Test::More;
use t::lib::Mocks;
use t::lib::Selenium;
use t::lib::TestBuilder;
eval { require Selenium::Remote::Driver; };
if ( $@ ) {
plan skip_all => "Selenium::Remote::Driver is needed for Selenium tests.";
} else {
plan tests => 3;
}
my @cleanup;
my $SeparateHoldings_value = C4::Context->preference( 'SeparateHoldings' );
#
# Add a test bibliographic record.
#
my $biblio = MARC::Record->new();
if ( C4::Context->preference( 'marcflavour' ) eq 'MARC21' ) {
$biblio->append_fields(
MARC::Field->new( '245', ' ', ' ', a => 'Test record for MARC21' ),
MARC::Field->new( '100', ' ', ' ', a => 'Test Author' )
);
} elsif ( C4::Context->preference( 'marcflavour' ) eq 'UNIMARC' ) {
$biblio->append_fields(
MARC::Field->new( '200', ' ', ' ', a => 'Test record for UNIMARC' ),
MARC::Field->new( '200', ' ', ' ', f => 'Test Author' )
);
}
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' );
my $builder = t::lib::TestBuilder->new;
#
# Add two items to the test bibliographic record.
# The 1st item is marked as "Lost", this is needed for the 3rd test.
# The 2nd item is located in a different library than the test patron's home
# library so that the "Other holdings" tab will appear in the 2nd test.
#
my $itemnumber1 = $builder->build_sample_item(
{
biblionumber => $biblionumber,
itype => 'BK',
holdingbranch => 'CPL',
homebranch => 'CPL',
ccode => 'FIC',
itemcallnumber => '230 TesA t 2021',
itemlost => 1,
datelastseen => '2023-02-02',
dateaccessioned => '2021-06-01',
datelastborrowed => '2022-07-07',
barcode => '0123456789'
}
)->itemnumber;
my $item1 = Koha::Items->find( $itemnumber1 );
my $itemnumber2 = $builder->build_sample_item(
{
biblionumber => $biblionumber,
itype => 'BK',
holdingbranch => 'FPL',
homebranch => 'FPL',
ccode => 'FIC',
itemcallnumber => '230 TesA t 2021',
itemlost => 0,
datelastseen => '2023-02-01',
dateaccessioned => '2021-06-01',
datelastborrowed => '2022-07-07',
barcode => '9876543210'
}
)->itemnumber;
my $item2 = Koha::Items->find( $itemnumber2 );
#
# Wait for the Zebra indexer daemon to pick up the changes.
# This is necessary for the 1st subtest to pass, otherwise
# the 'Holdings' DataTable is drawn too early and does not
# contain the two items added above.
#
sleep 10;
push @cleanup, $builder, $item1, $item2;
my $s = t::lib::Selenium->new;
my $driver = $s->driver;
my $base_url = $s->base_url;
# Adjust the height and width of the generated screenshots
$driver->set_window_size( 1620, 1920 ); # Height, then Width
#
# Add a test patron, this is needed for logging into the Staff interface.
# The patron's home library is set to 'Centerville', this is important as
# we want the 2nd item from the test bibliographic record created above to
# appear under the "Other holdings" tab when SeparateHoldings is enabled.
#
my $patron = $builder->build_object( {
class => 'Koha::Patrons',
value => { flags => 1, branchcode => 'CPL' }
} );
my $password = Koha::AuthUtils::generate_password( $patron->category );
t::lib::Mocks::mock_preference( 'RequireStrongPassword', 0 );
$patron->set_password( { password => $password } );
push @cleanup, $patron;
$s->auth( $patron->userid, $password );
my $screenshots_on = 1;
subtest 'Visit the bibliographic record details page and test the \'Holdings\' DataTable' => sub {
# Make sure SeparateHoldings is set to "Don't separate" for this test
C4::Context->set_preference( 'SeparateHoldings', '0' );
plan tests => 17;
$driver->get( $base_url . 'catalogue/detail.pl?biblionumber=' . $biblionumber );
$driver->capture_screenshot( 'Selenium_0_00.png' ) if $screenshots_on;
my $dt_activate_filters_elt;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
is( $dt_activate_filters_elt->get_attribute( 'href' , 1 ), '#', 'The page contains an \'Activate filters\' link/button' );
$dt_activate_filters_elt->click;
$driver->capture_screenshot( 'Selenium_0_01.png' ) if $screenshots_on;
is( $dt_activate_filters_elt->get_text( ), 'Deactivate filters', 'Clicking on the \'Activate filters\' link/button changes its description to \'Deactivate filters\'' );
my $dt_filters_row_elt = $driver->find_element( '//*[@id="holdings_table"]/thead/tr[2]' );
is( $dt_filters_row_elt->get_attribute( 'class' , 1 ), 'filters_row columnFilter', 'The table filters have appeared under the table sorting controls' );
is( $dt_filters_row_elt->is_displayed( ), 1, 'The table filters are currently displayed' );
#
# Perform some searches
#
my $element;
my @dt_results_count;
$element = $driver->find_element( '//*[@id="holdings_table_filter"]/label/input' );
$element->send_keys( 'T' );
$element->send_keys( 'e' );
$element->send_keys( 's' );
$element->send_keys( 'A' );
$driver->capture_screenshot( 'Selenium_0_02.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 2, 'Searching for "TesA" in the generic "Search:" field returns 2 results' );
$driver->refresh( );
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="holdings_itype"]/span/input' );
$element->send_keys( 'B' );
$element->send_keys( 'o' );
$element->send_keys( 'o' );
$element->send_keys( 'k' );
$element->send_keys( 's' );
$driver->capture_screenshot( 'Selenium_0_03.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 2, 'Searching for "Books" in the "Item type" search field returns 2 results' );
$driver->refresh( );
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="holdings_holdingbranch"]/span/input' );
$element->send_keys( 'e' );
$driver->capture_screenshot( 'Selenium_0_04.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 2, 'Searching for "e" in the "Current library" search field returns 2 results' );
$driver->refresh( );
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="holdings_homebranch"]/span/input' );
$element->send_keys( 'F' );
$driver->capture_screenshot( 'Selenium_0_05.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "F" in the "Home library" search field returns 1 result' );
$driver->refresh( );
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="holdings_ccode"]/span/input' );
$element->send_keys( 'F' );
$element->send_keys( 'i' );
$element->send_keys( 'c' );
$driver->capture_screenshot( 'Selenium_0_06.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 2, 'Searching for "Fic" in the "Collection" search field returns 2 results' );
$driver->refresh( );
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="holdings_itemcallnumber"]/span/input' );
$element->send_keys( '2' );
$element->send_keys( '3' );
$element->send_keys( '0' );
$driver->capture_screenshot( 'Selenium_0_07.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 2, 'Searching for "230" in the "Call number" search field returns 2 results' );
$driver->refresh( );
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="holdings_status"]/span/input' );
$element->send_keys( 'A' );
$element->send_keys( 'v' );
$element->send_keys( 'a' );
$element->send_keys( 'i' );
$element->send_keys( 'l' );
$driver->capture_screenshot( 'Selenium_0_08.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "Avail" in the "Status" search field returns 1 result' );
$driver->refresh( );
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="holdings_lastseen"]/span/input' );
$element->send_keys( '2' );
$element->send_keys( '0' );
$element->send_keys( '2' );
$element->send_keys( '3' );
$driver->capture_screenshot( 'Selenium_0_09.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 2, 'Searching for "2023" in the "Last seen" search field returns 2 results' );
$driver->refresh( );
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="holdings_dateaccessioned"]/span/input' );
$element->send_keys( '2' );
$element->send_keys( '0' );
$element->send_keys( '1' );
$element->send_keys( '5' );
$driver->capture_screenshot( 'Selenium_0_10.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 0, 'Searching for "2015" in the "Date accessioned" search field returns no results' );
$driver->refresh( );
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="holdings_datelastborrowed"]/span/input' );
$element->send_keys( '2' );
$element->send_keys( '0' );
$element->send_keys( '2' );
$element->send_keys( '2' );
$driver->capture_screenshot( 'Selenium_0_11.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 2, 'Searching for "2022" in the "Date last borrowed" search field returns 2 results' );
$driver->refresh( );
$dt_activate_filters_elt = $driver->find_element( '//*[@id="holdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="holdings_barcode"]/span/input' );
$element->send_keys( '7' );
$element->send_keys( '8' );
$element->send_keys( '9' );
$driver->capture_screenshot( 'Selenium_0_12.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="holdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "789" in the "Barcode" search field returns 1 result' );
#
# Deactivate the filters
#
$dt_activate_filters_elt->click;
$driver->capture_screenshot( 'Selenium_0_13.png' ) if $screenshots_on;
$dt_filters_row_elt = $driver->find_element( '//*[@id="holdings_table"]/thead/tr[2]' );
is( $dt_activate_filters_elt->get_text( ), 'Activate filters', 'Clicking on the \'Deactivate filters\' link/button changes its description back to \'Activate filters\'' );
is( $dt_filters_row_elt->is_displayed( ), 0, 'The table filters are now hidden again' );
};
subtest 'Visit the bibliographic record details page and test the \'Other holdings\' DataTable' => sub {
# Make sure SeparateHoldings is set to "Separate" for this test
C4::Context->set_preference( 'SeparateHoldings', '1' );
plan tests => 17;
$driver->get( $base_url . 'catalogue/detail.pl?biblionumber=' . $biblionumber );
my $otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$driver->capture_screenshot( 'Selenium_1_00.png' ) if $screenshots_on;
my $dt_activate_filters_elt;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
is( $dt_activate_filters_elt->get_attribute( 'href' , 1 ), '#', 'The page contains an \'Activate filters\' link/button' );
$dt_activate_filters_elt->click;
$driver->capture_screenshot( 'Selenium_1_01.png' ) if $screenshots_on;
is( $dt_activate_filters_elt->get_text( ), 'Deactivate filters', 'Clicking on the \'Activate filters\' link/button changes its description to \'Deactivate filters\'' );
my $dt_filters_row_elt = $driver->find_element( '//*[@id="otherholdings_table"]/thead/tr[2]' );
is( $dt_filters_row_elt->get_attribute( 'class' , 1 ), 'filters_row columnFilter', 'The table filters have appeared under the table sorting controls' );
is( $dt_filters_row_elt->is_displayed( ), 1, 'The table filters are currently displayed' );
#
# Perform some searches
#
my $element;
my @dt_results_count;
$element = $driver->find_element( '//*[@id="otherholdings_table_filter"]/label/input' );
$element->send_keys( 'T' );
$element->send_keys( 'e' );
$element->send_keys( 's' );
$element->send_keys( 'A' );
$driver->capture_screenshot( 'Selenium_1_02.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "TesA" in the generic "Search:" field returns 1 result' );
$driver->refresh( );
$otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="otherholdings_itype"]/span/input' );
$element->send_keys( 'B' );
$element->send_keys( 'o' );
$element->send_keys( 'o' );
$element->send_keys( 'k' );
$element->send_keys( 's' );
$driver->capture_screenshot( 'Selenium_1_03.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "Books" in the "Item type" search field returns 1 result' );
$driver->refresh( );
$otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="otherholdings_holdingbranch"]/span/input' );
$element->send_keys( 'e' );
$driver->capture_screenshot( 'Selenium_1_04.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "e" in the "Current library" search field returns 1 result' );
$driver->refresh( );
$otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="otherholdings_homebranch"]/span/input' );
$element->send_keys( 'F' );
$driver->capture_screenshot( 'Selenium_1_05.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "F" in the "Home library" search field returns 1 result' );
$driver->refresh( );
$otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="otherholdings_ccode"]/span/input' );
$element->send_keys( 'F' );
$element->send_keys( 'i' );
$element->send_keys( 'c' );
$driver->capture_screenshot( 'Selenium_1_06.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "Fic" in the "Collection" search field returns 1 result' );
$driver->refresh( );
$otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="otherholdings_itemcallnumber"]/span/input' );
$element->send_keys( '2' );
$element->send_keys( '3' );
$element->send_keys( '0' );
$driver->capture_screenshot( 'Selenium_1_07.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "230" in the "Call number" search field returns 1 result' );
$driver->refresh( );
$otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="otherholdings_status"]/span/input' );
$element->send_keys( 'A' );
$element->send_keys( 'v' );
$element->send_keys( 'a' );
$element->send_keys( 'i' );
$element->send_keys( 'l' );
$driver->capture_screenshot( 'Selenium_1_08.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "Avail" in the "Status" search field returns 1 result' );
$driver->refresh( );
$otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="otherholdings_lastseen"]/span/input' );
$element->send_keys( '2' );
$element->send_keys( '0' );
$element->send_keys( '2' );
$element->send_keys( '3' );
$driver->capture_screenshot( 'Selenium_1_09.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "2023" in the "Last seen" search field returns 1 result' );
$driver->refresh( );
$otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="otherholdings_dateaccessioned"]/span/input' );
$element->send_keys( '2' );
$element->send_keys( '0' );
$element->send_keys( '1' );
$element->send_keys( '5' );
$driver->capture_screenshot( 'Selenium_1_10.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 0, 'Searching for "2015" in the "Date accessioned" search field returns no results' );
$driver->refresh( );
$otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="otherholdings_datelastborrowed"]/span/input' );
$element->send_keys( '2' );
$element->send_keys( '0' );
$element->send_keys( '2' );
$element->send_keys( '2' );
$driver->capture_screenshot( 'Selenium_1_11.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "2022" in the "Date last borrowed" search field returns 1 result' );
$driver->refresh( );
$otherholdings_tab_elt = $driver->find_element( '//*[@id="bibliodetails"]/ul/li[2]/a' );
$otherholdings_tab_elt->click;
$dt_activate_filters_elt = $driver->find_element( '//*[@id="otherholdings_table_activate_filters"]' );
$dt_activate_filters_elt->click;
$element = $driver->find_element( '//*[@id="otherholdings_barcode"]/span/input' );
$element->send_keys( '9' );
$element->send_keys( '8' );
$element->send_keys( '7' );
$driver->capture_screenshot( 'Selenium_1_12.png' ) if $screenshots_on;
@dt_results_count = $driver->find_elements( '//*[@id="otherholdings_table"]/tbody/tr[@role="row"]' );
is( @dt_results_count, 1, 'Searching for "987" in the "Barcode" search field returns 1 result' );
#
# Deactivate the filters
#
$dt_activate_filters_elt->click;
$driver->capture_screenshot( 'Selenium_1_13.png' ) if $screenshots_on;
$dt_filters_row_elt = $driver->find_element( '//*[@id="otherholdings_table"]/thead/tr[2]' );
is( $dt_activate_filters_elt->get_text( ), 'Activate filters', 'Clicking on the \'Deactivate filters\' link/button changes its description back to \'Activate filters\'' );
is( $dt_filters_row_elt->is_displayed( ), 0, 'The table filters are now hidden again' );
};
subtest 'Visit Tools > Reports > Items lost and test the results DataTable' => sub {
plan tests => 4;
$driver->get( $base_url . 'reports/itemslost.pl' );
$driver->capture_screenshot( 'Selenium_2_00.png' ) if $screenshots_on;
my $barcode_input_elt = $driver->find_element( '//*[@id="barcodefilter"]' );
$barcode_input_elt->send_keys( '0123456789' );
$driver->capture_screenshot( 'Selenium_2_01.png' ) if $screenshots_on;
my $submit_button_elt = $driver->find_element( '//*[@id="rep_itemslost"]/div[3]/div/div[1]/main/form/fieldset[2]/input[1]' );
$submit_button_elt->click;
$driver->capture_screenshot( 'Selenium_2_02.png' ) if $screenshots_on;
sleep 5;
my $dt_activate_filters_button_elt;
$dt_activate_filters_button_elt = $driver->find_element( '//*[@id="lostitems-table_activate_filters"]' );
is( $dt_activate_filters_button_elt->get_attribute( 'href' , 1 ), '#', 'The page contains an \'Activate filters\' link/button' );
$dt_activate_filters_button_elt->click;
sleep 5;
$driver->capture_screenshot( 'Selenium_2_03.png' ) if $screenshots_on;
my $dt_activate_filters_button_elt2 = $driver->find_element( '//*[@id="lostitems-table_activate_filters"]' );
sleep 5;
is( $dt_activate_filters_button_elt2->get_text( ), 'Deactivate filters', 'Clicking on the \'Activate filters\' link/button changes its description to \'Deactivate filters\'' );
my $dt_filters_row_elt = $driver->find_element( '//*[@id="lostitems-table"]/thead/tr[2]' );
is( $dt_filters_row_elt->get_attribute( 'class' , 1 ), 'filters_row columnFilter', 'The table filters have appeared under the table sorting controls' );
is( $dt_filters_row_elt->is_displayed( ), 1, 'The table filters are currently displayed' );
#
# TODO: Perform some searches
#
};
$driver->quit();
# Revert the System Preference we modified earlier to its original value.
# Then delete the test items, the test patron, and finally the test biblio.
END {
C4::Context->set_preference( 'SeparateHoldings', $SeparateHoldings_value );
$_->delete for @cleanup;
DelBiblio( $biblionumber );
};