Skip to content

Page.navigate loads in an inactive tab #547

@ngugcx

Description

@ngugcx

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions