0
0
Selenium Pythontesting~10 mins

Markers for categorization in Selenium Python - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test uses markers to categorize tests in Selenium with Python. It runs a simple test that opens a webpage and checks the page title. The marker helps group this test for easy selection later.

Test Code - pytest
Selenium Python
import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By

@pytest.mark.smoke
def test_open_google():
    driver = webdriver.Chrome()
    driver.get('https://www.google.com')
    assert 'Google' in driver.title
    driver.quit()
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test starts with pytest runner recognizing the @pytest.mark.smoke markerTest framework is ready to run tests marked as 'smoke'-PASS
2Selenium WebDriver Chrome instance is createdBrowser window opens, ready to navigate-PASS
3Browser navigates to 'https://www.google.com'Google homepage is loaded in the browser-PASS
4Test checks if 'Google' is in the page titlePage title contains 'Google'assert 'Google' in driver.titlePASS
5Browser is closed with driver.quit()Browser window is closed-PASS
Failure Scenario
Failing Condition: Page title does not contain 'Google' or browser fails to open
Execution Trace Quiz - 3 Questions
Test your understanding
What is the purpose of the @pytest.mark.smoke marker in this test?
ATo skip the test during execution
BTo categorize the test as a smoke test for easy selection
CTo run the test multiple times
DTo change the browser used in the test
Key Result
Using markers like @pytest.mark.smoke helps organize tests into groups. This makes it easy to run only specific categories of tests, improving test management and efficiency.