0

elements not expanded imagem

I don't know why the elements are not expanded, when I execute the command it gives this error

Uncaught TypeError: Cannot read properties of null (reading 'querySelectorAll')

*Now when I open the elements up to the specific span the command works * elements expanded imagem

const parentElement = document.querySelector('h2.prompt-text');
let allChildren = parentElement.querySelectorAll(":scope > span"); console.log(allChildren[0].innerText)
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 23 '23 at 08:23
  • So `querySelector` did not find the element and it is null. You are probably reading the element before it exists. Expanding the element view does nothing for JavaScript. Maybe the context of your console changed. – epascarello Jan 23 '23 at 15:22

1 Answers1

0

The captcha is rendered in the Iframe tag, You can get elements in Iframe with the below code:

var iframe = document.getElementById("myFrame");
var elmnt = iframe.contentWindow.document.querySelector("h2.prompt-text");
...
Iman Rabbi
  • 271
  • 1
  • 2
  • Didn't work, `Uncaught TypeError: Cannot read properties of undefined (reading 'document')` I used getElementsByTagName because the iframe doesn't have an id or class, I use `const parentElement = document.querySelector('h2.prompt-text'); let allChildren = parentElement.querySelectorAll(":scope > span"); console.log(allChildren[0].innerText)` works fine, but only if the body of the iframe is expanded – ChristianMattos Jan 22 '23 at 19:58