(webdriverio): implement deep lookup with Bidi#12446
Conversation
| node as any as HTMLElement | ||
| ).then((wasFound) => wasFound ? host : undefined), | ||
| ...shadowRoots.map((shadowRootId) => ( | ||
| browser.execute( |
There was a problem hiding this comment.
This is never awaited and I think that might cause race conditions when the promise is not yet resolved and is put into the execute function
There was a problem hiding this comment.
It doesn't need to because it is a parameter within a Promise.all which takes a list of promises and resolves them. It is done this way so that all look ups happen in parallel.
| ...shadowRoots.map( | ||
| (shadowRootNodeId) => browser.findElementsFromShadowRoot(shadowRootNodeId, using, value) | ||
| .then( | ||
| elementPromiseHandler<ElementReference[]>(handle, shadowRootManager, shadowRootNodeId), |
There was a problem hiding this comment.
Should we run this only once, store the result and pass it on twice instead?
There was a problem hiding this comment.
I am not sure if this would make it that much more efficient, especially since elements change, show up or disappear. It makes it easier to just query elements again rather than caching results and worrying about when to clear the cache etc.
|
Since we do a lot of mapping I am wondering if it would make sense to use a WeakMap in some places, what do you think? |
Yeah, I always forget this exists. |
d436fa9 to
12d903b
Compare
12d903b to
07e7b3a
Compare
Proposed changes
With Bidi we can now inject a script to collect all initiated shadow roots in order to do a deep lookup effeciently.
Types of changes
Checklist
Backport Request
//: # (The current
mainbranch is the development branch for WebdriverIO v9. If your change should be released to the current major version of WebdriverIO (v8), please raise another PR with the same changes against thev8branch.)v9and doesn't need to be back-ported#XXXXXFurther comments
Thanks @erwinheitzman for coming up with this idea.
Reviewers: @webdriverio/project-committers