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
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
The starter repository for submissions to the GeneDisco challenge for optimized experimental design in genetic perturbation experiments

GeneDisco ICLR-22 Challenge Starter Repository The starter repository for submissions to the GeneDisco challenge for optimized experimental design in

22 Dec 06, 2022
Basic Docker Compose template application with Flask, Celery, Redis, MySQL, SocketIO, Nginx and Gunicorn.

Nginx / Gunicorn / Flask 🐍 / Celery / SocketIO / MySQL / Redis / Docker 🐳 sample application Basic Docker Compose template application for orchestat

Alex Oarga 8 Aug 06, 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
Generic template for python service

Cookie cutter template example Technology stack Flask Gevent UWSGI Poetry Docker Docker-compose Installation pip install cookiecutter cookiecutter git

Churkin Oleg 11 Oct 22, 2022
Setup a flask project using a single command, right from creating virtual environment to creating Procfile for deployment.

AutoFlask-Setup About AutoFlask-Setup can help you set up a new Flask Project, right from creating virtual environment to creating Procfile for deploy

Ashutosh Krishna 1 Oct 21, 2021
King is a simple boilerplate from a bigger Discord Bot project created for my Discord Server.

King A simple Discord bot boilerplate. King is a simple boilerplate from a bigger Discord Bot project created for my Discord Server. I intend to showc

Xminent 0 Aug 21, 2021
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

18.7k Jan 08, 2023
Backend Boilerplate using Django,celery,Redis

Backend Boilerplate using Django,celery,Redis

Daniel Mawioo 2 Sep 14, 2022
Template for creating PyPI project

template-for-creating-pypi-project Template for creating PyPI project Hello there! This is a template for creating a PyPI project. Fork or clone this

4 Apr 25, 2022
A project to get you started with Docker and Django.

Docker Django tl;dr $ git clone [email protected]:erroneousboat/docker-django.git $ d

JP Bruins Slot 176 Dec 29, 2022
Template repository to build PyTorch projects from source on any version of PyTorch/CUDA/cuDNN.

Template repository to build PyTorch projects from source on any version of PyTorch/CUDA/cuDNN.

Joonhyung Lee/이준형 651 Dec 12, 2022
Combine the power of FastAPI and Django to build a production-ready application capable of utilizing all of the best features of both worlds.

FastAPI and Django Combo This projects aims to combine FastAPI and Django to build a Production ready application capable of utilizing all of the feat

Nsikak Imoh 33 Dec 27, 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
PyPC is a very simple tool that creates Python projects from templates.

PyPC (Python Project Creator) PyPC is a very simple tool that creates Python projects from templates. In 0.1v#alpha, custom template creation will be

art3m1s 1 Nov 26, 2021
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
Code Kata Python Template

Code Kata Python Template This is the code kata template for python created by Aula de Software Libre de la Universidad de Córdoba Step 1. Use this re

Sergio Gómez 2 Nov 30, 2021
Boilerplate for starting a python project

Python Project Boilerplate Simple boilerplate for starting a python proect. Using the repo Follow following steps to install client on server Create a

Prajwal Dahal 1 Nov 19, 2021
NHS Theme for Streamlit applications

NHS Streamlit App Template Deployment (local) The tool has been built using Stre

nhs.pycom 3 Nov 07, 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