elements / iframes

Single UI element

Iframes

A same-origin iframe containing its own small form, for practicing frame-switching, nested element locator lookups, and context resetting.

Embedded frame

#practice-iframe
id
practice-iframe
expected
Contains its own internal DOM. You must switch execution context into the frame to interact with inner controls, then switch back to the parent document.
Code snippets
Python (Selenium)
# Switch into iframe
frame = driver.find_element(By.ID, "practice-iframe")
driver.switch_to.frame(frame)

# Interact inside iframe
inp = driver.find_element(By.ID, "frame-input")
inp.send_keys("Test text inside frame")
driver.find_element(By.ID, "frame-submit").click()
out = driver.find_element(By.ID, "frame-out")
assert "Received" in out.text

# Return to default document
driver.switch_to.default_content()
TypeScript (Playwright)
const frame = page.frameLocator('#practice-iframe');
await frame.locator('#frame-input').fill('Test text inside frame');
await frame.locator('#frame-submit').click();
expect(await frame.locator('#frame-out').textContent()).toContain('Received');