In my salesforce application there are multiple shadow dom elements present inside an iframe. I have used the below link and tried both the solution, but i am getting stale element reference exception, when the script tries to click on the shadow DOM element. Please suggest how can I resolve the error.
I have created a child element which I need to click ‘paper-button’ and created an another object for parent shadow dom element ‘sbPageContainer’. I have selected the Shadow root parent in the child test object and added the parent shadow dom element. I have added the iframe to the parent test object. While script tries to click the element getting the below error.
Caused by: org.openqa.selenium.StaleElementReferenceException: stale element reference: stale element not found
At object: ‘Object Repository/Page_Q-296116 Quote Salesforce/paper-button’
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_Q-296116 Quote Salesforce/paper-button’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_Q-296116 Quote Salesforce/paper-button’
Caused by: org.openqa.selenium.StaleElementReferenceException: stale element reference: stale element not found.
Now you lost me. I see three nested shadow dom elements and that statement is near impossible parse and track against the code I’m seeing. And to top it off, you’re inside an <iframe>…
Please PLEASE make it easier for us to follow.
That said, my advise is to talk directly at the page using JavaScript. You’ll find a ton of great support for accessing shadow dom stuff from JS.
shadow dom is an abomination and makes HTML insanely complicated. There is no need at all for HTML to be written like that. Encapsulated objects in a stream of text? Not clever ← stupid.