⚡️THE RAW TRUTH: When TESTS FAIL ON PURPOSE – What REALLY Happens?
Welcome to the most 🔥high-voltage automation breakdown yet! This isn't your typical "everything passes" script. Oh no — we're breaking rules to teach real-world testing the way professionals debug, validate, and control test execution flow in Java using TestNG + Selenium WebDriver!
This TestNGReport3 example includes:
Clean browser setup ✅
Intentional title vs. header mismatch ❌
Dependency control with skipped execution 🛑
Dynamic wait + XPath targeting 🎯
Full teardown ✅
Let's break it down with energy and insight!
💻 STEP 1: SETUP BROWSER AND NAVIGATE TO LOGIN PAGE
🔧 Concepts Used:
WebDriverManager
ChromeDriver
TestNG @BeforeClass
Browser Maximization & Navigation
Before any tests run, the browser is launched and pointed to the OrangeHRM login page. This is handled by the @BeforeClass method — the setup phase that runs once before all tests.
✅ Ensures environment readiness.
🔗 STEP 2: VERIFY IF URL MATCHES THE LOGIN PAGE
🧠 Concepts Used:
getCurrentUrl()
Assert.assertEquals
Basic Page Validation
The test fetches the current URL from the browser and checks if it matches the expected OrangeHRM login link.
💥 If it doesn’t match — FAIL!
✅ In this case, it should pass. A classic way to confirm navigation.
🏷️ STEP 3: CHECK IF PAGE TITLE EXISTS (AND PRINT IT!)
💡 Concepts Used:
getTitle()
Assert.assertNotNull
Console Output for Debugging
This is a sanity check to make sure the page has a proper HTML -title-.
We validate it's not null, then print it for confirmation.
🎯 Why it matters? If a page has no title, something's off (broken page, error, or redirect failure).
✅ This test should PASS.
💥 STEP 4: INTENTIONAL FAILURE – WRONG HEADER EXPECTATION!
⚠️ Concepts Used:
WebDriverWait
ExpectedConditions
XPath
Assert.assertEquals (Intentionally Failing)
dependsOnMethods
Now here comes the fireworks 💣 — this test is designed to fail.
What it does:
Waits dynamically (10 seconds max) for the h5 header element with the text "Login" to appear.
Captures its text.
Asserts the text is "Welcome", which is WRONG on purpose.
🔥 Outcome?
❌ The test fails and throws an error: "Expected 'Welcome' but found actual header."
Why? Because the header says "Login", not "Welcome" — and that mismatch is our teaching point. This is how you:
Simulate bugs
Test error handling
Practice debugging failed assertions
🧹 STEP 5: CLEAN EXIT – CLOSE THE BROWSER
🧘♂️ Concepts Used:
driver.quit()
TestNG @AfterClass
No matter what happened (pass, fail, skip) — we close the browser at the end to free up resources and avoid memory leaks.
✅ Always clean up after testing like a pro!
💥 FULL TECH STACK & CONCEPTS USED IN THIS PROJECT:
Feature Concept Used
Test Framework TestNG (@BeforeClass, @Test, @AfterClass)
Browser Automation Selenium WebDriver + ChromeDriver
Driver Management WebDriverManager
Element Locating XPath (By.xpath)
Wait Strategy WebDriverWait + ExpectedConditions
Validation Assert.assertEquals, Assert.assertNotNull
Test Flow Control dependsOnMethods
Console Debugging System.out.println()
📣 HASHTAGS:
#TestNG, #SeleniumWebDriver, #JavaAutomation, #IntentionalFailure, #SkippedTest,
#WebDriverWait, #XPathLocator, #TestNGTutorial, #AutomationFails, #QAInsights,
#TestAutomation, #TestDependency, #TestNGMasterclass, #ChromeDriver, #LoginValidation,
#JavaSelenium, #DebugAutomation, #WebTesting, #SoftwareTesting, #QAEngineering