# class: Frame At every point of time, page exposes its current frame tree via the [`method: Page.mainFrame`] and [`method: Frame.childFrames`] methods. [Frame] object's lifecycle is controlled by three events, dispatched on the page object: * [`event: Page.frameattached`] - fired when the frame gets attached to the page. A Frame can be attached to the page only once. * [`event: Page.framenavigated`] - fired when the frame commits navigation to a different URL. * [`event: Page.framedetached`] - fired when the frame gets detached from the page. A Frame can be detached from the page only once. An example of dumping frame tree: ```js const { firefox } = require('playwright'); // Or 'chromium' or 'webkit'. (async () => { const browser = await firefox.launch(); const page = await browser.newPage(); await page.goto('https://www.google.com/chrome/browser/canary.html'); dumpFrameTree(page.mainFrame(), ''); await browser.close(); function dumpFrameTree(frame, indent) { console.log(indent + frame.url()); for (const child of frame.childFrames()) { dumpFrameTree(child, indent + ' '); } } })(); ``` ```python async import asyncio from playwright.async_api import async_playwright async def run(playwright): firefox = playwright.firefox browser = await firefox.launch() page = await browser.new_page() await page.goto("https://www.theverge.com") dump_frame_tree(page.main_frame, "") await browser.close() def dump_frame_tree(frame, indent): print(indent + frame.name + '@' + frame.url) for child in frame.child_frames: dump_frame_tree(child, indent + " ") async def main(): async with async_playwright() as playwright: await run(playwright) asyncio.run(main()) ``` ```python sync from playwright.sync_api import sync_playwright def run(playwright): firefox = playwright.firefox browser = firefox.launch() page = browser.new_page() page.goto("https://www.theverge.com") dump_frame_tree(page.main_frame, "") browser.close() def dump_frame_tree(frame, indent): print(indent + frame.name + '@' + frame.url) for child in frame.child_frames: dump_frame_tree(child, indent + " ") with sync_playwright() as playwright: run(playwright) ``` ## async method: Frame.addScriptTag - returns: <[ElementHandle]> Returns the added tag when the script's onload fires or when the script content was injected into frame. Adds a `