Bugzilla – Attachment 144106 Details for
Bug 32010
selenium/authentication_2fa.t is failing randomly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32010: 2AF selenium tests - Alert can appear when we are waiting for ajax
Bug-32010-2AF-selenium-tests---Alert-can-appear-wh.patch (text/plain), 2.10 KB, created by
Jonathan Druart
on 2022-11-21 06:58:03 UTC
(
hide
)
Description:
Bug 32010: 2AF selenium tests - Alert can appear when we are waiting for ajax
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-11-21 06:58:03 UTC
Size:
2.10 KB
patch
obsolete
>From ede69db08ed9366bfff367ed3705f2f7d2aa7330 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 21 Nov 2022 07:55:52 +0100 >Subject: [PATCH] Bug 32010: 2AF selenium tests - Alert can appear when we are > waiting for ajax > >If we are waiting for ajax (there is a sleep 1s) and the alert pops up >at the same time, Selenium is raising "unexpected alert open" > >We should not wait for the ajax request, but better wait for the >alert actually. >--- > t/db_dependent/selenium/authentication_2fa.t | 3 +-- > t/lib/Selenium.pm | 18 ++++++++++++++++++ > 2 files changed, 19 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/selenium/authentication_2fa.t b/t/db_dependent/selenium/authentication_2fa.t >index a6bf221e5d9..8c9979be5d4 100755 >--- a/t/db_dependent/selenium/authentication_2fa.t >+++ b/t/db_dependent/selenium/authentication_2fa.t >@@ -279,8 +279,7 @@ SKIP: { > $driver->find_element('//*[@id="pin_code"]')->clear; > $driver->find_element('//*[@id="pin_code"]')->send_keys($pin_code); > $driver->find_element('//*[@id="register-2FA"]')->click; >- $s->wait_for_ajax; >- is( $driver->get_alert_text, >+ is( $s->get_next_alert_text, > "Two-factor authentication correctly configured. You will be redirected to the login screen." > ); > $driver->accept_alert; >diff --git a/t/lib/Selenium.pm b/t/lib/Selenium.pm >index 72b55f5c822..1117ce77627 100644 >--- a/t/lib/Selenium.pm >+++ b/t/lib/Selenium.pm >@@ -208,6 +208,24 @@ sub wait_for_ajax { > } > } > >+sub get_next_alert_text { >+ my ( $self ) = @_; >+ >+ my $alert_text; >+ my $max_retries = $self->max_retries; >+ my $i; >+ $self->remove_error_handler; >+ while ( not $alert_text ) { >+ $alert_text = eval { $self->driver->get_alert_text }; >+ $self->driver->pause(1000) unless $alert_text; >+ >+ die "Cannot wait more for next alert (get_next_alert)" >+ if $max_retries <= ++$i; >+ } >+ $self->add_error_handler; >+ return $alert_text; >+} >+ > sub show_all_entries { > my ( $self, $xpath_selector ) = @_; > >-- >2.25.1
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 32010
:
142914
|
144065
| 144106