Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not load iframe in https://todayjackpotresult.com in jsdom #3643

Open
fancy45daddy opened this issue Dec 23, 2023 · 0 comments
Open

can not load iframe in https://todayjackpotresult.com in jsdom #3643

fancy45daddy opened this issue Dec 23, 2023 · 0 comments

Comments

@fancy45daddy
Copy link

Basic info:

  • Node.js version: v21.2.0
  • jsdom version: "jsdom": "^23.0.1"

Minimal reproduction case

import jsdom from 'jsdom'

const virtualConsole = new jsdom.VirtualConsole()
const userAgent = await jsdom.JSDOM.fromURL('https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome', {virtualConsole}).then(_ => _.window.document.evaluate('//span[@Class="code" and contains(text(), "Linux x86_64")]/text()', _.window.document, null, 2, null).stringValue)
const resources = new jsdom.ResourceLoader({userAgent})

const window = await jsdom.JSDOM.fromURL('https://todayjackpotresult.com', {virtualConsole, runScripts:'dangerously', resources, pretendToBeVisual:true}).then(_ => .window)
console.log(window.document.querySelector('iframe[id^=google_ads_iframe
]').id)

output: TypeError: Cannot read properties of null (reading 'id')

How does similar code behave in browsers?

(Link to a jsbin or similar strongly suggested.)

If I open the url: https://todayjackpotresult.com in chrome 119.0.6045.159 in the console input console.log(window.document.querySelector('iframe[id^=google_ads_iframe_]').id)

the output is google_ads_iframe_/22994204070/Articlead_0

Any idea how to make jsdom like that in chrome?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant