TestProject Forum
Powered by leading experts in the test automation community

CSS Selectors for documents inside their own iframe

How would i write a simple selector (e.g. by class or Id) for an element that is nested inside an iframe ?

for example:

<html>
<body>
....
<iframe src="/resources/demo/webdemo.html" class="demo-iframe">
    <!DOCTYPE html>
    <html lang="en">
        <head>
        </head>
        <body>
              <div id="example"></div>
        </body>
    </html>
</iframe>
....
</body>
</html>

How to select the div with the id “example” ?

I don’t think it is possible.

As far as CSS is concerned, it only applies searches to html root. and an iframe is located in another document and therefore not under html root