1

I have the following unusual use case. I detail it below

1) I'm on an angular page & I do some actions on the page [It loads a non-angular iFrame]

2) I switch to the non-angular iframe & interact with some screens.

3) Eventually this causes redirection to happen back to an angular page.

When I use protractor for step 2 I have to use it with flag browser.ignoreSynchronization set to false as it is non-angular. I need a way to check whether the form I'm interacting with is angular or not to help with a smooth transition from steps 2) to 3).

I know you can check for angular capabilities automatically on a page using

browser.executeAsyncScript or browser.executeScript along with

!!window.angular (angular v1)

!!window.getAllAngularTestabilities (angular v2)

but this doesn't work in this use case as all of these will return true regardless of whether you are interacting with the non angular iframe or not. Would anyone have any other suggestion that may work for a use case like this? Many thanks in advance.

bhreinb
  • 181
  • 2
  • 13

1 Answers1

1

What I normally do when I need to automate an iframe is the following

// 1) When you know the iframe is there
browser.switchTo().frame(0);

// 2 a) You don't need to disable the wait for anguler, just use vanila webdriver, it will work on both
browser.driver.findElement(by.css('.your-css-selector'));
// Do some more interaction
browser.driver.findElement(by.css('.input-css-selector')).sendKeys('type something');
browser.driver.findElement(by.css('.button-css-selector')).click());

// 2b) Or now just use the Protractor syntax, 
//     because you switched you should be able to use it now.

// 3) Switch back
browser.switchTo().defaultContent();

// 4) Check for example with Protractor expectedConditions if the iframe is gone
var EC = protractor.ExpectedConditions;
// Waits for the ifram to be no longer present on the dom.
browser.wait(EC.stalenessOf($('iframe')), 5000);

As you see there is no need to do browser.ignoreSynchronization = true;

I hope this helps

wswebcreation
  • 2,365
  • 2
  • 10
  • 18