From 95e83fb0f7e4af8ff7f6edfff864d6e3096cc66e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 10 Nov 2020 11:37:55 +0100 Subject: [PATCH] Bug 26986: Prevent Selenium's StaleElementReferenceException This is a follow-up bug for bug 26162 By finding the element before the click I hope to get the good element, even if the page changed in the meanwhile. --- t/lib/Selenium.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/lib/Selenium.pm b/t/lib/Selenium.pm index 758470b668..261502aae1 100644 --- a/t/lib/Selenium.pm +++ b/t/lib/Selenium.pm @@ -218,7 +218,7 @@ sub click_when_visible { my $clicked; $self->remove_error_handler; while ( not $clicked ) { - eval { $elt->click }; + eval { $self->driver->find_element($xpath_selector)->click }; $clicked = !$@; $self->driver->pause(1000) unless $clicked; } -- 2.20.1