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.