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
After upgrading to v4 the switchTo behavior seems incorrect or at least inconsistent when working with nested iframes. The switch to iframe located on the top level works correctly and the context seems to be set properly.
I can verify and interact with elements within the first iframe. switchTo(nestedIframe) step passes but after that it seems to get into a state where nothing is visible to the driver any more. The elements present in nested iframe are never detected, neither are those within the first frame or on top-level outside of any frames.
Tested with codeceptjs@4.1.0 and playwright-core@1.61.1. Reproduction script:
Scenario('iframe test',({ I })=>{I.amOnPage('https://www.dezlearn.com/nested-iframes-example/')I.waitForElement('#parent_iframe',10)I.switchTo('#parent_iframe')I.waitForElement('#u_5_5')I.waitForElement('#iframe1')I.switchTo('#iframe1')I.waitForElement('#u_5_6')// fails on v4// below 2 calls are expected to fail with expected switchTo behavior but are included just to show that context seems broken // I.waitForElement('#u_5_5') // located in parent iframe // I.waitForElement('#parent_iframe') // located on top level})
On the other hand doing the same thing using within seems to work but that has its own downsides so I'm not keen on relying solely on that.
Scenario('iframe test',({ I })=>{I.amOnPage('https://www.dezlearn.com/nested-iframes-example/')I.waitForElement('#parent_iframe',10)within({frame: ['#parent_iframe','#iframe1']},()=>{I.waitForElement('#u_5_6')})})
This seems to be regression as it works fine on 3.7.9
Reacted by Gasper Jeklin, DraganSpasovskiCeltra, makregar, Tamás Gombos, Jan Vodopivec, Liam Mislej, Žan Hočevar, Matic Brovc, Tamara Jevtić, zstebljaj and 1 more
Minimal repro to comfirm this is Playwright specific regression: a local static fixture with a 3-level nested iframe (top → #outer → #inner → target element), tested on codeceptjs@4.1.0.
Same result: switchTo('#outer') then switchTo('#inner') both report passed, but the following assertion on the target element times out — context silently ends up wrong.
Ran the identical scenario through the other helpers against the same fixture:
Helper
Result
Playwright
❌ fails
Puppeteer
✅ works
WebDriver
✅ works
So this looks Playwright specific, not a general switchTo() regression. Your within({ frame: [...] }) workaround also checks out on Playwright.
Activity
neskoncno commentedon Aug 18, 2026
Minimal repro to comfirm this is Playwright specific regression: a local static fixture with a 3-level nested iframe (top →
#outer→#inner→ target element), tested oncodeceptjs@4.1.0.Same result:
switchTo('#outer')thenswitchTo('#inner')both report passed, but the following assertion on the target element times out — context silently ends up wrong.Ran the identical scenario through the other helpers against the same fixture:
So this looks Playwright specific, not a general
switchTo()regression. Yourwithin({ frame: [...] })workaround also checks out on Playwright.Repro + configs for all three helpers: https://github.com/neskoncno/cjs4-iframe-playwright-bug
Source of introduced regression cb7efd6#diff-5dc6e0a9028f00d161e530bc3b734e92d0497c131429e67b07e87a9224e4ecda
fix(Playwright): switchTo resolves nested iframes relative to current…
fix(Playwright): switchTo resolves nested iframes relative to current…