Skip to content
This repository was archived by the owner on Nov 24, 2018. It is now read-only.
This repository was archived by the owner on Nov 24, 2018. It is now read-only.

Evaluating Scripts inside of iframes #359

@ghost

Description

Hi there,
I am on a team that is trying to test a website that includes an iframe to a third-party component hosted on a different server. We need to be able to detect DOM events on document elements inside this iframe but I am running into the following error:

(node:17244) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame 
with origin "https://oursite.com" from accessing a cross-origin frame.

Is there a way to disable the same origin security policy in the automatically launched instance of Chrome started by Chromeless? Or would it be best just to start a local instance of Chrome with the --disable-web-security ?

Additional Details:
Our code looks as follows (hosts/urls changed):

async function run() {
  const chromeless = new Chromeless()

  var extIframePresent = await chromeless.goto('https://oursite.com/ourpage')
    .wait(4000)
    .evaluate(()=>{
        var extIframe = document.getElementsByClassName('container-with-3rd-party-iframe')[0].getElementsByTagName('iframe')[0];
        extIframe = extIframe.contentDocument || extIframe.contentWindow.document;
        extIframe = extIframe.contentDocument;

        return extIframe;

    });
    console.log('extIframePresent = ', extIframePresent);
    

}

run()

Activity

bubakazouba

bubakazouba commented on Jun 18, 2018

@bubakazouba

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bubakazouba

        Issue actions

          Evaluating Scripts inside of iframes · Issue #359 · schickling/chromeless