Bugzilla – Attachment 107888 Details for
Bug 26162
Prevent Selenium's StaleElementReferenceException
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26162: Make Selenium click action more robust
Bug-26162-Make-Selenium-click-action-more-robust.patch (text/plain), 1.44 KB, created by
Jonathan Druart
on 2020-08-06 13:11:00 UTC
(
hide
)
Description:
Bug 26162: Make Selenium click action more robust
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-08-06 13:11:00 UTC
Size:
1.44 KB
patch
obsolete
>From cabc888b65a65f8926ae2036182b18db7cb2fce3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 6 Aug 2020 15:08:48 +0200 >Subject: [PATCH] Bug 26162: Make Selenium click action more robust > >See >https://stackoverflow.com/questions/12967541/how-to-avoid-staleelementreferenceexception-in-selenium >https://www.selenium.dev/exceptions/ >https://developer.mozilla.org/en-US/docs/Web/WebDriver/Errors/StaleElementReference >--- > t/lib/Selenium.pm | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > >diff --git a/t/lib/Selenium.pm b/t/lib/Selenium.pm >index 4644d114f0..a4a36fc68f 100644 >--- a/t/lib/Selenium.pm >+++ b/t/lib/Selenium.pm >@@ -177,11 +177,20 @@ sub click_when_visible { > $self->driver->set_implicit_wait_timeout(20000); > my ($visible, $elt); > while ( not $visible ) { >- $elt = $self->driver->find_element($xpath_selector); >- $visible = $elt->is_displayed; >+ $elt = eval {$self->driver->find_element($xpath_selector) }; >+ $visible = $elt && $elt->is_displayed; > $self->driver->pause(1000) unless $visible; > } >- $elt->click; >+ >+ my $clicked; >+ $self->remove_error_handler; >+ while ( not $clicked ) { >+ eval { $elt->click }; >+ $clicked = !$@; >+ $self->driver->pause(1000) unless $clicked; >+ } >+ $self->add_error_handler; >+ $elt->click unless $clicked; # finally Raise the error > } > > =head1 NAME >-- >2.20.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 26162
:
107888
|
107889
|
107940
|
107985
|
108568
|
108569