Unable to locate shadow DOM Elements

Hello,

I’m having trouble locating elements that are in DOM shadows at multiple levels, which themselves depend on where they are located in an iframe.
I understand that you first have to locate the shawdow host and then locate the element in this shadow DOM tree by referring to the shadow host.

In my example, I succeeded in defining the location of the top-level shawdow host within an iframe.

But then I run into a problem locating the level 2 shawdow host, even though I seem to have followed the instructions correctly.

Knowing that my final goal is still to explore the second level to reach the element I really want.

Could you help me identify what I must have done wrong? Thank you for your help

1 Like

I don’t see a WebUI.switchToFrame('myPage/iframe_m3h5') in your script, which you should need to move to the <input> object that is “under” the <iframe>.

After finally using your <input> object “under” the <iframe> (setText, verify…) and before your next instruction, then don’t forget to WebUI.switchToDefaultContent().

[WebUI] Switch To Default Content | Katalon Docs

did you try context switch and still failing?

Hello,

No - I didn’t use the WebUI.switchToFrame instruction because, for the moment, I thought I could just use the 2 Settings options which are : Parent iframe and Shadow Room Parent.

But as I said in my previous answer, does this mean that this technique doesn’t work properly when there are cascading shadows?

Denis

Hello,
Thanks for your help
But maybe I’m explaining myself wrong, but I can locate my first shadow root, which is in an iframe.
I didn’t need to use the WebUI.switchToFrame instruction because in the settings for the first shadow I was looking for, I used the Parent iframe option in the settings.
However, it’s when I search for my second shadow from this first shadow, this time using the Shadow Room Parent option in the settings, that I run into a localization problem.

Should I conclude from this that when there are too many shadows in cascade, I shouldn’t use the Shadow Room Parent option? And that I should switch to developer mode by writing a few lines of script?

According to the document, it sounds like you have it.

Maybe we need Katalon staff here to ensure their documentation is still correct. @Elly_Tran, can you verify if @dmarette has it correct?

And something else for you to review. KS v10 is supposed to be on Selenium 4.

1 Like

Hello everyone,

Thanks to your posts in which you mentioned the explicit use of WebUI.switchToFrame, I used this technique to select my iframe rather than just using the Parent iframe option (which is supposed to do the same thing).

And by doing so, the search for the various shadow objects at multiple levels inside this iframe no longer ends in failure and is now correct. :+1:

I’ve come to the conclusion that this is the best way to go in my context and that there are limits to searching for shadow objects nested within an iframe using only the Parent iframe and Shadow Room Parent properties.

Denis

1 Like

Hi @dmarette,

It’s great to see that you gain a lot by now. Are you satisfied with what you found out now or would you like to discuss anything more in details? We are willing to support.

At this stage, it’s okay with me. Thanks for the community support. :wink:

Denis

3 Likes