<<

NAME

t::lib::Selenium - Selenium helper module

SYNOPSIS

    my $s = t::lib::Selenium->new;
    my $driver = $s->driver;
    my $base_url = $s->base_url;
    $s->auth;
    $driver->get($s->base_url . 'mainpage.pl');
    $s->fill_form({ input_id => 'value' });

DESCRIPTION

The goal of this module is to group the different actions we need when we use automation test using Selenium

METHODS

new

    my $s = t::lib::Selenium->new;

    Constructor - Returns the object Selenium
    You can pass login, password, base_url, selenium_addr, selenium_port
    If not passed, the environment variables will be used
    KOHA_USER, KOHA_PASS, KOHA_INTRANET_URL, SELENIUM_ADDR SELENIUM_PORT
    Or koha, koha, syspref staffClientBaseURL, localhost, 4444

auth

    $s->auth;

    Will login into Koha.

fill_form

    $driver->get($url)
    $s->fill_form({
        input_id => 'value',
        element_id => 'other_value',
    });

    Will fill the different elements of a form.
    The keys must be element ids (input and select are supported so far)
    The values must a string.

submit_form

    $s->submit_form;

    It will submit the form using the submit button present in in the fieldset with a clas="action".
    It should be the default way. If it does not work you should certainly fix the Koha interface.

click

    $s->click

    This is a bit dirty for now but will evolve depending on the needs
    3 parameters possible but only the following 2 forms are used:
    $s->click({ href => '/module/script.pl?foo=bar', main => 'doc3' }); # Sometimes we have doc or doc3. To make sure we are not going to hit a link in the header
    $s->click({ id => 'element_id });

click_when_visible

    $c->click_when_visible

    Should always be called to avoid the "An element could not be located on the page" error

capture $c->capture

Capture a screenshot and upload it using the excellent lut.im service provided by framasoft The url of the image will be printed on STDERR (it should be better to return it instead)

add_error_handler $c->add_error_handler

Add our specific error handler to the driver. It will displayed a trace as well as capture a screenshot of the current screen. So only case you should need it is after you called remove_error_handler

remove_error_handler $c->remove_error_handler

Do *not* call this method if you are not aware of what it will do! It will remove any kinds of error raised by the driver. It can be useful in some cases, for instance if you want to make sure something will not happen and that could make the driver exploses otherwise. You certainly should call it for only one statement then must call add_error_handler right after.

AUTHORS

Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Alex Buckley <alexbuckley@catalyst.net.nz>

Koha Development Team

COPYRIGHT

Copyright 2017 - Koha Development Team

LICENSE

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>.

<<