It is a bit unreliable, but if you write your tests with all concerns in mind they should always pass.
Inconsistent StaleElementReferenceException and NoSuchElementException test errors with Laravel Dusk
I am frequently running a test suite of around 250 tests. Everytime I run this test suite I am getting inconsistent errors returned for what seems like different tests each time. An example of inconsistent errors that are returned:
Facebook\WebDriver\Exception\StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: headless chrome=65.0.3325.146)
(Driver info: chromedriver=2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752),platform=Linux 4.9.125-linuxkit x86_64)
/var/www/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:108
/var/www/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:331
/var/www/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:565
/var/www/vendor/facebook/webdriver/lib/Remote/RemoteExecuteMethod.php:40
/var/www/vendor/facebook/webdriver/lib/Remote/RemoteWebElement.php:240
/var/www/vendor/laravel/dusk/src/Browser.php:267
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:141
/var/www/vendor/laravel/framework/src/Illuminate/Support/Traits/EnumeratesValues.php:176
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:147
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:70
/var/www/modules/Venues/Tests/Browser/Venue/VenueTagsTest.php:73
Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"tag name","selector":"body"}
(Session info: headless chrome=65.0.3325.146)
(Driver info: chromedriver=2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752),platform=Linux 4.9.125-linuxkit x86_64)
/var/www/vendor/facebook/webdriver/lib/Exception/WebDriverException.php:102
/var/www/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:331
/var/www/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:565
/var/www/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:204
/var/www/vendor/laravel/dusk/src/Browser.php:264
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:141
/var/www/vendor/laravel/framework/src/Illuminate/Support/Traits/EnumeratesValues.php:176
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:147
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:70
/var/www/modules/Venues/Tests/Browser/Venue/ResourcesTest.php:87
They don't provide a failure screenshot and the stacktrace takes you to the closing } of the test rather than an actual line in the test so I could only assume there is an issue before the actual test begins
I've tried making various changes to the test themselves, added waits and added sleeps but none were able to get rid of the issues. They seem to occur 3/10 times that a test is run. Any suggestions would be greatly appreciated and please let me know if I have not left enough detail, am happy to provide more
Please or to participate in this conversation.