3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use Test::More tests => 1;
26 eval { require Selenium::Remote::Driver; };
27 skip "Selenium::Remote::Driver is needed for selenium tests.", 1 if $@;
29 my $s = t::lib::Selenium->new;
31 my $driver = $s->driver;
32 my $opac_base_url = $s->opac_base_url;
34 subtest 'OPAC - Remove from cart' => sub {
37 $driver->get( $opac_base_url . "opac-search.pl?q=d" );
39 # A better way to do that would be to modify the way we display the basket count
40 # We should show/hide the count instead or recreate the node
41 my @basket_count_elts = $driver->find_elements('//span[@id="basketcount"]/span');
42 is( scalar(@basket_count_elts), 0, 'Basket should be empty');
44 $driver->find_element('//a[@class="addtocart cart1"]')->click;
45 my $basket_count_elt = $driver->find_element('//span[@id="basketcount"]/span');
46 is( $basket_count_elt->get_text(),
47 1, 'One element should have been added to the cart' );
49 $driver->find_element('//a[@class="addtocart cart3"]')->click;
50 $driver->find_element('//a[@class="addtocart cart5"]')->click;
51 $basket_count_elt = $driver->find_element('//span[@id="basketcount"]/span');
52 is( $basket_count_elt->get_text(),
53 3, '3 elements should have been added to the cart' );
55 $driver->find_element('//a[@class="cartRemove cartR3"]')->click;
56 $basket_count_elt = $driver->find_element('//span[@id="basketcount"]/span');
57 is( $basket_count_elt->get_text(),
58 2, '1 element should have been removed from the cart' );