0
0
Testing Fundamentalstesting~10 mins

Interview preparation for testers in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test simulates a simple interview question scenario where the tester verifies the presence of key UI elements on a sample login page. It checks if the username field, password field, and login button are visible and enabled, ensuring the page is ready for user interaction.

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 TestLoginPageElements(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://example.com/login')

    def test_login_page_elements(self):
        driver = self.driver
        wait = WebDriverWait(driver, 10)

        username = wait.until(EC.presence_of_element_located((By.ID, 'username')))
        password = wait.until(EC.presence_of_element_located((By.ID, 'password')))
        login_button = wait.until(EC.presence_of_element_located((By.ID, 'login-btn')))

        self.assertTrue(username.is_displayed(), 'Username field should be visible')
        self.assertTrue(password.is_displayed(), 'Password field should be visible')
        self.assertTrue(login_button.is_enabled(), 'Login button should be enabled')

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

if __name__ == '__main__':
    unittest.main()
Execution Trace - 9 Steps
StepActionSystem StateAssertionResult
1Test starts and Chrome browser opensChrome browser window is open and ready-PASS
2Navigates to 'https://example.com/login'Login page loads with username, password fields and login button-PASS
3Waits for username field with ID 'username' to be presentUsername input field is present in DOMUsername field is presentPASS
4Waits for password field with ID 'password' to be presentPassword input field is present in DOMPassword field is presentPASS
5Waits for login button with ID 'login-btn' to be presentLogin button is present in DOMLogin button is presentPASS
6Checks if username field is visibleUsername field is visible on pageUsername field is displayedPASS
7Checks if password field is visiblePassword field is visible on pagePassword field is displayedPASS
8Checks if login button is enabledLogin button is enabled and clickableLogin button is enabledPASS
9Test ends and browser closesBrowser window is closed-PASS
Failure Scenario
Failing Condition: Login button with ID 'login-btn' is missing or disabled
Execution Trace Quiz - 3 Questions
Test your understanding
What does the test verify about the login button?
AIt is hidden from the user
BIt is only present but disabled
CIt is present and enabled
DIt is clickable but not visible
Key Result
Always wait explicitly for elements to be present before interacting to avoid flaky tests and ensure reliable verification.