Selenium – test iframe inside shadow dom

  angular, iframe, protractor, selenium, shadow-dom

I have an angular app with enabled ViewEncapsulation.ShadowDom, inside which there is an iframe.
When I’m trying to write protractor test I’m getting an error:

Failed: unknown error: no element reference returned by script

While I’m able to actually get web element, I can’t perform any actions with it.

const root = element(by.css('app-root')).getWebElement();
      .executeScript('return arguments[0].shadowRoot', root)
      .then((shadowRoot: WebElement) => {
              console.log("EL:",el); //logs element
              browser.actions().mouseMove(el).perform(); //throws error

Is there a way to properly switch to iframe nested in shadow dom?

Source: Angular Questions

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.