Bug 26986

Summary: Second try to prevent Selenium's StaleElementReferenceException
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: andrewfh, martin.renvoize, victor
Version: unspecified   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
20.11.00, 20.05.07, 19.11.13
Bug Depends on: 26162    
Bug Blocks:    
Attachments: Bug 26986: Prevent Selenium's StaleElementReferenceException
Bug 26986: Prevent Selenium's StaleElementReferenceException
Bug 26986: Prevent Selenium's StaleElementReferenceException

Description Jonathan Druart 2020-11-10 10:37:23 UTC
This is a follow-up bug for bug 26162

The test is still failing:
STRACE: /usr/share/perl5/Try/Tiny.pm:123 in Selenium::Remote::Driver::catch {...}                                                                                                             
        /usr/local/share/perl/5.28.1/Selenium/Remote/Driver.pm:353 in Try::Tiny::try                                                                                                                  (eval 1687):1 in Selenium::Remote::Driver::__ANON__                                                                                                                                   
        (eval 1689):2 in Selenium::Remote::Driver::__ANON__                                                                                                                                   
        /usr/local/share/perl/5.28.1/Selenium/Remote/Driver.pm:1331 in Selenium::Remote::Driver::_execute_command
        /usr/local/share/perl/5.28.1/Selenium/Remote/Driver.pm:1331 in (eval)
        /kohadevbox/koha/t/lib/Selenium.pm:126 in Selenium::Remote::Driver::find_element
        t/db_dependent/selenium/administration_tasks.t:137 in t::lib::Selenium::fill_form

The screenshot is showing the library list, which means the edit button has not been clicked.

In the selenium logs there is:
12:44:39 selenium_1   | 03:44:38.642 WARN - Exception: Unable to locate element: {"method":"xpath","selector":"//*[@id=\"branchname\"]"}
12:44:39 selenium_1   | For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Comment 1 Jonathan Druart 2020-11-10 10:38:58 UTC
Created attachment 113337 [details] [review]
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.
Comment 2 Victor Grousset/tuxayo 2020-11-10 11:38:34 UTC
Created attachment 113360 [details] [review]
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 <victor@tuxayo.net>
Comment 3 Victor Grousset/tuxayo 2020-11-10 12:55:14 UTC
As for code change, it's simple and looks good.
Comment 4 Martin Renvoize 2020-11-17 08:58:52 UTC
Created attachment 113688 [details] [review]
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 <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 5 Martin Renvoize 2020-11-17 08:59:56 UTC
Run the tests in a loop for a while and couldn't trigger an error.. mind you, I couldn't when I did the same with the first attempt to fix either.

Code seems sane, fingers crossed it resolves the issue more long term.

Passing QA
Comment 6 Jonathan Druart 2020-11-17 11:26:22 UTC
Pushed to master for 20.11, thanks to everybody involved!
Comment 7 Andrew Fuerste-Henry 2020-12-09 20:29:44 UTC
Pushed to 20.05.x for 20.05.07
Comment 8 Victor Grousset/tuxayo 2020-12-10 14:04:12 UTC
Backported to 19.11.x branch for 19.11.13