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.

zlaval
  • 1,941
  • 1
  • 10
  • 11

1 Answers1

0

Please change this

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

Then

WebElement elmnt = driver.findElement(By.id("reality-check-period"));
frianH
  • 7,295
  • 6
  • 20
  • 45