0
0
Testing Fundamentalstesting~15 mins

Quality assurance vs quality control in Testing Fundamentals - Automation Approaches Compared

Choose your learning style9 modes available
Verify Quality Assurance and Quality Control definitions on About page
Preconditions (1)
Step 1: Locate the section titled 'Quality Assurance'
Step 2: Verify the text under 'Quality Assurance' matches 'Quality assurance (QA) is the process of ensuring that the product meets the required standards through planned and systematic activities.'
Step 3: Locate the section titled 'Quality Control'
Step 4: Verify the text under 'Quality Control' matches 'Quality control (QC) is the process of identifying defects in the actual products produced.'
✅ Expected Result: The About page correctly displays the definitions for Quality Assurance and Quality Control as specified.
Automation Requirements - Selenium with Python
Assertions Needed:
Assert the QA section text matches the expected definition
Assert the QC section text matches the expected definition
Best Practices:
Use explicit waits to ensure elements are loaded before accessing
Use clear and maintainable locators (e.g., By.ID or By.CSS_SELECTOR)
Separate test logic and assertions clearly
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 TestQualityDefinitions(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://example.com/about')
        self.wait = WebDriverWait(self.driver, 10)

    def test_quality_definitions(self):
        driver = self.driver
        wait = self.wait

        # Wait for QA section and verify text
        qa_section = wait.until(EC.visibility_of_element_located((By.ID, 'quality-assurance')))
        expected_qa_text = 'Quality assurance (QA) is the process of ensuring that the product meets the required standards through planned and systematic activities.'
        actual_qa_text = qa_section.text.strip()
        self.assertEqual(actual_qa_text, expected_qa_text, 'QA definition text does not match')

        # Wait for QC section and verify text
        qc_section = wait.until(EC.visibility_of_element_located((By.ID, 'quality-control')))
        expected_qc_text = 'Quality control (QC) is the process of identifying defects in the actual products produced.'
        actual_qc_text = qc_section.text.strip()
        self.assertEqual(actual_qc_text, expected_qc_text, 'QC definition text does not match')

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

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

This test script uses Selenium with Python's unittest framework to automate verification of the Quality Assurance and Quality Control definitions on the About page.

In setUp, the browser opens the About page URL. We use WebDriverWait with explicit waits to ensure the sections are visible before accessing their text.

We locate the QA and QC sections by their id attributes, which is a best practice for stable and clear locators.

Assertions compare the actual text on the page with the expected definitions exactly, ensuring correctness.

Finally, tearDown closes the browser after the test.

Common Mistakes - 3 Pitfalls
Using time.sleep() instead of explicit waits
Using brittle XPath locators that depend on page layout
Not verifying the exact text content
Bonus Challenge

Now add data-driven testing with 3 different pages that have QA and QC definitions

Show Hint