From 4a43a3fad9cd4adcd8983fe70e043ce5c2777fb9 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. Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Martin Renvoize --- 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