View | Details | Raw Unified | Return to bug 20757
Collapse All | Expand All

(-)a/t/lib/Selenium.pm (-3 / +16 lines)
Lines 18-29 package t::lib::Selenium; Link Here
18
18
19
use Modern::Perl;
19
use Modern::Perl;
20
use Carp qw( croak );
20
use Carp qw( croak );
21
use JSON qw( from_json );
21
22
22
use C4::Context;
23
use C4::Context;
23
24
24
use base qw(Class::Accessor);
25
use base qw(Class::Accessor);
25
__PACKAGE__->mk_accessors(qw(login password base_url opac_base_url selenium_addr selenium_port driver));
26
__PACKAGE__->mk_accessors(qw(login password base_url opac_base_url selenium_addr selenium_port driver));
26
27
28
sub capture {
29
    my ( $class, $driver ) = @_;
30
31
    my $lutim_server = q|https://framapic.org|; # Thanks Framasoft!
32
    $driver->capture_screenshot('selenium_failure.png');
33
    my $from_json = from_json qx{curl -s -F "format=json" -F "file=\@selenium_failure.png" -F "delete-day=1" $lutim_server};
34
    if ( $from_json ) {
35
        print STDERR "\nSCREENSHOT: $lutim_server/" . $from_json->{msg}->{short} . "\n";
36
    }
37
}
38
27
sub new {
39
sub new {
28
    my ( $class, $params ) = @_;
40
    my ( $class, $params ) = @_;
29
    my $self   = {};
41
    my $self   = {};
Lines 38-51 sub new { Link Here
38
        port               => $self->{selenium_port},
50
        port               => $self->{selenium_port},
39
        remote_server_addr => $self->{selenium_addr},
51
        remote_server_addr => $self->{selenium_addr},
40
        error_handler => sub {
52
        error_handler => sub {
41
            my $selenium_error = $_[1];
53
            my ( $driver, $selenium_error ) = @_;
42
            print STDERR "\nSTRACE:";
54
            print STDERR "\nSTRACE:";
43
            my $i = 1;
55
            my $i = 1;
44
            while ( (my @call_details = (caller($i++))) ){
56
            while ( (my @call_details = (caller($i++))) ){
45
                print STDERR "\t" . $call_details[1]. ":" . $call_details[2] . " in " . $call_details[3]."\n";
57
                print STDERR "\t" . $call_details[1]. ":" . $call_details[2] . " in " . $call_details[3]."\n";
46
            }
58
            }
47
            print STDERR "\n";
59
            print STDERR "\n";
48
            croak $selenium_error; }
60
            $class->capture( $driver );
61
            croak $selenium_error;
62
        }
49
    );
63
    );
50
    return bless $self, $class;
64
    return bless $self, $class;
51
}
65
}
52
- 

Return to bug 20757