Acceptance testing 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 RegistrationPage: def __init__(self, driver): self.driver = driver self.email_input = (By.ID, 'email') self.password_input = (By.ID, 'password') self.register_button = (By.ID, 'register-btn') self.success_message = (By.ID, 'register-success') def register(self, email, password): WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(self.email_input)).send_keys(email) self.driver.find_element(*self.password_input).send_keys(password) self.driver.find_element(*self.register_button).click() def is_registration_successful(self): return WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located(self.success_message)) 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 login(self, email, password): WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(self.email_input)).send_keys(email) self.driver.find_element(*self.password_input).send_keys(password) self.driver.find_element(*self.login_button).click() class DashboardPage: def __init__(self, driver): self.driver = driver self.welcome_message = (By.ID, 'welcome-msg') def is_welcome_message_displayed(self): return WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located(self.welcome_message)) def test_user_registration_and_login(): driver = webdriver.Chrome() driver.get('https://example.com/register') registration_page = RegistrationPage(driver) registration_page.register('newuser@example.com', 'Password123!') assert registration_page.is_registration_successful(), 'Registration success message not displayed' driver.get('https://example.com/login') login_page = LoginPage(driver) login_page.login('newuser@example.com', 'Password123!') WebDriverWait(driver, 10).until(EC.url_contains('/dashboard')) assert '/dashboard' in driver.current_url, 'Did not navigate to dashboard after login' dashboard_page = DashboardPage(driver) assert dashboard_page.is_welcome_message_displayed(), 'Welcome message not displayed on dashboard' driver.quit()
This test script automates the acceptance test case for user registration and login.
We use the Page Object Model to keep locators and actions organized for each page: RegistrationPage, LoginPage, and DashboardPage.
Explicit waits ensure the test waits for elements to appear before interacting or asserting, avoiding flaky tests.
Assertions check that the registration success message appears, the URL changes to the dashboard after login, and the welcome message is visible on the dashboard.
Finally, the browser is closed with driver.quit() to clean up.
Now add data-driven testing with 3 different user email and password combinations for registration and login.
Practice
acceptance testing in software development?Solution
Step 1: Understand acceptance testing goal
Acceptance testing focuses on confirming the software meets what users expect and need.Step 2: Compare options to acceptance testing purpose
Options B, C, and D relate to other testing types like unit or code testing, not acceptance testing.Final Answer:
To verify the software meets user requirements and expectations -> Option CQuick Check:
Acceptance testing = user requirements check [OK]
- Confusing acceptance testing with unit testing
- Thinking acceptance testing checks code syntax
- Believing acceptance testing is done after release
Solution
Step 1: Identify acceptance test scenario style
Acceptance tests use simple, clear descriptions of what users do and expect.Step 2: Eliminate unrelated options
Options A, C, and D focus on code-level or automated testing, not user-focused scenarios.Final Answer:
Describe user actions and expected results in simple language -> Option DQuick Check:
Acceptance test scenario = user steps + expected results [OK]
- Writing technical code instead of user steps
- Confusing acceptance tests with unit tests
- Using jargon instead of simple language
Given the user is on the login page When the user enters valid credentials Then the user should see the dashboard
What is the expected outcome when this test runs?
Solution
Step 1: Analyze the acceptance test steps
The scenario says valid credentials are entered, so login should succeed.Step 2: Determine expected result from scenario
After successful login, the user should see the dashboard, meaning redirection to dashboard page.Final Answer:
The user is redirected to the dashboard page -> Option AQuick Check:
Valid login = dashboard shown [OK]
- Choosing error message for valid credentials
- Confusing page reload with successful login
- Assuming crash on valid input
Given the user is on the homepage When the user clicks the 'Submit' button Then the form should be submitted
But during testing, clicking 'Submit' does nothing. What is the most likely cause?
Solution
Step 1: Understand the test failure symptom
Clicking 'Submit' does nothing, so the button action is not triggered.Step 2: Identify common causes for no action on click
Incorrect or missing locator means the test cannot find the button to click, causing no action.Final Answer:
The 'Submit' button locator is incorrect or missing -> Option BQuick Check:
Button not found = no click action [OK]
- Assuming form submitted but invisible
- Ignoring locator issues
- Blaming test syntax instead of element identification
Solution
Step 1: Identify acceptance test focus
Acceptance tests check if the user sees expected results after actions, like cart updates.Step 2: Evaluate each option against acceptance testing
Check that adding an item updates the cart total and displays the item describes user-visible behavior after adding item, fitting acceptance testing. Options A, B, and D focus on internal code, database, or styling, not user outcomes.Final Answer:
Check that adding an item updates the cart total and displays the item -> Option AQuick Check:
User sees cart update = acceptance test [OK]
- Choosing technical checks over user outcomes
- Confusing acceptance tests with unit or integration tests
- Ignoring visible feedback to users
Ready to prove it?
Pass the test and this pattern moves unknown
