[BUG-14514] - Switch frame to an iframe in a Shadow DOM#14589
[BUG-14514] - Switch frame to an iframe in a Shadow DOM#14589christian-bromann merged 19 commits intowebdriverio:mainfrom
Conversation
commit ed62250 Author: Vishnu Vardhan <vishnu.p@browserstack.com> Date: Wed Jun 25 16:04:25 2025 +0530 Trigger EasyCLA commit da54fcf Author: Vishnu Vardhan <vishnu.p@browserstack.com> Date: Tue Jun 24 15:59:12 2025 +0530 Comment commit ad9316e Merge: 97e851a ff2154c Author: Vishnu Vardhan <vardhan688@gmail.com> Date: Tue Jun 24 13:44:09 2025 +0530 Merge branch 'main' into bug-14514 commit 97e851a Merge: 5bb2673 24855c2 Author: Vishnu Vardhan <vardhan688@gmail.com> Date: Mon Jun 23 16:02:41 2025 +0530 Merge branch 'main' into bug-14514 commit 5bb2673 Merge: ac1ad49 d80354d Author: Vishnu Vardhan <vardhan688@gmail.com> Date: Fri Jun 20 12:58:50 2025 +0530 Merge branch 'main' into bug-14514 commit ac1ad49 Merge: 0471190 072e551 Author: Vishnu Vardhan <vardhan688@gmail.com> Date: Thu Jun 19 13:13:03 2025 +0530 Merge branch 'main' into bug-14514 commit 0471190 Merge: d70b3b1 d344dd4 Author: Vishnu Vardhan <vishnu.p@browserstack.com> Date: Wed Jun 18 16:08:30 2025 +0530 Merge branch 'bug-14514' of github.com:vishnuv688/webdriverio into bug-14514 commit d70b3b1 Author: Vishnu Vardhan <vishnu.p@browserstack.com> Date: Wed Jun 18 16:07:11 2025 +0530 Fixes webdriverio#14514 commit d344dd4 Merge: 35af439 5818efe Author: Vishnu Vardhan <vardhan688@gmail.com> Date: Wed Jun 18 15:52:47 2025 +0530 Merge branch 'main' into bug-14514 commit 35af439 Merge: 44fe5f5 41ddf78 Author: Vishnu Vardhan <vishnu.p@browserstack.com> Date: Wed Jun 18 15:48:48 2025 +0530 Merge branch 'bug-14514' of github.com:vishnuv688/webdriverio into bug-14514 commit 44fe5f5 Author: VishnuVardhan P <vishnu.p@browserstack.com> Date: Wed Jun 18 15:42:21 2025 +0530 [BUG-14514] - Switch frame to an iframe in a Shadow DOM commit 41ddf78 Author: Vishnu Vardhan P <vishnu.p@browserstack.com@Vishnus-MacBook-Air.local> Date: Wed Jun 18 15:42:21 2025 +0530 [BUG-14514] - Switch frame to an iframe in a Shadow DOM
create-wdio
eslint-plugin-wdio
@wdio/allure-reporter
@wdio/appium-service
@wdio/browser-runner
@wdio/browserstack-service
@wdio/cli
@wdio/concise-reporter
@wdio/config
@wdio/cucumber-framework
@wdio/dot-reporter
@wdio/firefox-profile-service
@wdio/globals
@wdio/jasmine-framework
@wdio/json-reporter
@wdio/junit-reporter
@wdio/lighthouse-service
@wdio/local-runner
@wdio/logger
@wdio/mocha-framework
@wdio/protocols
@wdio/repl
@wdio/reporter
@wdio/runner
@wdio/sauce-service
@wdio/shared-store-service
@wdio/smoke-test-cjs-service
@wdio/smoke-test-reporter
@wdio/smoke-test-service
@wdio/spec-reporter
@wdio/static-server-service
@wdio/sumologic-reporter
@wdio/testingbot-service
@wdio/types
@wdio/utils
@wdio/webdriver-mock-service
webdriver
webdriverio
commit: |
christian-bromann
left a comment
There was a problem hiding this comment.
Can you please provide some information about the actual bug or problem you are trying to solve here?
Thanks for the review! Just to clarify, this PR is actually fixing two separate bugs we ran into when working with switchFrame() in BiDi mode, especially in cases where the iframe is inside a Shadow DOM.
To fix this, I added a check so that we only re-resolve the element if elementId isn’t already set. That way, if we already have a valid element (from shadow$ or similar), we don’t overwrite it.
To work around this, I added a fallback that uses browser.execute() to run a script (findIframeInShadowDOM) which manually traverses the DOM and any shadow roots to find the iframe based on its src. |
|
@vishnuv688 in this case I would recommend to have an e2e test for this. We are having a test bed that is deployed to https://guinea-pig.webdriver.io/. It seems feasible to create little reproduction cases for this there and add some e2e tests for this. |
@christian-bromann I’ve already tested this using the reproduction test provided in the bug report by linking my local changes. And recently, I am facing an issue with the 'create-wdio' package |
Yes, let's do that. This will help prevent regressing on this side in the future.
We have already some
Mhm .. maybe try update your branch. We don't see these issues in |
|
@christian-bromann can you please provide me with access to the guinea-pig repo to raise a PR? |
The repo is public, you can raise a PR to it. |
@christian-bromann I tried but I am getting error. `git push --set-upstream origin bug-14514 Please make sure you have the correct access rights |
|
@vishnuv688 I've added the @webdriverio/browserstack team to the project, you should be able to push to the branch now |
@christian-bromann, I have merged the e2e test in guinea-pig. Please do review the changes. |
christian-bromann
left a comment
There was a problem hiding this comment.
One question, code overall looks good to me, great work!
|
Mind taking a look at the unit tests as well? |
@christian-bromann Yes, I've already added unit tests for both key scenarios:
I have already mentioned the reason for this change in the bug report. |
I understand, however the patch seems to cause other unit test to fail, mind taking a look at these? |
@christian-bromann May I know which test case is failing, as I could see all the test cases in switchFrame.test have passed. |
|
|
@christian-bromann Resolved the issue |
|
Hey, |
|
Yes, we will put out a release soon. |
Proposed changes
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
Reviewers: @webdriverio/project-committers