Protractor: Testing Angular App in an Iframe

Viewed 19989

I've got an interesting setup here.

I have an Angular App that loads another Angular App inside an iframe. I'm interested in testing the iframed-in Angular app with Protractor.

Protractor is waiting for the first Angular app to load, but when I switch the iframe with

ptor.switchTo().frame('experience');

I can see that Protractor is not waiting for the iframed Angular app before making assertions. I have tried adding

ptor.waitForAngular();

After switching to the iframe with no luck. Anybody have any ideas what is going on here?

Thanks!

If it helps, I'm running my tests through the Saucelabs ssh tunnel on Chrome. I can tell that the tunneling is working because I see the resources for the iframed app being requested and downloading.

3 Answers

Switching to an iframe is very simple according to latest protractor API docs 5.4.1:

await browser.switchTo().frame(element(by.xpath('//iframe')).getWebElement());

The context switches to the specified iframe, now every command that you run will be executed on the iframe. Now you can even switch to nested iframes. To switch back to parent iframe:

 driver.switchTo().parentFrame();
Related