-
Notifications
You must be signed in to change notification settings - Fork 309
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
feat: add sendRaw function #441
Conversation
Nice addition, AFAIK this is necessary to support commands like |
@Niek what's the use of this method since is only available from the browser session itself? |
Now |
@flotwig hmm in stdio mode you're already in the "browser target", as you can perform operations like |
Ah yeah, we should be talking about Is there another way to attach to a per-tab target from the browser target besides calling |
No OK, my question was (for @Niek) about
@flotwig the alternative is the deprecated BTW, I can't seem to make it work, Chrome simply doesn't reply anything to messages that include a
Where
|
With the only exception, funnily enough, of the |
@cyrus-and Sorry, I tested the new branch and it works great: → ./bin/client.js inspect
>>> Target.getTargets()
{
targetInfos: [
{
targetId: 'C104A7A2F6C6B29840C1EAFD9E7F4A22',
type: 'page',
title: 'about:blank',
url: 'about:blank',
attached: true,
canAccessOpener: false,
browserContextId: 'C689EBAB4EF2567951424D1C7E0794FA'
}
]
}
>>> Target.attachToTarget({targetId: 'C104A7A2F6C6B29840C1EAFD9E7F4A22'})
{ sessionId: '5B8328334DD51F8EFDBD17C941C42C58' }
>>> Page.navigate({sessionId: '5B8328334DD51F8EFDBD17C941C42C58', url: 'https://github.com'});
{
frameId: 'C104A7A2F6C6B29840C1EAFD9E7F4A22',
loaderId: '78B81222D9D6211F918787268E249B9B'
} Looking forward to see this released! |
@Niek uhm, I'm afraid it doesn't work that way, you're just passing In the new branch the correct syntax is: Page.navigate('5B8328334DD51F8EFDBD17C941C42C58', { url: 'https://github.com'}) But it hangs, as I pointed out in this comment (where I use the browser target, which I think is the only context where the I'm not aware of your use case but it looks like you don't really need to use |
@cyrus-and Oops, I feel silly. This is the way to get it working (you need to flatten the session): >>> Target.getTargets()
{
targetInfos: [
{
targetId: 'AE5249680D5E2E5FE1AEBC1FE029EC8F',
type: 'page',
title: 'about:blank',
url: 'about:blank',
attached: true,
canAccessOpener: false,
browserContextId: '1FB2FCD4E41A007E3938DED4678A5933'
}
]
}
>>> Target.attachToTarget({targetId: 'AE5249680D5E2E5FE1AEBC1FE029EC8F', flatten: true})
{ sessionId: '8C45BC912828F26DD634268FF23A1570' }
>>> Page.navigate('8C45BC912828F26DD634268FF23A1570', {url: 'https://github.com'});
{
frameId: 'AE5249680D5E2E5FE1AEBC1FE029EC8F',
loaderId: '2154A11FF6AE82267E2BE7ABA9C7D7B7'
} |
My 2c on this: for simply navigating a page the sessionId is useless, however there are other cases where it's really useful. See for example this bugreport: https://bugs.chromium.org/p/chromium/issues/detail?id=1070568 Without sessionId it's impossible to attach to all targets in time. In addition, the Chromium developers are moving towards supporting sessionId only. So this is a very important feature to have IMHO. |
LOL now I feel silly, I thought it was enabled by default...
That makes perfectly sense, thank you.
Yup, let me clean up a few things and I'll merge it in a few hours. |
Allow to filter events by `sessionId`. There is one gotcha that when using promises without filter, the `sessionId` is not returned due to the limitation of promises to return only one value, and the fact that changing the return type would be a breaking change. Related to #441.
There is one problem though, events should support The event filtering part should be fairly easy to implement, the only problem raises when events are registered via a promise and without any |
I pushed a possible implementation in that branch. |
Allow to filter events by `sessionId`. There is one gotcha that when using promises without filter, the `sessionId` is not returned due to the limitation of promises to return only one value, and the fact that changing the return type would be a breaking change. Related to #441.
Allow to filter events by `sessionId`. There is one gotcha that when using promises without filter, the `sessionId` is not returned due to the limitation of promises to return only one value, and the fact that changing the return type would be a breaking change. Related to #441.
Allow to filter events by `sessionId`. There is one gotcha that when using promises without filter, the `sessionId` is not returned due to the limitation of promises to return only one value, and the fact that changing the return type would be a breaking change. Related to #441.
@cyrus-and looks great, thanks! |
Closes #439
Adds a
sendRaw
function that lets the user manually construct a CDP message. This way, the user has control over parameters likesessionId
, unlocking the full capabilities of CDP.