Skip to content
CodeKruPro

Content Between Frame and Main Page

49/70

Content Between Frame and Main Page

Unlike Selenium, you never "switch" context in Playwright. You can access both the main page and frame elements in the same flow without any switching.

Task:

  1. Navigate to https://testkru.com/Interactions/Frames
  2. Get the main page heading (h2 on the main page)
  3. Get the frame1 heading (h1 inside the first #frame1; the page has two frames with that id, so use '#frame1 >> nth=0')
  4. Get the main page heading again (no switch back needed!)

Expected output:

Main page: Frames
Frame content: CodeKru
Back to main: Frames