0
0
Testing Fundamentalstesting~15 mins

Testing in Scrum sprints in Testing Fundamentals - Build an Automation Script

Choose your learning style9 modes available
Verify feature functionality within a Scrum sprint
Preconditions (2)
Step 1: Open the application in the test environment.
Step 2: Navigate to the feature page as described in the user story.
Step 3: Perform the main actions described in the user story (e.g., fill form, submit data).
Step 4: Observe the system response and behavior.
Step 5: Report any defects found or mark the feature as passed if no issues.
✅ Expected Result: The feature works as described in the user story without errors or unexpected behavior.
Automation Requirements - Selenium with Python
Assertions Needed:
Verify the feature page loads successfully.
Verify the main actions complete without errors.
Verify the expected success message or result appears.
Best Practices:
Use explicit waits to handle dynamic page elements.
Use Page Object Model to organize locators and actions.
Keep test steps clear and simple to match manual test case.
Use meaningful assertion messages.
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 FeatureTest(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://test-environment.example.com/feature')
        self.wait = WebDriverWait(self.driver, 10)

    def test_feature_functionality(self):
        driver = self.driver
        wait = self.wait

        # Wait for feature page main element to load
        main_element = wait.until(EC.visibility_of_element_located((By.ID, 'feature-main')))
        self.assertTrue(main_element.is_displayed(), 'Feature main element should be visible')

        # Perform main action: fill input and submit
        input_field = driver.find_element(By.ID, 'input-data')
        input_field.clear()
        input_field.send_keys('Test data')

        submit_button = driver.find_element(By.ID, 'submit-btn')
        submit_button.click()

        # Wait for success message
        success_msg = wait.until(EC.visibility_of_element_located((By.ID, 'success-msg')))
        self.assertEqual(success_msg.text, 'Submission successful', 'Success message should appear')

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

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

This test script uses Selenium with Python's unittest framework to automate the manual test case.

setUp() opens the browser and navigates to the feature page in the test environment.

The test test_feature_functionality waits explicitly for the main feature element to appear to ensure the page loaded correctly.

It then fills the input field with test data and clicks the submit button to perform the main action.

After submission, it waits for the success message and asserts that the message text matches the expected result.

tearDown() closes the browser after the test.

This structure follows best practices: explicit waits avoid timing issues, clear assertions verify expected outcomes, and the code is easy to read and maintain.

Common Mistakes - 3 Pitfalls
Using fixed sleep times instead of explicit waits
Hardcoding locators that are brittle or unclear
Not verifying the expected result after actions
Bonus Challenge

Now add data-driven testing with 3 different input values for the feature input field.

Show Hint