Bugzilla – Attachment 75772 Details for
Bug 20757
Capture a screenshot on selenium errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20757: Capture and upload screenshot on selenium errors
Bug-20757-Capture-and-upload-screenshot-on-seleniu.patch (text/plain), 2.42 KB, created by
Josef Moravec
on 2018-06-04 14:20:05 UTC
(
hide
)
Description:
Bug 20757: Capture and upload screenshot on selenium errors
Filename:
MIME Type:
Creator:
Josef Moravec
Created:
2018-06-04 14:20:05 UTC
Size:
2.42 KB
patch
obsolete
>From b71588c269f356e8c4a4aae8fc2cce0ef6a3e9bd Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 11 May 2018 16:58:07 -0300 >Subject: [PATCH] Bug 20757: Capture and upload screenshot on selenium errors > >It is a real pain to debug selenium errors, especially when it is >not reproducible locally. > >This patch capture a screenshot when an error occurred and upload it >using the excellent lut.im service provided by framasoft >(We could host our own later). > >Test plan: >Modify a selenium script to make it fails (search for find_element) >You will see a stack trace followed by a link to framapic.org > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> >--- > t/lib/Selenium.pm | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > >diff --git a/t/lib/Selenium.pm b/t/lib/Selenium.pm >index 645cd8d..83d7b84 100644 >--- a/t/lib/Selenium.pm >+++ b/t/lib/Selenium.pm >@@ -18,12 +18,24 @@ package t::lib::Selenium; > > use Modern::Perl; > use Carp qw( croak ); >+use JSON qw( from_json ); > > use C4::Context; > > use base qw(Class::Accessor); > __PACKAGE__->mk_accessors(qw(login password base_url opac_base_url selenium_addr selenium_port driver)); > >+sub capture { >+ my ( $class, $driver ) = @_; >+ >+ my $lutim_server = q|https://framapic.org|; # Thanks Framasoft! >+ $driver->capture_screenshot('selenium_failure.png'); >+ my $from_json = from_json qx{curl -s -F "format=json" -F "file=\@selenium_failure.png" -F "delete-day=1" $lutim_server}; >+ if ( $from_json ) { >+ print STDERR "\nSCREENSHOT: $lutim_server/" . $from_json->{msg}->{short} . "\n"; >+ } >+} >+ > sub new { > my ( $class, $params ) = @_; > my $self = {}; >@@ -38,14 +50,16 @@ sub new { > port => $self->{selenium_port}, > remote_server_addr => $self->{selenium_addr}, > error_handler => sub { >- my $selenium_error = $_[1]; >+ my ( $driver, $selenium_error ) = @_; > print STDERR "\nSTRACE:"; > my $i = 1; > while ( (my @call_details = (caller($i++))) ){ > print STDERR "\t" . $call_details[1]. ":" . $call_details[2] . " in " . $call_details[3]."\n"; > } > print STDERR "\n"; >- croak $selenium_error; } >+ $class->capture( $driver ); >+ croak $selenium_error; >+ } > ); > return bless $self, $class; > } >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20757
:
75287
|
75465
| 75772 |
77182