Skip to main content
Version: 9.0.0

Iframes

Iframes are commonly used in Pega, their ids are changeable, and it takes time for the iframe to be fully uploaded. It's not always possible to switch to the iframe even if it's already visible on the screen. However, Pega Model methods allow iframes handling in easy and stable way.

As a rule, Pega iframe element has an id that contains "PegaGadget" as a part of value. That's why we are looking for the iframe with "PegaGadget" partial id which is blocking the display. Be careful, sometimes you might need to switch between the iframes (e.g. standard Pega search field is always in the main iframe, as well as the operator's avatar or the document-statetracker element) or pass through the chain of iframes (luckily, it doesn't happen very often). If you are not inside the iframe with the certain element and you`re trying to interact with, the element is not visible and do not exist for the testing framework (despite the fact that you can see it on the screen).

If the application is stable and fast enough, you can use a simple switch function:

await pega.switchToWorkAreaIframe();

If you know the performance is not the best and the application might need more time to have the iframe fully uploaded, use more "safe" method:

await pega.switchToTheWorkAreaIframeAndWaitForTheElement(`waitForSelectorToBeVisibleSelector`, timeout);

In this case, a method is retrying a switch action until the element passed as a parameter is finally visible (or the timeout expires).

Usually, there is no issue with the main iframe (just don`t forget to switch on time):

await pega.switchToDefault();