Playwright Python 1 | Getting Started
Автор: Automation Step by Step
Загружено: 2025-06-05
Просмотров: 38950
Описание:
In this session…
Getting Started
Install Python
Install Playwright
1st Playwright Test
(Open a webpage)
After watching take this QUIZ and let me know your score in comments
https://forms.gle/W3GUVGskMDFA3G29A
GitHub Repo - https://github.com/Raghav-Pal/Playwri...
--
What is Playwright
It’s a tool to test websites from start to end (like how a user uses it)
--
What browsers does it work with?
Works with all big browsers:
Chromium (like Chrome, Edge)
WebKit (like Safari)
Firefox
--
What OS does it work with?
Windows
Linux
Mac
Can run tests in CI/CD ( Jenkins etc.)
headless (no browser window) OR headed (you see browser open)
can also pretend to be a mobile phone (mobile emulation)
--
Before we begin… Let’s check our system is ready
At least 4 GB RAM (8 GB better)
Disk space: around 1.5 GB
Stable internet
https://playwright.dev/python/docs/in...
-
Install Python
Step 1 - Check if python is already installed python --version or py --version
Step 2 - Download Python installer from https://www.python.org/
Step 3 - Create a folder for python
Step 4 - Run python installer and use the folder destination
Step 4 - Also check if PATH env variables has python and python/scripts folders added
Step 5 - Check if python is installed python --version or py --version
Step 6 - Also check pip pip --version
-
Install Playwright
Step 1 - Create a new folder for playwright project
mkdir playwright_demo
cd playwright_demo
Step 2 - Create a python virtual env for this project
python -m venv venv
source venv/bin/activate # Mac/Linux
venv\Scripts\activate # Windows
Step 3 - Install playwright pip install playwright playwright --version
Can also install with pytest pip install pytest-playwright
Step 4 - Install browser binaries
playwright install
This downloads Chromium, Firefox, WebKit for testing
Step 5 - Verify installation
python -m playwright --version
We’re ready. Let’s write our first script
-
1st Playwright Test (Open a webpage)
Step 1 - Create a new python file touch first_test.py # Mac/Linux
type nul > first_test.py # Windows
Step 2 - Write this script in first_test.py
Can also use some editor or IDE like VS Code
Can download zip file of vscode and extract in a separate new folder
Can also install python extensions. Will find python option in the button status bar
Step 3 - Run the test python first_test.py
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch(headless=False)
page = browser.new_page()
page.goto('https://google.com')
print(page.title())
browser.close()
-
#Playwright #PythonAutomation #QATutorial
▬▬▬▬▬▬▬
Share with all who may need this
If my work has helped you, consider helping any animal near you, in any way you can
Never Stop Learning
Raghav Pal
▬▬▬▬ USEFUL LINKS ▬▬▬▬
✅ ALL TUTORIALS - https://AutomationStepByStep.com/
🙌 Connect with Raghav:
Ask Raghav: https://bit.ly/2CoJGWf
GitHub: https://github.com/Raghav-Pal
Udemy: https://www.udemy.com/user/raghav-pal-3/
Shorts Eng - https://bit.ly/3H9bifV
Shorts Hindi - https://bit.ly/3XY7XqN
➡️ Subscribe for more videos: / @raghavpal
—
Повторяем попытку...
Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: