0
0
Testing Fundamentalstesting~10 mins

Transitioning to automation in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test simulates a simple web login automation to verify that the login button works and the user is redirected to the dashboard page. It checks if automation can successfully perform a login action and validate the result.

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.get('https://example.com/login')

    def test_login_button_redirects(self):
        driver = self.driver
        # Wait until login button is clickable
        login_button = WebDriverWait(driver, 10).until(
            EC.element_to_be_clickable((By.ID, 'login-btn'))
        )
        login_button.click()
        # Wait until dashboard page loads by checking URL
        WebDriverWait(driver, 10).until(
            EC.url_contains('/dashboard')
        )
        self.assertIn('/dashboard', driver.current_url)

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

if __name__ == '__main__':
    unittest.main()
Execution Trace - 6 Steps
StepActionSystem StateAssertionResult
1Test starts and Chrome browser opensBrowser window opened at https://example.com/login-PASS
2Wait until login button with ID 'login-btn' is clickableLogin page fully loaded with login button visible and enabledLogin button is clickablePASS
3Click the login buttonBrowser navigates to new page after click-PASS
4Wait until URL contains '/dashboard' indicating page loadDashboard page loaded with URL containing '/dashboard'Current URL contains '/dashboard'PASS
5Assert that current URL contains '/dashboard'Dashboard page visibleassertIn('/dashboard', driver.current_url)PASS
6Close browser and end testBrowser closed-PASS
Failure Scenario
Failing Condition: Login button with ID 'login-btn' is not found or not clickable within 10 seconds
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test check after clicking the login button?
AIf the page title changes to 'Login Page'
BIf the URL contains '/dashboard' indicating successful navigation
CIf the login button changes color
DIf an alert popup appears
Key Result
Always wait explicitly for elements to be ready before interacting in automation to avoid flaky tests caused by timing issues.