0
0
Testing Fundamentalstesting~15 mins

Bug severity vs priority in Testing Fundamentals - Automation Approaches Compared

Choose your learning style9 modes available
Verify correct classification of bug severity and priority
Preconditions (2)
Step 1: Open the bug tracking system
Step 2: Select a bug with 'Critical' severity
Step 3: Verify that the bug's priority is set to 'High'
Step 4: Select a bug with 'Minor' severity
Step 5: Verify that the bug's priority is set to 'Low'
Step 6: Select a bug with 'Major' severity
Step 7: Verify that the bug's priority is set to 'Medium'
Step 8: Change the priority of a 'Critical' severity bug to 'Low'
Step 9: Verify that a warning message appears indicating mismatch between severity and priority
✅ Expected Result: Bugs with 'Critical' severity have 'High' priority, 'Major' severity have 'Medium' priority, 'Minor' severity have 'Low' priority. Changing priority to a level inconsistent with severity triggers a warning.
Automation Requirements - Selenium with Python
Assertions Needed:
Verify bug severity label text matches expected
Verify bug priority label text matches expected
Verify warning message appears when priority and severity mismatch
Best Practices:
Use explicit waits for elements to be visible
Use Page Object Model to separate page interactions
Use clear and descriptive assertion messages
Automated Solution
Testing Fundamentals
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import unittest

class BugPage:
    def __init__(self, driver):
        self.driver = driver

    def open_bug(self, bug_id):
        self.driver.get(f"https://bugtracker.example.com/bugs/{bug_id}")

    def get_severity(self):
        return WebDriverWait(self.driver, 10).until(
            EC.visibility_of_element_located((By.ID, "bug-severity"))
        ).text

    def get_priority(self):
        return WebDriverWait(self.driver, 10).until(
            EC.visibility_of_element_located((By.ID, "bug-priority"))
        ).text

    def set_priority(self, priority):
        priority_dropdown = WebDriverWait(self.driver, 10).until(
            EC.element_to_be_clickable((By.ID, "priority-dropdown"))
        )
        priority_dropdown.click()
        option = WebDriverWait(self.driver, 10).until(
            EC.element_to_be_clickable((By.XPATH, f"//option[text()='{priority}']"))
        )
        option.click()

    def get_warning_message(self):
        return WebDriverWait(self.driver, 5).until(
            EC.visibility_of_element_located((By.ID, "priority-warning"))
        ).text

class TestBugSeverityPriority(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.bug_page = BugPage(self.driver)

    def tearDown(self):
        self.driver.quit()

    def test_bug_severity_priority_mapping(self):
        # Test Critical severity bug
        self.bug_page.open_bug("CRIT-001")
        severity = self.bug_page.get_severity()
        priority = self.bug_page.get_priority()
        self.assertEqual(severity, "Critical", "Severity should be Critical")
        self.assertEqual(priority, "High", "Priority should be High for Critical severity")

        # Test Minor severity bug
        self.bug_page.open_bug("MIN-002")
        severity = self.bug_page.get_severity()
        priority = self.bug_page.get_priority()
        self.assertEqual(severity, "Minor", "Severity should be Minor")
        self.assertEqual(priority, "Low", "Priority should be Low for Minor severity")

        # Test Major severity bug
        self.bug_page.open_bug("MAJ-003")
        severity = self.bug_page.get_severity()
        priority = self.bug_page.get_priority()
        self.assertEqual(severity, "Major", "Severity should be Major")
        self.assertEqual(priority, "Medium", "Priority should be Medium for Major severity")

    def test_priority_change_warning(self):
        self.bug_page.open_bug("CRIT-001")
        self.bug_page.set_priority("Low")
        warning = self.bug_page.get_warning_message()
        self.assertIn("mismatch", warning.lower(), "Warning should appear for priority and severity mismatch")

if __name__ == "__main__":
    unittest.main()

The code uses Selenium with Python and unittest framework.

The BugPage class follows the Page Object Model to keep page actions organized.

Explicit waits ensure elements are ready before interacting.

Test methods check that bugs with different severities have correct priorities.

Another test changes priority to an inconsistent value and verifies a warning message appears.

Assertions have clear messages to help understand failures.

Common Mistakes - 3 Pitfalls
Using hardcoded sleep instead of explicit waits
Mixing locators styles inconsistently
Not verifying warning message after priority change
Bonus Challenge

Now add data-driven testing with 3 different bugs having various severity and priority combinations

Show Hint