Bird
Raised Fist0
Testing Fundamentalstesting~15 mins

Pair testing in Testing Fundamentals - Build an Automation Script

Choose your learning style10 modes available
Pair Testing on Login Functionality
Preconditions (3)
Step 1: Tester A enters 'user@example.com' in the email field
Step 2: Tester A enters 'Password123' in the password field
Step 3: Tester A clicks the Login button
Step 4: Tester B observes the behavior and notes any issues
Step 5: Both testers discuss and verify if the login was successful
Step 6: Repeat the above steps for invalid email format 'userexample.com' and verify error message
Step 7: Repeat the above steps for empty password field and verify error message
Step 8: Repeat the above steps for correct email and wrong password and verify error message
✅ Expected Result: Login succeeds only with valid credentials; appropriate error messages appear for invalid inputs; both testers agree on the test outcomes
Automation Requirements - Selenium with Python
Assertions Needed:
Verify URL changes to dashboard after successful login
Verify error message is displayed for invalid email format
Verify error message is displayed for empty password
Verify error message is displayed for wrong password
Best Practices:
Use explicit waits to handle page loading
Use clear and maintainable locators (By.ID, By.NAME)
Separate test data from test logic
Use assertions to validate expected outcomes
Write clean and readable code with comments
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 TestLogin(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://example.com/login')
        self.wait = WebDriverWait(self.driver, 10)

    def login(self, email, password):
        email_field = self.wait.until(EC.presence_of_element_located((By.ID, 'email')))
        password_field = self.driver.find_element(By.ID, 'password')
        login_button = self.driver.find_element(By.ID, 'loginBtn')

        email_field.clear()
        email_field.send_keys(email)
        password_field.clear()
        password_field.send_keys(password)
        login_button.click()

    def test_valid_login(self):
        self.login('user@example.com', 'Password123')
        self.wait.until(EC.url_contains('/dashboard'))
        self.assertIn('/dashboard', self.driver.current_url)

    def test_invalid_email_format(self):
        self.login('userexample.com', 'Password123')
        error = self.wait.until(EC.visibility_of_element_located((By.ID, 'emailError')))
        self.assertEqual(error.text, 'Please enter a valid email address.')

    def test_empty_password(self):
        self.login('user@example.com', '')
        error = self.wait.until(EC.visibility_of_element_located((By.ID, 'passwordError')))
        self.assertEqual(error.text, 'Password cannot be empty.')

    def test_wrong_password(self):
        self.login('user@example.com', 'WrongPass')
        error = self.wait.until(EC.visibility_of_element_located((By.ID, 'loginError')))
        self.assertEqual(error.text, 'Incorrect email or password.')

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

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

This test script uses Selenium with Python's unittest framework to automate the login tests.

setUp: Opens the browser and navigates to the login page before each test.

login method: Enters email and password, then clicks login.

test_valid_login: Checks that after valid login, URL contains '/dashboard'.

test_invalid_email_format: Checks error message for invalid email format.

test_empty_password: Checks error message when password is empty.

test_wrong_password: Checks error message for wrong password.

tearDown: Closes the browser after each test.

Explicit waits ensure elements are ready before interaction. Assertions verify expected results. Locators use IDs for clarity and maintainability.

Common Mistakes - 4 Pitfalls
Using time.sleep() instead of explicit waits
Hardcoding test data inside test methods
Using brittle locators like absolute XPath
Not closing the browser after tests
Bonus Challenge

Now add data-driven testing with 3 different sets of login credentials (valid, invalid email, wrong password).

Show Hint

Practice

(1/5)
1. What is the main idea behind pair testing in software testing?
easy
A. Testers work in pairs but test different features independently.
B. Two testers work separately on different devices to compare results.
C. Two testers work together on one device to find bugs faster.
D. One tester writes tests while the other writes code.

Solution

  1. Step 1: Understand the definition of pair testing and compare options

    Pair testing means two testers work together on one device to collaborate closely. "Two testers work together on one device to find bugs faster." correctly describes this.
  2. Final Answer:

    Two testers work together on one device to find bugs faster. -> Option C
  3. Quick Check:

    Pair testing = Two testers, one device [OK]
Hint: Pair testing means two testers share one device [OK]
Common Mistakes:
  • Thinking testers work separately in pair testing
  • Confusing pair testing with pair programming
  • Assuming testers test different features independently
2. Which of the following is the correct way to describe the roles in pair testing?
easy
A. Testers switch roles often to keep both active and engaged.
B. One tester tests while the other watches silently without switching roles.
C. Testers work independently and combine results at the end.
D. One tester writes bugs, the other fixes them immediately.

Solution

  1. Step 1: Recall role behavior in pair testing and match options

    In pair testing, testers switch roles often to stay active and share knowledge. "Testers switch roles often to keep both active and engaged." correctly states this.
  2. Final Answer:

    Testers switch roles often to keep both active and engaged. -> Option A
  3. Quick Check:

    Role switching = Active testers [OK]
Hint: Roles switch often in pair testing to stay engaged [OK]
Common Mistakes:
  • Assuming one tester is passive
  • Thinking testers work independently
  • Confusing pair testing with bug fixing roles
3. Consider this scenario: Two testers are pair testing a login feature. Tester A types inputs while Tester B observes and suggests test cases. What is the main benefit of this approach?
medium
A. It allows testers to work on different features simultaneously.
B. It reduces the total number of test cases needed.
C. It ensures only one tester is responsible for bugs.
D. It helps find bugs faster and shares knowledge between testers.

Solution

  1. Step 1: Analyze the pair testing scenario and identify the benefit

    Tester A inputs data, Tester B observes and suggests test cases, showing collaboration. This helps find bugs faster and shares knowledge between testers.
  2. Final Answer:

    It helps find bugs faster and shares knowledge between testers. -> Option D
  3. Quick Check:

    Pair testing benefit = Faster bugs + knowledge sharing [OK]
Hint: Pair testing speeds bug finding and knowledge sharing [OK]
Common Mistakes:
  • Thinking it reduces test cases
  • Believing only one tester is responsible
  • Assuming testers work on different features
4. During pair testing, a team notices that one tester is always controlling the device and the other rarely participates. What is the main problem here?
medium
A. The testers are not switching roles often, reducing engagement.
B. The device is faulty and causing delays.
C. Testers should work independently to be efficient.
D. One tester should write code while the other tests.

Solution

  1. Step 1: Identify the issue in pair testing and its impact

    One tester always controls the device, meaning roles are not switching often. This reduces engagement and knowledge sharing.
  2. Final Answer:

    The testers are not switching roles often, reducing engagement. -> Option A
  3. Quick Check:

    No role switching = Low engagement [OK]
Hint: Lack of role switching reduces tester engagement [OK]
Common Mistakes:
  • Blaming the device instead of process
  • Suggesting independent work in pair testing
  • Confusing testing roles with coding roles
5. You are asked to improve the efficiency of pair testing for a complex feature. Which approach best applies pair testing principles to maximize bug detection and knowledge sharing?
hard
A. Have two testers test separately and merge their bug reports at the end of the day.
B. Assign two testers to work together on one device, switching roles every 15 minutes, discussing findings continuously.
C. One tester tests while the other documents test cases without switching roles.
D. Testers take turns testing different features independently to cover more ground.

Solution

  1. Step 1: Identify key pair testing principles and evaluate options

    Pair testing: two testers on one device, switch roles often, share knowledge. "Assign two testers to work together on one device, switching roles every 15 minutes, discussing findings continuously." matches all.
  2. Final Answer:

    Assign two testers to work together on one device, switching roles every 15 minutes, discussing findings continuously. -> Option B
  3. Quick Check:

    Pair testing best practice = Together + switch roles + discuss [OK]
Hint: Switch roles often and discuss to maximize pair testing [OK]
Common Mistakes:
  • Testing separately instead of together
  • Not switching roles during testing
  • Ignoring communication between testers
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard