0

Recently i was trying to traverse the DOM in Google Chrome's console.cant traverse inside #document

var list = document.querySelectorAll('.g-recaptcha>div>div'); 
console.log(list)

i don't know how to go inside #document. Please someone help. Found this article about #document

But the link i provided is of #document problem in selenium web driver. I am not using selenium web driver and I just want to know how can i traverse the #document using css selector or anyother javascript solution.

Aniket Bose
  • 45
  • 1
  • 5
  • Does this answer your question? [jQuery/JavaScript: accessing contents of an iframe](https://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe) – freedomn-m May 26 '21 at 16:49
  • I know knothing about Jquery. Only know pure javascript – Aniket Bose May 26 '21 at 16:51
  • https://stackoverflow.com/questions/926916/how-to-get-the-bodys-content-of-an-iframe-in-javascript -----> this link suggest to first get the iframe by queryselector let that be, var iframe = document.querySelector('.g-recaptcha>div>div>[title]'); and then use iframe.contentDocument and iframe.contentWindow.document in case of iframe.contentDocument it's returning null and in case of iframe.contentWindow.document it's giving the error --> Uncaught DOMException: Blocked a frame with origin "https://iqfaucet.com" from accessing a cross-origin frame. – Aniket Bose May 26 '21 at 17:00
  • 1
    The cross origin issue is explained in this answer: https://stackoverflow.com/a/364997/2181514 which essentially just points to wiki: https://en.wikipedia.org/wiki/Same-origin_policy – freedomn-m May 26 '21 at 17:12
  • But that didn't give any solution in pure javascript. – Aniket Bose May 26 '21 at 17:15
  • then what i should do? – Aniket Bose May 26 '21 at 17:17
  • TBH, probably not the best explained question/answer - try this question, with a lot more detail: https://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame – freedomn-m May 26 '21 at 17:18

0 Answers0