0

I'm new with Selenium, just try to help the tester guy. We try to find an element in shadow-dom with Selenium but Selenium don't find it. I tried other post's solutions, but thats didn't work for me either.

My DOM:

<iframe>
  #document
    <html>
     <body>
       <div>
         <div>
           <div id="reality-check-period">

           </div>
         </div>
       </div>
    </body
   </html>
</iframe>

I was able to find the iframe, but i need to locate the div with id 'reality-check-period'.

Try to return with arguments[0] etc.

WebElement iframe = driver.findElement(By.tagName("iframe"))
driver.switchTo().frame(iframe);

We use Chrome driver 74.0.3729.6

Any suggestion would be appreciated.

enter image description here

Edit: As I mentioned .shadowRoot not work for me, because the DOM contains #document under the IFrame and not #shadow-root.

0

1 Answer 1

0

Please change this

driver.switchTo().frame("notificationIframe");

Then

WebElement elmnt = driver.findElement(By.id("reality-check-period"));
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks but it won't work, because the reality-check-period div is inside the shadow dom.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.