Hi @Arthur.Valijan,
Thank you for your post to the community!
From the given information, it is difficult to give the exact approach you need. As the error message says, the element is no longer accessible but this happens for different reasons, due to the website structure, network latency, the server environment, the client environment, etc. I found these pages and maybe they will help you to understand the issue and take a next step.
https://www.softwaretestingmaterial.com/stale-element-reference-exception-selenium-webdriver/
https://stackoverflow.com/questions/12967541/how-to-avoid-staleelementreferenceexception-in-selenium
As you mention it rather happens randomly, I would like to suggest to execute the script many times locally and take some statistics. It may reveal facts for the error, like on which element it happens more, in which time range happens more, etc.
We also have documentation for waiting for DOM Elements. https://docs.appdynamics.com/appd/22.x/latest/en/end-user-monitoring/synthetic-monitoring/browser-synthetic-monitoring/synthetic-scripts/wait-for-dom-elements
Hope this answer helps.
Best regards, Kenji
... View more