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
This error message...
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)
and this error message...
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)
...implies that the ChromeDriver was unable to interact with the Browsing Context ie Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
Supports Chrome v63-65
So apparently chromedriver=2.36 and chrome= 65.0 are compatible but may not be compatible with current release of Selenium Client v3.141.59 .
Ensure that:
@Test
as non-root user.driver.quit()
within tearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.Wanted to comment but stack overflow won't let a newb add a comment. This is probably not an answer per say, but a suggestion.
Try adding a static wait before the element is addressed. Or when you debug, add a break point before where the exception occurs. Usually waiting a hair longer addressed the issue.
If that seems to work well, then consider implementing an explicit wait for the element to be displayed and enabled before addressing the element.
In some cases, even when the explicit wait returns, you might still have to do a very small static wait. Sometimes elements are still sliding around, so to speak.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.