Bird
Raised Fist0
Testing Fundamentalstesting~15 mins

Boundary value analysis in Testing Fundamentals - Build an Automation Script

Choose your learning style10 modes available
Test input field with boundary values
Preconditions (3)
Step 1: Enter 0 in the input field and submit
Step 2: Verify the error message 'Input out of range' is displayed
Step 3: Enter 1 in the input field and submit
Step 4: Verify the success message 'Input accepted' is displayed
Step 5: Enter 100 in the input field and submit
Step 6: Verify the success message 'Input accepted' is displayed
Step 7: Enter 101 in the input field and submit
Step 8: Verify the error message 'Input out of range' is displayed
✅ Expected Result: The application correctly accepts inputs 1 and 100 and rejects inputs 0 and 101 with appropriate messages
Automation Requirements - Selenium with Python
Assertions Needed:
Verify error message 'Input out of range' appears for invalid inputs
Verify success message 'Input accepted' appears for valid inputs
Best Practices:
Use explicit waits to wait for messages to appear
Use clear and maintainable locators (e.g., By.ID or By.CSS_SELECTOR)
Separate test data from test logic
Use assertions that clearly check the message text
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 BoundaryValueTest(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('http://example.com/input-form')  # Replace with actual URL
        self.wait = WebDriverWait(self.driver, 10)

    def enter_value_and_submit(self, value):
        input_field = self.wait.until(EC.presence_of_element_located((By.ID, 'number-input')))
        input_field.clear()
        input_field.send_keys(str(value))
        submit_button = self.driver.find_element(By.ID, 'submit-btn')
        submit_button.click()

    def get_message_text(self):
        message = self.wait.until(EC.visibility_of_element_located((By.ID, 'message')))
        return message.text

    def test_boundary_values(self):
        test_cases = [
            (0, 'Input out of range'),
            (1, 'Input accepted'),
            (100, 'Input accepted'),
            (101, 'Input out of range')
        ]
        for value, expected_message in test_cases:
            with self.subTest(value=value):
                self.enter_value_and_submit(value)
                actual_message = self.get_message_text()
                self.assertEqual(actual_message, expected_message, f'Failed for input {value}')

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

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

This test script uses Selenium with Python's unittest framework to automate boundary value analysis.

setUp: Opens the browser and navigates to the input form page.

enter_value_and_submit: Enters a value into the input field and clicks submit.

get_message_text: Waits for the message element to appear and returns its text.

test_boundary_values: Runs tests for four boundary values (0, 1, 100, 101) checking the displayed message matches expected.

tearDown: Closes the browser after tests.

Explicit waits ensure the test waits for elements and messages properly. Using subTest helps identify which input fails if any.

Common Mistakes - 4 Pitfalls
Using hardcoded sleep instead of explicit waits
Using brittle XPath locators that depend on full element paths
Not clearing the input field before entering new values
Not verifying the exact message text
Bonus Challenge

Now add data-driven testing with 3 different valid inputs and 3 invalid inputs using a test data structure

Show Hint

Practice

(1/5)
1. What is the main goal of Boundary Value Analysis in software testing?
easy
A. To test the software's user interface design
B. To test inputs at the edges of input ranges
C. To test the software's performance under load
D. To test only the middle values of input ranges

Solution

  1. Step 1: Understand boundary value analysis purpose

    Boundary value analysis focuses on testing the edges or limits of input ranges where errors often occur.
  2. Step 2: Compare options with definition

    Only To test inputs at the edges of input ranges correctly describes testing inputs at the edges of input ranges.
  3. Final Answer:

    To test inputs at the edges of input ranges -> Option B
  4. Quick Check:

    Boundary value analysis = test edges [OK]
Hint: Focus on testing minimum and maximum input values [OK]
Common Mistakes:
  • Confusing boundary testing with performance testing
  • Testing only middle values instead of edges
  • Ignoring values just outside the boundaries
2. Which of the following is the correct set of test inputs for boundary value analysis of an input field that accepts values from 1 to 10?
easy
A. 1, 5, 10
B. 0, 5, 10
C. 2, 5, 9
D. 0, 1, 10, 11

Solution

  1. Step 1: Identify boundary values for range 1 to 10

    Boundaries are minimum (1) and maximum (10). Values just outside are 0 and 11.
  2. Step 2: Check options for boundary and just outside values

    0, 1, 10, 11 includes 0 (just below min), 1 (min), 10 (max), and 11 (just above max), which is correct for boundary testing.
  3. Final Answer:

    0, 1, 10, 11 -> Option D
  4. Quick Check:

    Include min, max, and just outside values [OK]
Hint: Always test min, max, and values just outside boundaries [OK]
Common Mistakes:
  • Testing only valid values inside the range
  • Ignoring values just outside the boundaries
  • Choosing random values without boundary focus
3. Consider a function that accepts an integer input from 5 to 15 inclusive. Which of the following test inputs is NOT a valid boundary value test case?
medium
A. 10
B. 5
C. 4
D. 15

Solution

  1. Step 1: Identify boundary values and just outside values

    Boundaries are 5 (min) and 15 (max). Just outside are 4 and 16.
  2. Step 2: Check which input is not a boundary or just outside value

    Inputs 4, 5, and 15 are boundary or just outside values. 10 is a normal middle value, not a boundary test case.
  3. Final Answer:

    10 -> Option A
  4. Quick Check:

    Boundary tests exclude middle values like 10 [OK]
Hint: Exclude middle values; test edges and just outside only [OK]
Common Mistakes:
  • Including middle values as boundary tests
  • Ignoring values just outside boundaries
  • Confusing valid inputs with boundary inputs
4. A tester wrote these boundary test inputs for a field accepting values 10 to 20: 9, 10, 20, 21. The test failed for input 21. What is the most likely reason?
medium
A. The software has a bug accepting 21
B. The test inputs are incorrect; 21 should be accepted
C. 21 is outside the valid input range and should fail
D. Boundary value analysis does not require testing outside the range

Solution

  1. Step 1: Understand boundary test inputs and expected behavior

    Inputs 9 and 21 are just outside the valid range 10 to 20, so failure on 21 is expected.
  2. Step 2: Analyze test failure reason

    Since 21 is invalid input, failure means software correctly rejects it. So test failure is expected, not a bug.
  3. Final Answer:

    21 is outside the valid input range and should fail -> Option C
  4. Quick Check:

    Outside boundary inputs should cause failure [OK]
Hint: Expect failure for inputs just outside boundaries [OK]
Common Mistakes:
  • Thinking failure on invalid input is a bug
  • Not testing values just outside boundaries
  • Assuming all test inputs must pass
5. A form accepts age input from 18 to 60 inclusive. Using boundary value analysis, which set of test inputs covers all necessary boundary cases including just outside values?
hard
A. 17, 18, 60, 61
B. 18, 30, 60
C. 16, 18, 59, 61
D. 18, 19, 59, 60

Solution

  1. Step 1: Identify boundary and just outside values for age 18 to 60

    Boundaries are 18 (min) and 60 (max). Just outside are 17 (below min) and 61 (above max).
  2. Step 2: Check which option includes all boundaries and just outside values

    17, 18, 60, 61 includes 17, 18, 60, and 61, covering all required boundary and just outside values.
  3. Final Answer:

    17, 18, 60, 61 -> Option A
  4. Quick Check:

    Test min, max, and just outside values for full coverage [OK]
Hint: Always include min, max, and one value outside each boundary [OK]
Common Mistakes:
  • Missing just outside boundary values
  • Testing only valid inputs inside range
  • Confusing boundary values with random inputs
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