Template to quickly start your playwright-python project

Overview

Playwright-python template 🍪

Template to quickly start your playwright-python project

Getting startedDemoConfiguration

Getting started

  1. Clone the repository:
git clone https://github.com/constantbratu/playwright-python-template.git
cd playright-python-template
  1. Set up the virtual environment:
python -m venv venv
venv\Scripts\activate
pip install playwright pyinstaller pyyaml
  1. Set up the environment variable and install chromium:
SET PLAYWRIGHT_BROWSERS_PATH=0
playwright install chromium
  1. Configure the project using the provided config.yaml file

  2. Start recording the session using:

playwright codegen 
   

   
  1. Copy the generated async code into main.py:
GENERATED CODE GOES HERE <--- await context.close() await browser.close() ">
async def run(playwright: Playwright) -> None:
    browser = await playwright.chromium.launch(
        headless=CONFIG["headless"],
        executable_path=get_executable_path(),
        args=CONFIG["chromium_args"],
    )
    context = await browser.new_context(viewport=None)

    global page
    page = await context.new_page()
    page.set_default_timeout(CONFIG["default_timeout"])

    await page.goto(CONFIG["start_page"])
    
    # ---> GENERATED CODE GOES HERE <---

    await context.close()
    await browser.close()
  1. Compile the project and bundle the chromium binary via pyinstaller using the provided spec file:
pyinstaller --noconfirm build.spec

To save time, 3 scripts have been added to the repository:

  • init_venv.bat to set up the environment and download all the required files
  • codegen.bat to start the recording session
  • build.bat to compile the project

Demo

...

Configuration

Edit config.yml to change the project settings:

start_page: https://www.google.com/  # 
   
     sets the initial page; changing this key will also affect `codegen.bat`
   

headless: false  # 
   
     if the browser should run in headless mode
   
default_timeout: 5000  # 
   
     maximum time to wait for the page to load (in milliseconds)
   
chromium_args:  # 
   
     list of chromium command line switches
   
    - --window-size=800,600
    - --user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36

A list of chromium command line switches can be found here.

Note that more options will also be added in the future.

Owner
Constantin
Constantin
Forkable, Minimal Template for Starknet Projects.

Forkable, Minimal Template for Starknet Projects.

velleity.eth 44 Oct 09, 2022
Python example making use of best practice file structure and multithreading.

Python example making use of best practice file structure and multithreading.

Bob 1 Oct 13, 2021
Cookiecutter Flask OpenAPI is a template for jumpstarting production-ready Flask projects quickly.

Cookiecutter Flask OpenAPI is a template for jumpstarting production-ready Flask projects quickly. It has a well organized and scalable structure. It uses API design first

Roger Camargo 3 Nov 17, 2022
A template repository implementing HTML5 Boilerplate 8.0 in Sanic using the Domonic framework.

sanic-domonic-h5bp A template repository implementing HTML5 Boilerplate 8.0 in Sanic using the Domonic framework. If you need frontend interactivity,

PyXY 3 Dec 12, 2022
Um template para quem quiser usar o Docker + PGSQL + Django.

Um template para quem quiser usar o Docker + PGSQL + Django.

Drack 2 Mar 11, 2022
Starter project for python based lambda project.

Serverless Python Starter Starter project for python based lambda project. Features FastAPI - Frontend dev with Hot Reload API Gateway Integration (+r

4 Feb 22, 2022
A framework for launching new Django Rest Framework projects quickly.

DRFx A framework for launching new Django Rest Framework projects quickly. Comes with a custom user model, login/logout/signup, social authentication

William Vincent 400 Dec 29, 2022
Template to quickly start your playwright-python project

Playwright-python template 🍪 Template to quickly start your playwright-python project Getting started • Demo • Configuration Getting started Clone th

Constantin 1 Dec 13, 2021
This is the starter for the Flask React project.

Flask React Project This is the starter for the Flask React project. Getting started Clone this repository (only this branch) git clone https://github

Jami Travers 5 May 25, 2022
Backend Boilerplate using Django,celery,Redis

Backend Boilerplate using Django,celery,Redis

Daniel Mawioo 2 Sep 14, 2022
Vue + Django with no compromises. Django Templates and Vue SFCs in harmony without sacrificing the full power of either.

Cookiecutter Vue Django Vue + Django with no compromise. Cookiecutter Vue Django is a framework for jumpstarting production-ready Django + Vue project

Mike Hoolehan 122 Dec 22, 2022
Template for creating ds simple projects

ds-project-template Template for creating ds simple projects Requirements pyenv python==3.9.4 Setup For this purpose you use following commands: pytho

1 Dec 17, 2021
Flask Boilerplate - Material Kit Design | AppSeed

Flask Boilerplate - Material Kit Design | AppSeed

App Generator 45 Nov 18, 2022
Django Boilerplate - Material Kit Design | AppSeed

Django Boilerplate - Material Kit Design | AppSeed

App Generator 45 Dec 23, 2022
A Django starter template with a sound foundation.

SOS Django Template SOS Django Tempalate is a Django starter template that has opinionated and good solutions while starting your new Django project.

Eray Erdin 19 Oct 30, 2022
Launchr is an open source SaaS starter kit, based on Django.

Launchr Launchr is an open source SaaS starter kit. About Launchr is a fully-equipped starter template, ready to start a SaaS web app. It implements t

Jannis Gebauer 183 Jan 06, 2023
Django starter project with 🔋

A batteries-included Django starter project. For a production-ready version see the book Django for Professionals. 🚀 Features Django 3.1 & Python 3.8

William Vincent 1.5k Jan 08, 2023
Bleeding edge django template focused on code quality and security.

wemake-django-template Bleeding edge django2.2 template focused on code quality and security. Purpose This project is used to scaffold a django projec

wemake.services 1.6k Jan 08, 2023
Cookiecutter-allpurpose-minimal-python - A simple cookiecutter template for general-purpose python projects.

cookiecutter-allpurpose-minimal-python A simple cookiecutter template for general-purpose python projects. To use, run pip install cookiecutter cookie

E. Tolga Ayan 2 Jan 24, 2022
A platform for developers 👩‍💻 who wants to share their programs and projects.

Hacktoberfest-2021 A platform for developers 👩‍💻 who wants to share their projects and programs. Hacktoberfest has updated their rules and now this

Mayank Choudhary 40 Nov 07, 2022