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

Page.navigate loads in an inactive tab #547

Open
ngugcx opened this issue Nov 9, 2023 · 0 comments
Open

Page.navigate loads in an inactive tab #547

ngugcx opened this issue Nov 9, 2023 · 0 comments

Comments

@ngugcx
Copy link

ngugcx commented Nov 9, 2023

Environment

Component Version
Node.js v18.16.1
Client (Chrome/Chromium/...) Chromium
OS running Node.js Windows 11
OS running the client Windows 11
chrome-remote-interface 0.33.0

Is the client running in a container? NO

Description

I create a new target and activate it, then want to load a url in the new tab, but it's loaded in one of the old inactive tab.
After printing out all targets, I find that the new target is not attached:

  {
    targetId: 'B6EE69DA83EE0250549E75E0A3FCB546',
    type: 'page',
    title: '',
    url: 'about:blank',
    attached: false,
    canAccessOpener: false,
    browserContextId: 'E73126F5922E3512A5440DA4BAAA1EBD'
  }

Example

const client = await CDP({ host, port }
const target = await client.Target.createTarget({ url: '', newWindow: false })
await client.Target.activateTarget({ targetId: target.targetId })
await client.Page.navigate({ url })

I also tried to attach the new target, but it makes no difference:

const client = await CDP({ host, port }
const target = await client.Target.createTarget({ url: '', newWindow: false })
await this.client.send('Target.attachToTarget', {
  targetId: target.targetId,
  flatten: true
})
await client.Target.activateTarget({ targetId: target.targetId })
await client.Page.navigate({ url })

I must be doing something wrong.
Thanks for your help.

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