0
0
Selenium Pythontesting~3 mins

Why Markers for categorization in Selenium Python? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if you could run only the tests you need with a simple label?

The Scenario

Imagine you have a big set of tests for a website. You want to run only the tests about login today, but you have to open each test file and find those tests manually.

The Problem

Doing this by hand is slow and easy to mess up. You might forget some tests or run the wrong ones. It feels like searching for a needle in a haystack every time.

The Solution

Markers let you tag tests with labels like 'login' or 'slow'. Then you can tell your test tool to run only tests with a certain tag. This saves time and avoids mistakes.

Before vs After
Before
def test_login():
    # no marker, must find manually
    pass

def test_logout():
    pass
After
@pytest.mark.login
def test_login():
    pass

@pytest.mark.logout
def test_logout():
    pass
What It Enables

You can quickly run just the tests you want, making testing faster and more organized.

Real Life Example

A team working on a shopping site runs only 'payment' tests before a release to be sure checkout works, without waiting for all tests.

Key Takeaways

Manual test selection is slow and error-prone.

Markers tag tests for easy grouping and running.

Markers help run focused tests quickly and reliably.