Wait before taking screenshot with Python and Playwright
Install Playwright and Playwright client for Python
pip install pytest-playwright
playwright install
Take a screenshot and save to file
Wait for the specified number of milliseconds before taking the screenshot.
import asyncio
from playwright.async_api import async_playwright
async def main():
async with async_playwright() as p:
browser = await p.chromium.launch()
page = await browser.new_page()
await page.goto('https://www.bbc.co.uk/news/business-63709754')
await page.wait_for_timeout(3000);
await page.screenshot(path='wait.png')
await browser.close()
asyncio.run(main())
Find out how to take a full-page screenshot with Python and Playwright.
We created Urlbox to make converting HTML to images easy
Learn more about our website screenshot API.