My goal is to be able to record traffic in multiple tabs via the CDP.
According to the documentation, I believe I should be able to have:
- A main CDP connection process which handles new target discovery (Target.targetCreated, etc)
- For each new page-target:
- Connect directly to that target with CDP
- Enable Fetch, Network, Page
- Listen and capture traffic
I understand there are some race conditions with capturing traffic at the very start of a target's life. I have some ideas to work around those limitations.
The main issue I am seeing , is that I seem unable to consistently watch the network traffic of two different targets. What are the subtle constraints on listening to / pausing traffic?
I have tried to have one CDP connection, which detects targets and "attaches" to them. This will let me record traffic on the initial tab, but subsequent tabs do not send Network.* or Fetch.* events (is there a way to make that work?)
I have tried multiple CDP connections, one per page-target, and that does not seem to consistently work either. Sometimes it does work for the new tab to receive traffic events, but then the other CDP listener clients no longer receive events.
Is it true that only one event stream can be active from chrome browser at a time?
And if so, is there a way to get the event stream for *all* tabs at once?
Or possibly there are constraints I do not see in the documentation, because *sometimes* I can get events on two CDP clients. But nothing consistent yet.
Thank you for any tips!
Cary FitzHugh