More about iFrames

Learn about iFrame limitations and troubleshooting steps.

Sandbox (HTML5)

Objects cannot be retrieved from an iFrame that contains a Sandbox attribute, as shown in the following example.

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

The value of the sandbox attribute can either be sandbox (in this case, all restrictions are applied) or a space-separated list of pre-defined values that will remove the particular restrictions.

To learn more about sandbox, see HTML <iframe> sandbox Attribute.

The following example shows 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 this, 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.