📅 Day 6 - Collections, Inheritance, GitHub

"Organizing Data, Roles, and Teamwork in QA"

Duration: 1 Hour | Theme: QA Store Management

🕒 Session Flow

🎭 Intro Story (5 min)

🛍️ "Imagine we're managing an online QA store. We have a big shelf of products (Collections), different types of workers (Inheritance), and we need a shared logbook (GitHub) to track who tested what. Today, we'll learn how to organize our data, roles, and teamwork."

1. 📦 Collections in JS (25 min)

📌 Concept

Organizing multiple values (test data, roles, sessions).

a) Arrays – ordered list

let products = ["Laptop", "Phone", "Camera"]; console.log(products[1]); // Phone products.push("Tablet"); // add new product console.log(products); // ["Laptop", "Phone", "Camera", "Tablet"]

💡 QA Example: Store product names in an array and verify "Phone" is in the list

b) Set – unique values

let testIDs = new Set(["TC001", "TC002", "TC001"]); console.log(testIDs.size); // 2 (duplicate removed) testIDs.add("TC003"); console.log(testIDs.has("TC001")); // true

💡 QA Example: Ensure test case IDs are unique (no duplicate test execution)

c) Map – key-value store

let userRoles = new Map(); userRoles.set("Admin", ["Add Product", "Manage Orders"]); userRoles.set("Customer", ["Browse Products", "Add to Cart"]); console.log(userRoles.get("Admin")); // ["Add Product", "Manage Orders"] console.log(userRoles.has("Guest")); // false

💡 QA Example: Role → Actions mapping in OpenCart testing

d) Objects vs Map

// Object - fixed structure let user = { username: "demo", password: "demo" }; // Map - dynamic key-value pairs let userMap = new Map([["username", "demo"], ["password", "demo"]]); console.log(user.username); // demo console.log(userMap.get("username")); // demo

💡 QA Example: Objects for fixed test data, Map for dynamic role-based access

📊 Collection Comparison

Collection Type Use Case QA Example
Array Ordered list of items Product catalog, test steps
Set Unique values only Browser sessions, test IDs
Map Key-value pairs User roles, test data
Object Fixed structure data User profiles, test config

💡 Interactive Qs:

  1. If I want to ensure unique browsers opened in parallel testing → which collection? (👉 Set)
  2. If I want to store feature → test cases mapping → which collection? (👉 Map)

🎯 Mini Task: Collection Practice

  • Create an array of 5 test browsers
  • Convert to Set to remove duplicates
  • Create Map mapping browser → test count

2. 🧬 Inheritance Recap + Advanced Example (15 min)

📌 Concept

Reusing code between parent & child classes.

class BasePage { open(url) { console.log("Opening:", url); } waitForElement(selector) { console.log("Waiting for:", selector); } } class ProductPage extends BasePage { addToCart(product) { console.log(product, "added to cart"); } viewProduct(productId) { console.log("Viewing product:", productId); } } class CheckoutPage extends BasePage { checkout() { console.log("Proceeding to checkout"); } applyCoupon(code) { console.log("Applying coupon:", code); } } let cart = new ProductPage(); cart.open("https://demo.opencart.com"); cart.addToCart("Laptop");

💡 QA Example: Base actions (open, wait) in parent, page-specific actions in child classes

💡 Interactive Q:

👉 What error happens if you try calling checkout() from ProductPage?

Answer: TypeError: cart.checkout is not a function

🎯 Mini Task: Page Object Model

  • Create LoginPage extending BasePage
  • Add login(username, password) method
  • Test the inheritance chain

3. 📚 GitHub Basics (15 min)

📌 Why GitHub for QA?

  • Version control for test code
  • Collaboration with developers
  • History of changes

🔄 Git Workflow for QA

# 1. Clone a repo git clone https://github.com/username/qa-playwright-training.git # 2. Check status git status # 3. Stage & Commit git add . git commit -m "Added CartPage tests" # 4. Push to remote git push origin main # 5. Pull updates git pull origin main

💡 QA Example:

  • Store test cases in repo
  • Track who updated automation scripts
  • Rollback to older stable test suite

🎯 Mini Task: Git Simulation

Let's simulate a Git workflow for QA team collaboration:

💡 Interactive Activity:

  • Create a dummy repo qa-playwright-training
  • Each student adds a Day6_notes.txt file with "Hello from <Name>"
  • Commit & push
  • Everyone pulls and sees all notes

📋 Essential Git Commands for QA

Command Purpose QA Use Case
git clone Download repository Get test automation project
git status Check file changes See modified test files
git add Stage changes Prepare test updates
git commit Save changes Save test improvements
git push Upload to remote Share with team
git pull Download updates Get latest test changes

🎯 Day 6 Learning Outcomes