From b0af61fdc77e089e57525627fcb8e8eecd4be42c 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 Signed-off-by: Jonathan Druart (cherry picked from commit 836d9a38727859f06902a7be6790592431fe812e) Signed-off-by: Andrew Fuerste-Henry --- 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 42cda1d65f..340a820092 100644 --- a/t/lib/Selenium.pm +++ b/t/lib/Selenium.pm @@ -212,7 +212,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.39.5