Acceptance criteria verification in Testing Fundamentals - Build an Automation Script
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 class LoginPage: def __init__(self, driver): self.driver = driver self.email_input = (By.ID, 'email') self.password_input = (By.ID, 'password') self.login_button = (By.ID, 'login-btn') def enter_email(self, email): WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(self.email_input)).send_keys(email) def enter_password(self, password): WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(self.password_input)).send_keys(password) def click_login(self): WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable(self.login_button)).click() class DashboardPage: def __init__(self, driver): self.driver = driver self.welcome_message = (By.ID, 'welcome-msg') def get_welcome_text(self): return WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(self.welcome_message)).text def test_user_login(): driver = webdriver.Chrome() driver.get('https://example.com/login') login_page = LoginPage(driver) login_page.enter_email('user@example.com') login_page.enter_password('Password123') login_page.click_login() WebDriverWait(driver, 10).until(EC.url_contains('/dashboard')) assert '/dashboard' in driver.current_url, 'URL does not contain /dashboard' dashboard_page = DashboardPage(driver) welcome_text = dashboard_page.get_welcome_text() assert welcome_text == 'Welcome, user!', f'Unexpected welcome message: {welcome_text}' driver.quit()
This test script uses Selenium with Python to automate the acceptance criteria verification for the login functionality.
We define two page classes: LoginPage and DashboardPage to organize locators and actions, following the Page Object Model pattern for maintainability.
Explicit waits ensure the script waits for elements to be visible or clickable before interacting, avoiding flaky tests.
The test navigates to the login page, enters the provided email and password, clicks login, then waits for the URL to contain '/dashboard'. It asserts the URL and the welcome message text to verify acceptance criteria.
Finally, the browser is closed with driver.quit() to clean up.
Now add data-driven testing with 3 different sets of valid user credentials
Practice
Solution
Step 1: Understand acceptance criteria role
Acceptance criteria specify the conditions that must be met for a feature to be considered complete.Step 2: Differentiate from other tasks
Writing code, designing UI, and creating automation are separate activities, not the main purpose of acceptance criteria.Final Answer:
To define what 'done' means for a feature -> Option BQuick Check:
Acceptance criteria = Definition of done [OK]
- Confusing acceptance criteria with coding tasks
- Thinking acceptance criteria are test scripts
- Mixing acceptance criteria with UI design
Solution
Step 1: Identify clear, testable criteria
The system shall allow users to reset their password via email. clearly states a specific, testable behavior: users can reset passwords via email.Step 2: Evaluate other options for clarity and testability
The other options are vague or subjective and cannot be directly tested.Final Answer:
The system shall allow users to reset their password via email. -> Option CQuick Check:
Clear and testable = The system shall allow users to reset their password via email. [OK]
- Choosing vague or subjective statements
- Ignoring testability of criteria
- Confusing feature description with acceptance criteria
The login button must be disabled until both username and password fields are filled. Which test case will verify this criterion correctly?Solution
Step 1: Understand the criterion condition
The login button should be disabled until both fields have values.Step 2: Identify the correct test case
Check if login button is disabled when username is filled but password is empty. tests that the button is disabled when only username is filled, which matches the criterion.Final Answer:
Check if login button is disabled when username is filled but password is empty. -> Option AQuick Check:
Button disabled until both fields filled = Check if login button is disabled when username is filled but password is empty. [OK]
- Testing button enabled when fields are empty
- Expecting button disabled when both fields filled
- Ignoring partial input cases
The search results must display within 2 seconds after submitting a query. Which of the following is the best way to debug a failing test that shows results after 5 seconds?Solution
Step 1: Analyze the cause of delay
Since results take 5 seconds, check network and server performance to find bottlenecks.Step 2: Avoid ignoring or changing criteria improperly
Ignoring delay or changing criteria without cause is incorrect; removing timer hides the problem.Final Answer:
Check network speed and server response times. -> Option AQuick Check:
Debug performance issues first = Check network speed and server response times. [OK]
- Ignoring the delay problem
- Changing acceptance criteria without reason
- Removing test validations
1. Users can add items to the cart.
2. Cart updates total price correctly.
3. Cart shows an error if quantity exceeds stock.During testing, you find the cart updates price but does not show an error when quantity is too high. What should you do next?
Solution
Step 1: Verify all acceptance criteria
The feature meets price update but fails to show error for quantity exceeding stock.Step 2: Take appropriate action
Since one criterion fails, report a bug and plan to retest after the fix.Final Answer:
Report a bug for missing error message and retest after fix. -> Option DQuick Check:
Failing criteria means report bug = Report a bug for missing error message and retest after fix. [OK]
- Ignoring failed criteria
- Marking incomplete features as done
- Changing acceptance criteria to hide bugs
Ready to prove it?
Pass the test and this pattern moves unknown
