Bug 25811: Add debug info to authentication.t
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 21 Aug 2020 08:49:42 +0000 (10:49 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 21 Aug 2020 10:32:43 +0000 (12:32 +0200)
Trying to know if the logged in patron is the one we are expecting to
(well, we are not expecting anybody to be logged in at this point!)

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

t/db_dependent/selenium/authentication.t

index 418346a..90797f7 100644 (file)
@@ -97,7 +97,26 @@ SKIP: {
         $driver->find_element('//a[@id="user-menu"]')->click;
         $driver->find_element('//a[@id="logout"]')->click;
         $driver->get($mainpage); # This should not be needed but we the next find_element fails randomly
-        $driver->find_element('//div[@id="login"]'); # logged out
+
+        { # Temporary debug
+            $driver->error_handler(
+                sub {
+                    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";
+                    print STDERR sprintf("Is logged in patron: %s (%s)?\n", $patron->firstname, $patron->surname );
+                    $s->capture( $driver );
+                    croak $selenium_error;
+                }
+            );
+
+            $driver->find_element('//div[@id="login"]'); # logged out
+            $s->add_error_handler; # Reset to the default error handler
+        }
 
         # Using the form on the right
         $s->fill_form( { userid => $patron->userid, password => $password } );