Playwright Python 3 | How to create First Pytest

preview_player
Показать описание
In this session…
- What is a test in Pytest
- Run and verify
- Write a Pytest function line by line

--
After learning take this QUIZ and let me know your score in comments

What is a test in Pytest
A test is just a function whose name starts with test_
Pytest automatically finds and runs these functions

--

Write a pytest function line by line
Step 1 - In your project create a folder named: tests
Step 3 - Start writing a simple test line by line

Step 4 - Add import statements

import re

Step 5 - Write the test function

def test_google_search(page):

Step 6 - Navigate to Google (and skip the "Before you proceed" screen)

Step 7 - Handle the “Accept All” popup (optional)

try:
except:
print("No popup")

Step 8 - Type in the Search Box

Step 9 - Press Enter to search

Step 10 - Verify the page title contains the word "Playwright"

Select browser
--browser=chromium (includes Chrome/Edge)
--browser=firefox
--browser=webkit (Safari engine)

Headed or Headless Mode
--headed
--headless

Capture Screenshots
--screenshot=on off (default)
on
only-on-failure

Record Video
--video=on off (default)
Retain-on-failure
On-first-retry

pip install pytest-html

Check all options pytest --help

--
▬▬▬▬▬▬▬

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 ▬▬▬▬

🙌 Connect with Raghav:


Рекомендации по теме
Комментарии
Автор

24:10 'I'm not a robot' Google Captacha appeared but test succesffully passed. How could it happen? Your test doesn't have code which bypass captcha.

olegmikulskiy
welcome to shbcf.ru