Bird
Raised Fist0
Testing Fundamentalstesting~10 mins

Interview preparation for testers in Testing Fundamentals - Test Execution Trace

Choose your learning style10 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.

Practice

(1/5)
1. What is the main purpose of software testing in a project?
easy
A. To write code for new features
B. To find defects and ensure the software works as expected
C. To design the user interface
D. To manage the project timeline

Solution

  1. Step 1: Understand the role of testing

    Testing is done to check if the software behaves correctly and to find any bugs.
  2. Step 2: Compare options with testing goals

    Only To find defects and ensure the software works as expected talks about finding defects and verifying software behavior, which matches testing purpose.
  3. Final Answer:

    To find defects and ensure the software works as expected -> Option B
  4. Quick Check:

    Testing = Find defects + Verify behavior [OK]
Hint: Testing finds bugs and checks software works [OK]
Common Mistakes:
  • Confusing testing with coding
  • Thinking testing manages project tasks
  • Mixing testing with design roles
2. Which of the following is the correct syntax to write a test case title?
easy
A. verify_user_login_with_valid_credentials
B. verify user login with valid credentials
C. VerifyUserLoginWithValidCredentials
D. "Verify user login with valid credentials"

Solution

  1. Step 1: Identify proper test case title format

    Test case titles should be clear, descriptive, and readable, usually in sentence case with quotes.
  2. Step 2: Evaluate options for clarity and format

    "Verify user login with valid credentials" uses clear sentence case with quotes, making it easy to understand. Others are less readable or informal.
  3. Final Answer:

    "Verify user login with valid credentials" -> Option D
  4. Quick Check:

    Clear descriptive title in quotes = "Verify user login with valid credentials" [OK]
Hint: Test case titles are clear sentences in quotes [OK]
Common Mistakes:
  • Using camelCase or snake_case for titles
  • Writing titles without quotes or punctuation
  • Using all lowercase without clarity
3. Consider this test scenario: A login form accepts username and password. Which test case will fail if the password field allows empty input?
Test Case: Verify login with empty password
Steps:
1. Enter valid username
2. Leave password empty
3. Click login
Expected Result: Login should fail with error message
What will be the test execution result?
medium
A. Fail, because login succeeds with empty password
B. Pass, because empty password is allowed
C. Pass, because login fails as expected
D. Fail, because username is invalid

Solution

  1. Step 1: Understand the test case and expected behavior

    The test expects login to fail when password is empty, showing an error.
  2. Step 2: Analyze the actual behavior described

    The password field allows empty input, so login succeeds, which is against expected result.
  3. Final Answer:

    Fail, because login succeeds with empty password -> Option A
  4. Quick Check:

    Expected fail but login succeeds = Fail [OK]
Hint: If actual differs from expected, test fails [OK]
Common Mistakes:
  • Assuming empty password is valid
  • Confusing pass/fail with allowed inputs
  • Ignoring expected error message
4. You wrote this test step: Click the submit button but the test fails because the button is not found. What is the most likely cause?
medium
A. The locator used to find the button is incorrect or outdated
B. The submit button does not exist in the application
C. The test script has syntax errors
D. The test environment is down

Solution

  1. Step 1: Identify the failure reason for 'button not found'

    This usually means the test script cannot locate the button element on the page.
  2. Step 2: Evaluate possible causes

    Incorrect or outdated locator is the most common cause, as UI changes can break locators.
  3. Final Answer:

    The locator used to find the button is incorrect or outdated -> Option A
  4. Quick Check:

    Button not found = Locator issue [OK]
Hint: Check locators first when element not found [OK]
Common Mistakes:
  • Assuming button is missing without checking locator
  • Blaming syntax errors without evidence
  • Ignoring environment status
5. You have a list of test cases with their results:
[{"id":1, "result":"pass"}, {"id":2, "result":"fail"}, {"id":3, "result":"pass"}, {"id":4, "result":"fail"}]
How many test cases must be re-executed after fixing defects?
hard
A. 3
B. 4
C. 2
D. 1

Solution

  1. Step 1: Identify test cases with failed results

    From the list, test cases with id 2 and 4 have result 'fail'.
  2. Step 2: Determine re-execution count

    Only failed test cases need re-execution after defects are fixed, so count is 2.
  3. Final Answer:

    2 -> Option C
  4. Quick Check:

    Failed tests = 2 [OK]
Hint: Re-run only failed test cases after fixes [OK]
Common Mistakes:
  • Counting all test cases instead of only failed
  • Confusing pass with fail
  • Ignoring test case results
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