More about iFrames

This article provides iFrame limitations and troubleshooting information.

Sandbox (HTML5)

Objects cannot be retrieved from an iFrame that contains a Sandbox attribute

Copy
<iframe src="demo_iframe_sandbox.htm" sandbox></iframe>

The value of the sandbox attribute can either be just sandbox (then all restrictions are applied) or a space-separated list of pre-defined values that will REMOVE the particular restrictions.

More about Sandbox can be found here.

Example of how to use sandbox to enable Perfecto commands:

Copy
<iframe src="demo_iframe_sandbox_origin.htm" sandbox="allow-same-origin allow-scripts"></iframe>

Possible errors include

  • Cross Domain Error (switchTo)
  • Invalid Path To Frame (switchTo)
  • The Path Doesn't Point To a Frame (switchTo)
  • Scopes - Cross Domain Error
  • Scopes - Cannot Evaluate xPath Expression
  • Scopes - The Path Doesn't Point To a Frame
  • Script Execution Not Supported For Target Frame

iFrame loading time

When you browse to a page with iFrame, it is not enough to use BrowserSync because BrowserSync does not wait for IFrames to load.

The iFrame may still be loading even when the main page has completed loading.

To solve - Create a loop where you wait for the iFrame to load. You can check that it loads by checking if a specific elements is there.