0
0
Testing Fundamentalstesting~10 mins

Error guessing in Testing Fundamentals - Test Execution Trace

Choose your learning style9 modes available
Test Overview

This test simulates error guessing by deliberately entering invalid input to check if the system handles errors gracefully. It verifies that the application shows an appropriate error message when invalid data is submitted.

Test Code - Selenium
Testing Fundamentals
import unittest
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

class TestErrorGuessing(unittest.TestCase):
    def setUp(self):
        self.driver = webdriver.Chrome()
        self.driver.get('https://example.com/login')

    def test_invalid_login(self):
        driver = self.driver
        # Find username field and enter invalid username
        username = WebDriverWait(driver, 10).until(
            EC.presence_of_element_located((By.ID, 'username'))
        )
        username.clear()
        username.send_keys('invalid_user!@#')

        # Find password field and enter invalid password
        password = driver.find_element(By.ID, 'password')
        password.clear()
        password.send_keys('wrongpass123')

        # Click login button
        login_button = driver.find_element(By.ID, 'loginBtn')
        login_button.click()

        # Wait for error message to appear
        error_msg = WebDriverWait(driver, 10).until(
            EC.visibility_of_element_located((By.ID, 'errorMessage'))
        )

        # Assert error message text
        self.assertEqual(error_msg.text, 'Invalid username or password.')

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

if __name__ == '__main__':
    unittest.main()
Execution Trace - 5 Steps
StepActionSystem StateAssertionResult
1Test starts and browser opens the login pageBrowser displays the login page with username, password fields and login button-PASS
2Find username field and enter invalid username 'invalid_user!@#'Username field is filled with invalid characters-PASS
3Find password field and enter invalid password 'wrongpass123'Password field is filled with invalid password-PASS
4Click the login buttonLogin button is clicked, form is submitted-PASS
5Wait for error message to appear with id 'errorMessage'Error message element is visible on the pageVerify error message text equals 'Invalid username or password.'PASS
Failure Scenario
Failing Condition: Error message does not appear or text is different after submitting invalid credentials
Execution Trace Quiz - 3 Questions
Test your understanding
What is the purpose of entering 'invalid_user!@#' in the username field?
ATo check password strength
BTo verify successful login
CTo test how the system handles invalid input
DTo clear the username field
Key Result
Error guessing tests help find hidden bugs by trying inputs that might cause the system to fail, ensuring robust error handling.