You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to read all frames via Page.getFrameTree(). It works at the start. The frames are all visible. But after a short moment a FrameDetached, Reason: swap-event is fired.
Now the question is, how to “handle” this correctly?
http://127.0.0.1:9222/json/list shows the correct IFrames. However, Page.getFrameTree() does not - although I would expect it to.
Unfortunately, this topic has not (yet) been dealt with here. Puppeteer seems to have found a way to do this, but I couldn't find the right place in the code base. Probably because Puppeteer pays attention to Target.targetCreated at the same time?
It also feels as if the IFrame is a “separate process”. If I connect directly via CDP({ target: webSocketDebuggerUrl }) (while webSocketDebuggerUrl is the url to the IFrame; parentId is the page which contains that IFrame), then it works.
Example
constCDP=require('chrome-remote-interface');asyncfunctionmain(){// I don't have an example (yet).}main().catch((error)=>{console.error(error);});
The text was updated successfully, but these errors were encountered:
0x7357
changed the title
How to properly handle iframe "swaps" (Detach Reason: "swap")?
How to properly handle iframe "swaps" (FrameDetached, Reason "swap")?
May 11, 2024
I already can see that. The whole topic has already been discussed and my “feeling” has somehow been confirmed. It's probably about “OOPIFs” and that makes the story quite complex. Has anyone perhaps already realized this with chrome-remote-interface?
Well, the protocol is the same, so whatever works in Puppeteer, should work here too. The protocol however is complex, mostly experimental, and I have nothing to do with that. Whenever I face similar issues I just read the terrible documentation available and I proceed by trials and errors.
Having said that, it's not clear to me what your problem is... You can register for events and react the way you want. You can CDP.List targets and connect to them. However if you plan to interact with multiple targets, I think it's better to connect to the browser target, certain things are not available via regular targets IIRC.
Environment
Is the client running in a container? NO
Description
I am trying to read all frames via
Page.getFrameTree()
. It works at the start. The frames are all visible. But after a short moment aFrameDetached, Reason: swap
-event is fired.Now the question is, how to “handle” this correctly?
http://127.0.0.1:9222/json/list
shows the correct IFrames. However,Page.getFrameTree()
does not - although I would expect it to.Unfortunately, this topic has not (yet) been dealt with here. Puppeteer seems to have found a way to do this, but I couldn't find the right place in the code base. Probably because Puppeteer pays attention to
Target.targetCreated
at the same time?It also feels as if the IFrame is a “separate process”. If I connect directly via
CDP({ target: webSocketDebuggerUrl })
(while webSocketDebuggerUrl is the url to the IFrame;parentId
is the page which contains that IFrame), then it works.Example
The text was updated successfully, but these errors were encountered: