Does it need to capture #dcoument which locate below in iframe when capturing locators using CSS locators for Selenium WebDriver?

I have below DOM structure, since it’s inside of a Shadow DOM, I am using CSS locators to capture the elements.

I want to access html tag which below the iframe , but as per the DOM tree structure., it’s inside of #dcoument, so do I need to go to #dcoument ?

Answer-

First capture the iframe using the element above it .

This is the element above the iframe.

// Using sn_polaris_layout, capture the iframe using tag.

Then, there is #document but no need to capture it, simply switch to the iframe.

Since now inside of iframe using class can capture the elements inside of it.

Full code is as per below.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store