Closed Lightning00Blade closed 3 months ago
@Lightning00Blade if id
and name
are given which should be prioritized? What if both have different values? How does the client know if it's the id
or name
? Maybe both would be needed?
I can see a point of this not only when the browsing context is created, but when the getTree
is called.
To answers Henrik question, in CDP the name is always top priority, then it's the id. and
<iframe name="TheFrameName" id="TheFrameId"></iframe>
Frame.name => "TheFrameName"
CDP does not provide a way to differentiate if it's a name
or id
.
To answers Henrik question, in CDP the name is always top priority, then it's the id. and
<iframe name="TheFrameName" id="TheFrameId"></iframe> Frame.name => "TheFrameName"
CDP does not provide a way to differentiate if it's a
name
orid
.
Can we extend CDP with it? It seems meaningful.
The Browser Testing and Tools Working Group just discussed Frame name
.
I have been thinking about this use case again and I wonder if Puppeteer's API actually makes sense here:
1) it only gives access to the name/ID set at the iframe creation time => so might not match the current DOM state. 2) it does not differentiate between ID and name. 3) it is also possible to achieve similar results using locators OR script evaluation. 4) it is only applicable to iframes and not top-level browsing contexts.
So if we include it in the WebDriver BiDi spec, we could solve the issue No 2 by listing the fields (ID, name) separately but the issue No 1, 3 and 4 remain since the browsingContextInfo is not emitted if DOM changes and for implementations (e.g., CDP) it might be not very straight-forward to implement the sync of the DOM attributes with the browsing context tree. I would suggest that we consider deprecating this API and instead directing users towards the locator/selector API in Puppeteer? cc @Lightning00Blade @sadym-chromium
@Lightning00Blade and @sadym-chromium any feedback from you regarding the suggestions from @OrKoN? Quite a few tests are failing because of this issue. Thanks!
I filed a feature request in puppeteer to deprecate Frame.name()
. @Lightning00Blade consider closing this issue.
Given that https://github.com/puppeteer/puppeteer/pull/12084 is merged and already released I assume we can close this issue? @sadym-chromium @Lightning00Blade
Given that puppeteer/puppeteer#12084 is merged and already released I assume we can close this issue? @sadym-chromium @Lightning00Blade
sure!
In CDP when there is a new
Frame
created it's possible to collect the data about it's element attributename
orid
. Ref: Page.Frame.nameThe proposed solution would be add a property on the
browsingContext.contextCreated
return type calledname
(oridentifier
), that will betext / null
of either the frame's element attributeid
orname
.Example of such scenarios where this is useful:
This will expose only the initial name on creation as after that the attribute may change by scripts or script evaluation. For the up to date users use script evaluation.