0
0
Testing Fundamentalstesting~10 mins

Why automation accelerates testing in Testing Fundamentals - Test Execution Impact

Choose your learning style9 modes available
Test Overview

This test simulates an automated test running on a login page. It verifies that automation speeds up testing by quickly opening the browser, entering credentials, clicking login, and checking the welcome message. The test confirms that automation performs these steps faster and more reliably than manual testing.

Test Code - Selenium with unittest
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 TestLoginAutomation(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(5)

    def test_login(self):
        driver = self.driver
        driver.get('https://example.com/login')

        username_input = driver.find_element(By.ID, 'username')
        password_input = driver.find_element(By.ID, 'password')
        login_button = driver.find_element(By.ID, 'login-btn')

        username_input.send_keys('testuser')
        password_input.send_keys('password123')
        login_button.click()

        welcome_message = WebDriverWait(driver, 10).until(
            EC.presence_of_element_located((By.ID, 'welcome-msg'))
        )

        self.assertEqual(welcome_message.text, 'Welcome, testuser!')

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

if __name__ == '__main__':
    unittest.main()
Execution Trace - 10 Steps
StepActionSystem StateAssertionResult
1Test starts and Chrome browser opensChrome browser window is open and ready-PASS
2Browser navigates to https://example.com/loginLogin page is loaded with username, password fields and login button-PASS
3Find username input field by ID 'username'Username input field is located-PASS
4Find password input field by ID 'password'Password input field is located-PASS
5Find login button by ID 'login-btn'Login button is located-PASS
6Enter 'testuser' into username fieldUsername field contains 'testuser'-PASS
7Enter 'password123' into password fieldPassword field contains 'password123'-PASS
8Click the login buttonLogin form submitted, page starts loading next content-PASS
9Wait up to 10 seconds for welcome message element with ID 'welcome-msg' to appearWelcome message element is present on pageCheck that welcome message text equals 'Welcome, testuser!'PASS
10Test ends and browser closesBrowser window is closed-PASS
Failure Scenario
Failing Condition: Welcome message element does not appear or text is incorrect
Execution Trace Quiz - 3 Questions
Test your understanding
What is the first action the automated test performs?
AClick the login button
BEnter username
COpen the Chrome browser
DCheck the welcome message
Key Result
Automated tests speed up testing by performing repetitive steps quickly and consistently, reducing human error and saving time.