0

I have a simple iframe presenting a URL (any, in this case: https://www.saucedemo.com/inventory.html).

The goal is to get inside the iframe and gather various amounts of data, or elements. For example, find all buttons.

Everytime I try to access the element I get this error: SecurityError: Blocked a frame with origin "http://localhost:3000" from accessing a cross-origin frame.

The Capture function:

import $ from "jquery";

function Capture (){
  var $myFrameDocument = $ ('#test_website').contents().find("button");
  console.log($myFrameDocument);
}

export { Capture };

That returned an empty array (didn't seem to find anything).

I attempted to grab the document and that's when I got the cross origin error:

  var doc = $ ( '#test_website' )[0].contentWindow.document ;
  console.log(doc);

I'm sure how to go about this.

I have tried a useding <embed> as an alternative but similarly I recieve an emty array.

Robolisk
  • 1,442
  • 2
  • 17
  • 33
  • Does this answer your question? [SecurityError: Blocked a frame with origin from accessing a cross-origin frame](https://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame) – pintxo Aug 13 '20 at 19:40

0 Answers0