Improving iframe Performance

Replaying tests against web applications that contain many iframes on browsers other than Internet Explorer might sometimes be slow. This topic provides some performance optimization suggestions when using the following browsers:
  • Google Chrome
  • Mozilla Firefox
  • Microsoft Edge
  • Apple Safari
  • A supported mobile browser on a mobile device or on an emulator.

If you are facing such performance issues, you could try to apply some performance optimizations to your test scripts.

For example, assume that you are testing against a web application with an iframe structure that looks similar to the following:
BrowserWindow
  iframe name=1
    iframe name=2
    iframe name=3
    iframe name=4
    iframe name=5
  iframe name=6
    iframe name=7
    iframe name=8
    iframe name=9
You could try to apply one or more of the following performance optimizations:
Using the Include list for iframe support to enable only the iframes that you are interested in
For example, in the previous iframe structure, assume you only want to interact with elements in the iframe with the name 8. A locator for such an element would look like the following:
//BrowserApplication//BrowserWindow//IFRAME[@name='6']//IFRAME[@name='8']//input[@name='username']
Note: All supported browsers except Internet Explorer include iframes in the locator.

To interact with the elements from the iframe with the name 8, you need to also include all parent iframes in the Include list for iframe support. For this example, type name:6, name:8 into the Include list for iframe support field.

Using the Exclude list for iframe support to disable the iframes that you are not interested in

You can use the Exclude list for iframe support to disable iframes that you are not interested in, for example iframes for ads.

For example, in the previous iframe structure, if you know that you will never test elements in the iframe with the name 1 or in its child iframes, type name:1 into the Exclude list for iframe support field.

Completely disabling iframe support

You can completely disable the iframe support by setting the Enable iframe support option to No.

For example, if all iframes in your application are only used for ads, and you do not want to test any of these iframes, you can use this option.

Adapt locators to reduce the number of iframe searches

To enhance the replay performance of find actions, you can adapt the locators to reduce the number of iframe searches. Applying this performance optimization might work very well in combination with using the Exclude list for iframe support or Include list for iframe support.

For example, in the previous iframe structure, assume you only want to interact with elements in the iframe with the name 8. You can adapt the Xpath locators or the object map entries to reduce the number of iframe searches.

The following sample script searches multiple times for the iframe with the name 8.
' VB code
With _desktop.BrowserApplication("//BrowserApplication")
  With .BrowserWindow("//BrowserWindow")
    .DomElement("//IFRAME[@name='6']//IFRAME[@name='8']//input[@name='username']").TypeKeys("my user name")
    .DomElement("//IFRAME[@name='6']//IFRAME[@name='8']//input[@name='password']").TypeKeys("top secret")
    .DomElement("//IFRAME[@name='6']//IFRAME[@name='8']//input[@name='loginButton']").Click()
  End With
End With
You can adapt the locators in the previous sample script to only search once for the iframe with the name 8.
' VB code
With _desktop.BrowserApplication("//BrowserApplication")
  With .BrowserWindow("//BrowserWindow")
    With .DomElement("//IFRAME[@name='6']//IFRAME[@name='8']")
      .DomElement("//input[@name='username']").TypeKeys("my user name")
      .DomElement("//input[@name='password']").TypeKeys("top secret")
      .DomElement("//input[@name='loginButton']").Click()
    End With
  End With
End With