Playwright Python 10 | Data Driven Testing
In this session… How to parameterize tests How to get data from csv file How to get data from json file DEMO - How to do Data Driven Testing Step 1 - Create a simple test that uses some data Step 2 - Parameterize the test i.e. use variables in place of hard coded data values pass values to the variables using @pytest.mark. parameterize() fixture Using CSV File Step 3 - Now store the test data in a csv file Step 4 - In the test file create function to read and get data from csv file Using JSON File Step 5 - Create a json file and add the test data Step 6 - In the test file create function to read and get data from json file - Function to get data from csv file import csv def get_csv_data(): data = [] with open("data.csv", newline="") as csvfile: reader = csv.DictReader(csvfile) for row in reader: data.append((row["search_term"], row["expected_keyword"])) return data @pytest.mark.parametrize("username, password", get_csv_data()) def test_example(page: Page, username, password) -> None: JSON file [ { "username": "Admin", "password": "admin123" }, { "username": "Test1", "password": "admin345" }, { "username": "Test2", "password": "admin567" } ] Function to get data from json file import json def get_json_data(): with open("data.json") as f: raw = json.load(f) return [(item["search_term"], item["expected_keyword"]) for item in raw] @pytest.mark.parametrize("username, password", get_json_data()) def test_example(page: Page, username, password) -> None: GitHub Repo - https://github.com/Raghav-Pal/Playwri... ▬▬▬▬▬▬▬ 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/ QnA Friday - https://bit.ly/2NgwGpw Sunday Special - https://bit.ly/2wB23BO 🙌 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 —

Playwright Python 1 | Getting Started

Playwright Python 8 | 1st API Test

Data-Driven Testing in Playwright Framework

Playwright with Python & Pytest | Data Driven Testing using JSON, CSV & Excel Files (Session 15)

Playwright Python 6 | Page Object Model (POM)

Playwright with TypeScript | Parameterization | Data Driven Testing | JSON, CSV & Excel (Session 18)

Playwright Beginner Tutorial 5 | How To Record Tests

The Man Who Worked At Subway, Then Solved An "Impossible" Problem

Easiest Way to Read Excel Files in Playwright (Step-by-Step)

Playwright Fixtures Explained 🔥 | Step-by-Step Tutorial for Beginners

Playwright Beginner Tutorial 10 | Slow Motion and Video Recording

Blue gradient background - screensaver, mood lighting, ambiance, TV art, focus, study

Listen and Feel the Peace | Tibetan Healing Sounds for Deep Meditation, Inner Peace & Soul Healing

3 Reasons for Playwright Flaky Tests (and How To Fix It)

Playwright Fixtures: How They Actually Work (Simpy Explained)

Playwright Web Scraping + CAPTCHA Bypass Tutorial

Playwright Python 7 | How to use Trace Viewer

10 Images | Coastal Citrus Floral Summer Paintings Screensaver l Frame TV ART |

Playwright Tutorial #20 - How to Handle Dynamic Dropdown in Playwright

