Bird
Raised Fist0
Selenium Javatesting~15 mins

Page title and URL retrieval in Selenium Java - Deep Dive

Choose your learning style10 modes available
Overview - Page title and URL retrieval
What is it?
Page title and URL retrieval means getting the current web page's title and its web address (URL) using automated tests. In Selenium with Java, this helps verify that the browser is showing the right page during testing. The title is the text shown on the browser tab, and the URL is the exact address in the browser's address bar. These are basic but important checks in web testing.
Why it matters
Without checking the page title and URL, tests might miss if the browser navigated to the wrong page or if the page loaded incorrectly. This can cause bugs to go unnoticed, leading to bad user experiences or broken features. Retrieving and verifying these values ensures the website behaves as expected and helps catch navigation errors early.
Where it fits
Before learning this, you should know how to set up Selenium WebDriver and open a web page. After this, you can learn more about interacting with page elements, waiting for page loads, and validating page content. This topic is a foundation for verifying navigation and page correctness in automated tests.
Mental Model
Core Idea
Retrieving the page title and URL is like reading the label and address on a package to confirm it’s the right one before opening it.
Think of it like...
Imagine you order a book online. When the delivery arrives, you check the label (page title) and the address (URL) on the package to make sure it’s the book you ordered and it came to your house. Similarly, in testing, you check the page title and URL to confirm the browser shows the correct page.
┌─────────────────────────────┐
│        Browser Window       │
│ ┌───────────────────────┐ │
│ │ Page Title (Tab Text) │ │
│ └───────────────────────┘ │
│ ┌───────────────────────┐ │
│ │ URL (Address Bar)     │ │
│ └───────────────────────┘ │
│ ┌───────────────────────┐ │
│ │ Web Page Content      │ │
│ └───────────────────────┘ │
└─────────────────────────────┘
Build-Up - 7 Steps
1
FoundationUnderstanding Page Title and URL
🤔
Concept: Learn what page title and URL mean in a web browser context.
The page title is the text shown on the browser tab. It usually describes the page content. The URL is the web address shown in the browser's address bar. Both help identify the page you are viewing.
Result
You can recognize the page title and URL visually in any browser.
Knowing what the page title and URL represent helps you understand why verifying them matters in testing.
2
FoundationSetting Up Selenium WebDriver
🤔
Concept: Prepare the Selenium WebDriver to open a browser and load a web page.
Install Selenium Java bindings and a browser driver (like ChromeDriver). Write code to create a WebDriver instance and open a URL using driver.get("https://example.com").
Result
A browser window opens and loads the specified web page.
Setting up WebDriver is essential before you can retrieve page title or URL.
3
IntermediateRetrieving Page Title in Selenium Java
🤔Before reading on: do you think driver.getTitle() returns the page title as a String or an object? Commit to your answer.
Concept: Use the getTitle() method of WebDriver to get the current page title as a String.
Example: String title = driver.getTitle(); System.out.println("Page title is: " + title);
Result
The console prints the exact title text of the current page.
Understanding that getTitle() returns a simple String lets you easily compare it with expected titles in tests.
4
IntermediateRetrieving Current URL in Selenium Java
🤔Before reading on: do you think driver.getCurrentUrl() returns the URL before or after any redirects? Commit to your answer.
Concept: Use the getCurrentUrl() method of WebDriver to get the current page URL as a String after all navigation and redirects.
Example: String url = driver.getCurrentUrl(); System.out.println("Current URL is: " + url);
Result
The console prints the full URL of the page currently loaded in the browser.
Knowing getCurrentUrl() reflects the final URL after redirects helps you verify navigation correctness.
5
IntermediateUsing Assertions to Verify Title and URL
🤔Before reading on: do you think assertions stop the test immediately on failure or continue running? Commit to your answer.
Concept: Use assertions to check if the retrieved title and URL match expected values, causing test failure if they don't.
Example with JUnit: import static org.junit.jupiter.api.Assertions.*; String expectedTitle = "Example Domain"; assertEquals(expectedTitle, driver.getTitle()); String expectedUrl = "https://example.com/"; assertEquals(expectedUrl, driver.getCurrentUrl());
Result
Test passes if title and URL match; fails with error if not.
Assertions provide automated checks that confirm the page is correct, preventing silent errors.
6
AdvancedHandling Dynamic Titles and URLs
🤔Before reading on: do you think exact string matching always works for titles and URLs on dynamic sites? Commit to your answer.
Concept: Learn strategies to handle pages where titles or URLs change dynamically, like using contains() or regex matching.
Example: String title = driver.getTitle(); assertTrue(title.contains("Welcome")); String url = driver.getCurrentUrl(); assertTrue(url.matches("https://example.com/page/\d+"));
Result
Tests pass if title or URL partially match expected patterns, allowing flexibility.
Knowing how to handle dynamic values prevents flaky tests that fail due to small expected changes.
7
ExpertAvoiding Common Pitfalls in Title and URL Checks
🤔Before reading on: do you think checking title and URL alone guarantees the page loaded fully and correctly? Commit to your answer.
Concept: Understand the limitations of title and URL checks and learn to combine them with other validations like element presence or page state.
Example: // Title and URL check assertEquals("Home", driver.getTitle()); assertEquals("https://example.com/home", driver.getCurrentUrl()); // Additional check assertTrue(driver.findElement(By.id("main-content")).isDisplayed());
Result
Tests become more reliable by verifying page content along with title and URL.
Knowing that title and URL are necessary but not sufficient checks helps build robust tests.
Under the Hood
When Selenium WebDriver calls getTitle() or getCurrentUrl(), it communicates with the browser through the WebDriver protocol. The browser returns the current page's title or URL from its internal state. These values reflect the page loaded in the active tab, updated after navigation or redirects. The driver does not parse the page itself but relies on the browser's rendering engine to provide accurate information.
Why designed this way?
This design separates test code from browser internals, allowing WebDriver to work with many browsers uniformly. Returning simple strings for title and URL keeps the API easy to use and efficient. Alternatives like parsing page source would be slower and more complex. The WebDriver protocol standardizes these commands for cross-browser compatibility.
┌───────────────┐       ┌───────────────┐       ┌───────────────┐
│ Selenium Test │──────▶│ WebDriver API │──────▶│   Browser     │
│   (Java)      │       │ (Commands)    │       │ (Rendering)   │
└───────────────┘       └───────────────┘       └───────────────┘
        │                      │                      │
        │ getTitle()           │                      │
        │--------------------▶│                      │
        │                      │ get title string     │
        │                      │--------------------▶│
        │                      │                      │
        │                      │◀--------------------│
        │◀---------------------│                      │
        │  returns title string │                      │
Myth Busters - 4 Common Misconceptions
Quick: Does driver.getTitle() always return the page title immediately after driver.get()? Commit yes or no.
Common Belief:driver.getTitle() instantly returns the correct page title right after calling driver.get(url).
Tap to reveal reality
Reality:If the page is still loading or redirecting, getTitle() may return an old or empty title. You often need to wait for the page to load fully before retrieving the title.
Why it matters:Without waiting, tests may fail or pass incorrectly, causing flaky or unreliable results.
Quick: Does driver.getCurrentUrl() return the URL you initially requested or the final URL after redirects? Commit your answer.
Common Belief:driver.getCurrentUrl() always returns the URL passed to driver.get(), ignoring redirects.
Tap to reveal reality
Reality:driver.getCurrentUrl() returns the actual URL loaded in the browser after all redirects and navigation.
Why it matters:Tests that expect the original URL may fail if redirects occur, leading to false negatives.
Quick: Is checking only the page title enough to confirm the page loaded correctly? Commit yes or no.
Common Belief:If the page title is correct, the page has loaded fully and correctly.
Tap to reveal reality
Reality:The title can be correct even if page content is missing or broken. Additional checks are needed for full validation.
Why it matters:Relying solely on title can miss critical page errors, causing bugs to slip through.
Quick: Does getTitle() return the visible text on the page or the title tag content? Commit your answer.
Common Belief:getTitle() returns any visible text on the page.
Tap to reveal reality
Reality:getTitle() returns only the content of the tag in the HTML head, not visible page text.</span></div><div class="dlm-myth-why"><span class="dlm-myth-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="M459-60q-10-3.33-19-10L186.67-260q-12.34-9-19.5-23.33-7.17-14.34-7.17-30v-500q0-27 19.83-46.84Q199.67-880 226.67-880h506.66q27 0 46.84 19.83Q800-840.33 800-813.33v500q0 15.66-7.17 30-7.16 14.33-19.5 23.33L520-70q-9 6.67-19 10t-21 3.33q-11 0-21-3.33Zm-21.67-394-70.66-70.67q-10-10-23.34-9.83-13.33.17-23.33 9.83-10 10-10.17 23.5-.16 13.5 9.84 23.5l95 94.34q10 10 23.33 10 13.33 0 23.33-10l179.34-179.34q10-10 9.5-23.33-.5-13.33-10.17-23.33-10-10-23.5-10.17-13.5-.17-23.5 9.83L437.33-454Z"></path></svg></span>Why it matters:</span><span>Confusing these can lead to wrong assertions and test failures.</span></div></div></div></div></div></article><article class="content-card dlm-card"><div class="code-articles-card-header"><span class="card-icon intro"><span class="new-material-symbols icon-hw-24"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#3B82F6"><path d="M853.33-315.33V-562l-342 185q-15.33 8.67-32 8.33-16.66-.33-32-9L93.33-571q-9-5.33-12.83-12.67Q76.67-591 76.67-600q0-9 3.83-16.33 3.83-7.34 12.83-12.67l354-193.33q7.67-4.34 15.5-6.5 7.84-2.17 16.5-2.17 8.67 0 16.5 2.17 7.84 2.16 15.5 6.5l391 212.66q8.67 4.34 13.17 12.5Q920-589 920-580v264.67q0 14.33-9.5 23.83-9.5 9.5-23.83 9.5-14.34 0-23.84-9.5t-9.5-23.83Zm-406 177.66-220-120q-16-9-25.33-24.66-9.33-15.67-9.33-34.34v-166.66l254.66 139q15.34 8.66 32 8.66 16.67 0 32-8.66l254.67-139v166.66q0 18.67-9.33 34.34-9.34 15.66-25.34 24.66l-220 120q-7.66 4.34-15.5 6.5Q488-129 479.33-129q-8.66 0-16.5-2.17-7.83-2.16-15.5-6.5Z"></path></svg></span></span><span class="codefly-card-title">Expert Zone</span></div><div class="code-articles-card-body"><div class="dlm-expert-nuances"><div class="dlm-nuance-item"><div class="dlm-nuance-number">1</div><div class="dlm-nuance-text">Some websites dynamically change the page title after loading using JavaScript, so getTitle() may change during the test session.</div></div><div class="dlm-nuance-item"><div class="dlm-nuance-number">2</div><div class="dlm-nuance-text">In multi-tab or multi-window tests, getTitle() and getCurrentUrl() always refer to the active window; switching windows is necessary to get info from others.</div></div><div class="dlm-nuance-item"><div class="dlm-nuance-number">3</div><div class="dlm-nuance-text">Browser security policies can affect URL retrieval, especially with redirects or cross-origin navigation, causing unexpected URL values.</div></div></div><div class="dlm-when-not"><div class="dlm-when-not-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#EF4444"><path d="m480-433.33 124.67 124.66Q614.33-299 628-299q13.67 0 23.33-9.67Q661-318.33 661-332q0-13.67-9.67-23.33L526.67-480l124.66-124.67Q661-614.33 661-628q0-13.67-9.67-23.33Q641.67-661 628-661q-13.67 0-23.33 9.67L480-526.67 355.33-651.33Q345.67-661 332-661q-13.67 0-23.33 9.67Q299-641.67 299-628q0 13.67 9.67 23.33L433.33-480 308.67-355.33Q299-345.67 299-332q0 13.67 9.67 23.33Q318.33-299 332-299q13.67 0 23.33-9.67L480-433.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span>When NOT to use</div><div>Relying only on page title and URL is insufficient for complex pages with dynamic content or single-page applications. Instead, use element presence checks, JavaScript execution results, or network monitoring for deeper validation.</div></div><div class="dlm-production"><div class="dlm-production-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="m422-395.33-94-94q-9.67-9.67-24-9.67t-24.67 10.33q-9.66 9.67-9.66 24 0 14.34 9.66 24l119.34 120q10 10 23.33 10 13.33 0 23.33-10L680-555.33q10.33-10.34 10.33-24.67 0-14.33-10.33-24.67-10.33-9.66-25-9.33-14.67.33-24.33 10L422-395.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span>Production Patterns</div><div>In real-world tests, title and URL checks are combined with waits for page readiness and element visibility. Tests often use partial matches or regex for titles/URLs to handle dynamic parts. Also, these checks are part of navigation validation steps in end-to-end test suites.</div></div></div></article><article class="content-card dlm-card"><div class="code-articles-card-header"><span class="card-icon intro"><span class="new-material-symbols icon-hw-24"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#3B82F6"><path d="M602.67-120v-123.33h-156V-650H358v126.67H80V-840h278v123.33h244.67V-840H880v316.67H602.67V-650h-89.34v340h89.34v-126.67H880V-120H602.67Zm-456-653.33V-590v-183.33ZM669.33-370v183.33V-370Zm0-403.33V-590v-183.33Zm0 183.33h144v-183.33h-144V-590Zm0 403.33h144V-370h-144v183.33ZM146.67-590h144.66v-183.33H146.67V-590Z"></path></svg></span></span><span class="codefly-card-title">Connections</span></div><div class="code-articles-card-body"><div class="dlm-connections-list"><div class="dlm-connection-item"><div class="dlm-connection-to">Assertions in Automated Testing</div><div class="dlm-connection-rel">Builds-on</div><div class="dlm-connection-insight"><span class="dlm-insight-icon"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="yellow-icon-color" height="22" width="22" xmlns="http://www.w3.org/2000/svg"><path d="M7.94101 18C7.64391 16.7274 6.30412 15.6857 5.75395 14.9992C4.65645 13.6297 4 11.8915 4 10C4 5.58172 7.58172 2 12 2C16.4183 2 20 5.58172 20 10C20 11.8925 19.3428 13.6315 18.2443 15.0014C17.6944 15.687 16.3558 16.7276 16.059 18H7.94101ZM16 20V21C16 22.1046 15.1046 23 14 23H10C8.89543 23 8 22.1046 8 21V20H16ZM13 10.0048V6L8.5 12.0048H11V16.0048L15.5 10.0048H13Z"></path></svg></span><span>Understanding how to retrieve page title and URL enables meaningful assertions that confirm navigation success in tests.</span></div></div><div class="dlm-connection-item"><div class="dlm-connection-to">WebDriver Waits and Synchronization</div><div class="dlm-connection-rel">Builds-on</div><div class="dlm-connection-insight"><span class="dlm-insight-icon"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="yellow-icon-color" height="22" width="22" xmlns="http://www.w3.org/2000/svg"><path d="M7.94101 18C7.64391 16.7274 6.30412 15.6857 5.75395 14.9992C4.65645 13.6297 4 11.8915 4 10C4 5.58172 7.58172 2 12 2C16.4183 2 20 5.58172 20 10C20 11.8925 19.3428 13.6315 18.2443 15.0014C17.6944 15.687 16.3558 16.7276 16.059 18H7.94101ZM16 20V21C16 22.1046 15.1046 23 14 23H10C8.89543 23 8 22.1046 8 21V20H16ZM13 10.0048V6L8.5 12.0048H11V16.0048L15.5 10.0048H13Z"></path></svg></span><span>Knowing that title and URL may not be immediately available teaches the importance of waits to avoid flaky tests.</span></div></div><div class="dlm-connection-item"><div class="dlm-connection-to">Package Labeling and Delivery Verification (Logistics)</div><div class="dlm-connection-rel">Analogy-based cross-domain</div><div class="dlm-connection-insight"><span class="dlm-insight-icon"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="yellow-icon-color" height="22" width="22" xmlns="http://www.w3.org/2000/svg"><path d="M7.94101 18C7.64391 16.7274 6.30412 15.6857 5.75395 14.9992C4.65645 13.6297 4 11.8915 4 10C4 5.58172 7.58172 2 12 2C16.4183 2 20 5.58172 20 10C20 11.8925 19.3428 13.6315 18.2443 15.0014C17.6944 15.687 16.3558 16.7276 16.059 18H7.94101ZM16 20V21C16 22.1046 15.1046 23 14 23H10C8.89543 23 8 22.1046 8 21V20H16ZM13 10.0048V6L8.5 12.0048H11V16.0048L15.5 10.0048H13Z"></path></svg></span><span>Just like checking a package label and address ensures correct delivery, verifying page title and URL ensures correct page navigation in testing.</span></div></div></div></div></article><article class="content-card dlm-card"><div class="code-articles-card-header"><span class="card-icon project"><span class="new-material-symbols icon-hw-24"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#EF4444"><path d="m480-513.33 80.67 80.66Q570.33-423 584-423q13.67 0 23.33-9.67Q617-442.33 617-456q0-13.67-9.67-23.33L526.67-560l80.66-80.67Q617-650.33 617-664q0-13.67-9.67-23.33Q597.67-697 584-697q-13.67 0-23.33 9.67L480-606.67l-80.67-80.66Q389.67-697 376-697q-13.67 0-23.33 9.67Q343-677.67 343-664q0 13.67 9.67 23.33L433.33-560l-80.66 80.67Q343-469.67 343-456q0 13.67 9.67 23.33Q362.33-423 376-423q13.67 0 23.33-9.67L480-513.33ZM240-240 136.67-136.67Q121-121 100.5-129.6 80-138.21 80-160.33v-653q0-27 19.83-46.84Q119.67-880 146.67-880h666.66q27 0 46.84 19.83Q880-840.33 880-813.33v506.66q0 27-19.83 46.84Q840.33-240 813.33-240H240Zm-28.67-66.67h602v-506.66H146.67v575l64.66-68.34Zm-64.66 0v-506.66 506.66Z"></path></svg></span></span><span class="codefly-card-title">Common Pitfalls</span></div><div class="code-articles-card-body"><div class="dlm-pitfalls-list"><div class="dlm-pitfall-item"><div class="dlm-pitfall-header"><span class="dlm-pitfall-number">#<!-- -->1</span><span class="dlm-pitfall-title">Checking page title immediately after navigation without waiting.</span></div><div class="dlm-pitfall-body"><div class="dlm-pitfall-wrong"><span class="dlm-pitfall-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#EF4444"><path d="m480-433.33 124.67 124.66Q614.33-299 628-299q13.67 0 23.33-9.67Q661-318.33 661-332q0-13.67-9.67-23.33L526.67-480l124.66-124.67Q661-614.33 661-628q0-13.67-9.67-23.33Q641.67-661 628-661q-13.67 0-23.33 9.67L480-526.67 355.33-651.33Q345.67-661 332-661q-13.67 0-23.33 9.67Q299-641.67 299-628q0 13.67 9.67 23.33L433.33-480 308.67-355.33Q299-345.67 299-332q0 13.67 9.67 23.33Q318.33-299 332-299q13.67 0 23.33-9.67L480-433.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span>Wrong approach:</span><span>driver.get("https://example.com"); String title = driver.getTitle(); assertEquals("Example Domain", title);</span></div><div class="dlm-pitfall-right"><span class="dlm-pitfall-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="m422-395.33-94-94q-9.67-9.67-24-9.67t-24.67 10.33q-9.66 9.67-9.66 24 0 14.34 9.66 24l119.34 120q10 10 23.33 10 13.33 0 23.33-10L680-555.33q10.33-10.34 10.33-24.67 0-14.33-10.33-24.67-10.33-9.66-25-9.33-14.67.33-24.33 10L422-395.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span>Correct approach:</span><span>driver.get("https://example.com"); new WebDriverWait(driver, Duration.ofSeconds(10)) .until(ExpectedConditions.titleIs("Example Domain")); String title = driver.getTitle(); assertEquals("Example Domain", title);</span></div><div class="dlm-pitfall-root"><span class="dlm-pitfall-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#3B82F6"><path d="M400-320q100 0 170-70t70-170q0-100-70-170t-170-70q-100 0-170 70t-70 170q0 100 70 170t170 70Zm-28.5-131.5Q360-463 360-480v-200q0-17 11.5-28.5T400-720q17 0 28.5 11.5T440-680v200q0 17-11.5 28.5T400-440q-17 0-28.5-11.5Zm-140 0Q220-463 220-480v-120q0-17 11.5-28.5T260-640q17 0 28.5 11.5T300-600v120q0 17-11.5 28.5T260-440q-17 0-28.5-11.5Zm280 0Q500-463 500-480v-80q0-17 11.5-28.5T540-600q17 0 28.5 11.5T580-560v80q0 17-11.5 28.5T540-440q-17 0-28.5-11.5ZM400-240q-134 0-227-93T80-560q0-134 93-227t227-93q134 0 227 93t93 227q0 56-17.5 106T653-363l199 199q11 11 11 28t-11 28q-11 11-28 11t-28-11L597-307q-41 32-91 49.5T400-240Z"></path></svg></span>Root cause:</span><span>The test tries to get the title before the page finishes loading, causing flaky failures.</span></div></div></div><div class="dlm-pitfall-item"><div class="dlm-pitfall-header"><span class="dlm-pitfall-number">#<!-- -->2</span><span class="dlm-pitfall-title">Using exact string match for URLs that include dynamic query parameters.</span></div><div class="dlm-pitfall-body"><div class="dlm-pitfall-wrong"><span class="dlm-pitfall-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#EF4444"><path d="m480-433.33 124.67 124.66Q614.33-299 628-299q13.67 0 23.33-9.67Q661-318.33 661-332q0-13.67-9.67-23.33L526.67-480l124.66-124.67Q661-614.33 661-628q0-13.67-9.67-23.33Q641.67-661 628-661q-13.67 0-23.33 9.67L480-526.67 355.33-651.33Q345.67-661 332-661q-13.67 0-23.33 9.67Q299-641.67 299-628q0 13.67 9.67 23.33L433.33-480 308.67-355.33Q299-345.67 299-332q0 13.67 9.67 23.33Q318.33-299 332-299q13.67 0 23.33-9.67L480-433.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span>Wrong approach:</span><span>assertEquals("https://example.com/page?session=123", driver.getCurrentUrl());</span></div><div class="dlm-pitfall-right"><span class="dlm-pitfall-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="m422-395.33-94-94q-9.67-9.67-24-9.67t-24.67 10.33q-9.66 9.67-9.66 24 0 14.34 9.66 24l119.34 120q10 10 23.33 10 13.33 0 23.33-10L680-555.33q10.33-10.34 10.33-24.67 0-14.33-10.33-24.67-10.33-9.66-25-9.33-14.67.33-24.33 10L422-395.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span>Correct approach:</span><span>assertTrue(driver.getCurrentUrl().startsWith("https://example.com/page"));</span></div><div class="dlm-pitfall-root"><span class="dlm-pitfall-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#3B82F6"><path d="M400-320q100 0 170-70t70-170q0-100-70-170t-170-70q-100 0-170 70t-70 170q0 100 70 170t170 70Zm-28.5-131.5Q360-463 360-480v-200q0-17 11.5-28.5T400-720q17 0 28.5 11.5T440-680v200q0 17-11.5 28.5T400-440q-17 0-28.5-11.5Zm-140 0Q220-463 220-480v-120q0-17 11.5-28.5T260-640q17 0 28.5 11.5T300-600v120q0 17-11.5 28.5T260-440q-17 0-28.5-11.5Zm280 0Q500-463 500-480v-80q0-17 11.5-28.5T540-600q17 0 28.5 11.5T580-560v80q0 17-11.5 28.5T540-440q-17 0-28.5-11.5ZM400-240q-134 0-227-93T80-560q0-134 93-227t227-93q134 0 227 93t93 227q0 56-17.5 106T653-363l199 199q11 11 11 28t-11 28q-11 11-28 11t-28-11L597-307q-41 32-91 49.5T400-240Z"></path></svg></span>Root cause:</span><span>Dynamic parts of the URL cause exact matches to fail unnecessarily.</span></div></div></div><div class="dlm-pitfall-item"><div class="dlm-pitfall-header"><span class="dlm-pitfall-number">#<!-- -->3</span><span class="dlm-pitfall-title">Assuming getTitle() returns visible page content.</span></div><div class="dlm-pitfall-body"><div class="dlm-pitfall-wrong"><span class="dlm-pitfall-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#EF4444"><path d="m480-433.33 124.67 124.66Q614.33-299 628-299q13.67 0 23.33-9.67Q661-318.33 661-332q0-13.67-9.67-23.33L526.67-480l124.66-124.67Q661-614.33 661-628q0-13.67-9.67-23.33Q641.67-661 628-661q-13.67 0-23.33 9.67L480-526.67 355.33-651.33Q345.67-661 332-661q-13.67 0-23.33 9.67Q299-641.67 299-628q0 13.67 9.67 23.33L433.33-480 308.67-355.33Q299-345.67 299-332q0 13.67 9.67 23.33Q318.33-299 332-299q13.67 0 23.33-9.67L480-433.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span>Wrong approach:</span><span>String title = driver.getTitle(); assertTrue(title.contains("Welcome Message")); // expecting visible text</span></div><div class="dlm-pitfall-right"><span class="dlm-pitfall-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="m422-395.33-94-94q-9.67-9.67-24-9.67t-24.67 10.33q-9.66 9.67-9.66 24 0 14.34 9.66 24l119.34 120q10 10 23.33 10 13.33 0 23.33-10L680-555.33q10.33-10.34 10.33-24.67 0-14.33-10.33-24.67-10.33-9.66-25-9.33-14.67.33-24.33 10L422-395.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span>Correct approach:</span><span>String pageText = driver.findElement(By.tagName("body")).getText(); assertTrue(pageText.contains("Welcome Message"));</span></div><div class="dlm-pitfall-root"><span class="dlm-pitfall-label"><span class="new-material-symbols icon-hw-20"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#3B82F6"><path d="M400-320q100 0 170-70t70-170q0-100-70-170t-170-70q-100 0-170 70t-70 170q0 100 70 170t170 70Zm-28.5-131.5Q360-463 360-480v-200q0-17 11.5-28.5T400-720q17 0 28.5 11.5T440-680v200q0 17-11.5 28.5T400-440q-17 0-28.5-11.5Zm-140 0Q220-463 220-480v-120q0-17 11.5-28.5T260-640q17 0 28.5 11.5T300-600v120q0 17-11.5 28.5T260-440q-17 0-28.5-11.5Zm280 0Q500-463 500-480v-80q0-17 11.5-28.5T540-600q17 0 28.5 11.5T580-560v80q0 17-11.5 28.5T540-440q-17 0-28.5-11.5ZM400-240q-134 0-227-93T80-560q0-134 93-227t227-93q134 0 227 93t93 227q0 56-17.5 106T653-363l199 199q11 11 11 28t-11 28q-11 11-28 11t-28-11L597-307q-41 32-91 49.5T400-240Z"></path></svg></span>Root cause:</span><span>Confusing the page title with visible page text leads to wrong assertions.</span></div></div></div></div></div></article><article class="content-card dlm-card"><div class="code-articles-card-header"><span class="card-icon summary"><span class="new-material-symbols icon-hw-24"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="M186.67-120q-27.5 0-47.09-19.58Q120-159.17 120-186.67v-586.66q0-27.5 19.58-47.09Q159.17-840 186.67-840h192.66q7.67-35.33 35.84-57.67Q443.33-920 480-920t64.83 22.33Q573-875.33 580.67-840h192.66q27.5 0 47.09 19.58Q840-800.83 840-773.33v586.66q0 27.5-19.58 47.09Q800.83-120 773.33-120H186.67Zm0-66.67h586.66v-586.66H186.67v586.66ZM313.33-280H522q14.17 0 23.75-9.62 9.58-9.61 9.58-23.83 0-14.22-9.58-23.72-9.58-9.5-23.75-9.5H313.33q-14.16 0-23.75 9.62-9.58 9.62-9.58 23.83 0 14.22 9.58 23.72 9.59 9.5 23.75 9.5Zm0-166.67h333.34q14.16 0 23.75-9.61 9.58-9.62 9.58-23.84 0-14.21-9.58-23.71-9.59-9.5-23.75-9.5H313.33q-14.16 0-23.75 9.61-9.58 9.62-9.58 23.84 0 14.21 9.58 23.71 9.59 9.5 23.75 9.5Zm0-166.66h333.34q14.16 0 23.75-9.62 9.58-9.62 9.58-23.83 0-14.22-9.58-23.72-9.59-9.5-23.75-9.5H313.33q-14.16 0-23.75 9.62-9.58 9.61-9.58 23.83 0 14.22 9.58 23.72 9.59 9.5 23.75 9.5ZM503.5-804.5q9.83-9.83 9.83-23.5t-9.83-23.5q-9.83-9.83-23.5-9.83t-23.5 9.83q-9.83 9.83-9.83 23.5t9.83 23.5q9.83 9.83 23.5 9.83t23.5-9.83ZM186.67-186.67v-586.66 586.66Z"></path></svg></span></span><span class="codefly-card-title">Key Takeaways</span></div><div class="code-articles-card-body"><div class="summary-list"><div class="summary-item"><span class="new-material-symbols icon-hw-26"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="m422-395.33-94-94q-9.67-9.67-24-9.67t-24.67 10.33q-9.66 9.67-9.66 24 0 14.34 9.66 24l119.34 120q10 10 23.33 10 13.33 0 23.33-10L680-555.33q10.33-10.34 10.33-24.67 0-14.33-10.33-24.67-10.33-9.66-25-9.33-14.67.33-24.33 10L422-395.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span><span class="summary-text">Page title and URL retrieval are fundamental checks to confirm correct page navigation in automated web tests.</span></div><div class="summary-item"><span class="new-material-symbols icon-hw-26"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="m422-395.33-94-94q-9.67-9.67-24-9.67t-24.67 10.33q-9.66 9.67-9.66 24 0 14.34 9.66 24l119.34 120q10 10 23.33 10 13.33 0 23.33-10L680-555.33q10.33-10.34 10.33-24.67 0-14.33-10.33-24.67-10.33-9.66-25-9.33-14.67.33-24.33 10L422-395.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span><span class="summary-text">Selenium WebDriver provides simple methods getTitle() and getCurrentUrl() that return strings representing the current page's title and URL.</span></div><div class="summary-item"><span class="new-material-symbols icon-hw-26"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="m422-395.33-94-94q-9.67-9.67-24-9.67t-24.67 10.33q-9.66 9.67-9.66 24 0 14.34 9.66 24l119.34 120q10 10 23.33 10 13.33 0 23.33-10L680-555.33q10.33-10.34 10.33-24.67 0-14.33-10.33-24.67-10.33-9.66-25-9.33-14.67.33-24.33 10L422-395.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span><span class="summary-text">Always wait for the page to load fully before retrieving title or URL to avoid flaky tests.</span></div><div class="summary-item"><span class="new-material-symbols icon-hw-26"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="m422-395.33-94-94q-9.67-9.67-24-9.67t-24.67 10.33q-9.66 9.67-9.66 24 0 14.34 9.66 24l119.34 120q10 10 23.33 10 13.33 0 23.33-10L680-555.33q10.33-10.34 10.33-24.67 0-14.33-10.33-24.67-10.33-9.66-25-9.33-14.67.33-24.33 10L422-395.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span><span class="summary-text">Use assertions to compare retrieved title and URL with expected values, but handle dynamic content flexibly.</span></div><div class="summary-item"><span class="new-material-symbols icon-hw-26"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" fill="#10B981"><path d="m422-395.33-94-94q-9.67-9.67-24-9.67t-24.67 10.33q-9.66 9.67-9.66 24 0 14.34 9.66 24l119.34 120q10 10 23.33 10 13.33 0 23.33-10L680-555.33q10.33-10.34 10.33-24.67 0-14.33-10.33-24.67-10.33-9.66-25-9.33-14.67.33-24.33 10L422-395.33ZM480-80q-82.33 0-155.33-31.5-73-31.5-127.34-85.83Q143-251.67 111.5-324.67T80-480q0-83 31.5-156t85.83-127q54.34-54 127.34-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 82.33-31.5 155.33-31.5 73-85.5 127.34Q709-143 636-111.5T480-80Z"></path></svg></span><span class="summary-text">Title and URL checks alone are not enough; combine them with other validations for robust test coverage.</span></div></div></div></article></div><div><article class="content-card" id="practice"><div class="code-articles-card-header justify-content-between"><div class="d-flex align-items-center" style="gap:12px"><span class="card-icon nofill intro"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="blue-icon-color site-fs-20" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path><path d="M12 7a5 5 0 1 0 5 5"></path><path d="M13 3.055a9 9 0 1 0 7.941 7.945"></path><path d="M15 6v3h3l3 -3h-3v-3z"></path><path d="M15 9l-3 3"></path></svg></span><h2 class="codefly-card-title mb-0 pb-0">Practice</h2></div><span class="site-fs-15">(<!-- -->1<!-- -->/<!-- -->5<!-- -->)</span></div><div class="code-articles-card-body" data-theme="light"><div class=""><div class="mb-4"><div class="practice-content"><div class="text-pre-wrap dbd-txt-theme-intense pb-3">1<!-- -->. <!-- -->Which Selenium WebDriver method is used to retrieve the title of the current webpage as a string?</div></div><div class="question-pills-container " style="padding-top:unset"><span class="level-badge">easy</span></div></div><div class=""><div class="practice-options"><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>A<!-- -->. <code>getTitle()</code></span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>B<!-- -->. <code>getPageTitle()</code></span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>C<!-- -->. <code>getCurrentUrl()</code></span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>D<!-- -->. <code>getUrl()</code></span></div></div><div class="py-3"><button class="site-btn" style="width:200px" disabled="">Verify</button></div></div><div class="py-2 d-none"><div class="practice-helper-btns-wrapper"></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-solution-box"><h4 class="helper-solution-box-title">Solution</h4><div class="practice-helper-body"><ol><li><h4>Step 1: Understand the purpose of <code>getTitle()</code></h4>This method returns the title of the current webpage as a string, which helps verify the page loaded.</li><li><h4>Step 2: Compare with other methods</h4><code>getCurrentUrl()</code> returns the URL, not the title. The other options are not valid Selenium methods.</li><li><h4>Final Answer:</h4><strong>getTitle()</strong> -> Option A</li><li><h4>Quick Check:</h4>Page title retrieval = getTitle() [OK]</li></ol></div></div></div></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-hint-box"><div class="practice-helper-body"><strong class="helper-hint-box-title">Hint: </strong>Remember: Title uses getTitle(), URL uses getCurrentUrl() [OK]</div></div></div></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-mistakes-box"><div class="practice-helper-body"><strong class="helper-mistakes-box-title">Common Mistakes: </strong><ul class="ph-mistakes-list"><li class="ph-mistake-item mb-0">Confusing getTitle() with getCurrentUrl()</li><li class="ph-mistake-item mb-0">Using non-existent methods like getPageTitle()</li><li class="ph-mistake-item mb-0">Trying to get title from URL method</li></ul></div></div></div></div></div></div><div class="d-none"><div class="mb-4"><div class="practice-content"><div class="text-pre-wrap dbd-txt-theme-intense pb-3">2<!-- -->. <!-- -->Which of the following is the correct Java syntax to get the current page URL using Selenium WebDriver stored in variable <code>driver</code>?</div></div><div class="question-pills-container " style="padding-top:unset"><span class="level-badge">easy</span></div></div><div class=""><div class="practice-options"><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>A<!-- -->. <!-- -->String url = driver.getUrl();</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>B<!-- -->. <!-- -->String url = driver.currentUrl();</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>C<!-- -->. <!-- -->String url = driver.getPageUrl();</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>D<!-- -->. <!-- -->String url = driver.getCurrentUrl();</span></div></div><div class="py-3"><button class="site-btn" style="width:200px" disabled="">Verify</button></div></div><div class="py-2 d-none"><div class="practice-helper-btns-wrapper"></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-solution-box"><h4 class="helper-solution-box-title">Solution</h4><div class="practice-helper-body"><ol><li><h4>Step 1: Identify the correct method name</h4>The correct Selenium method to get the current URL is <code>getCurrentUrl()</code>.</li><li><h4>Step 2: Check Java syntax correctness</h4>Assigning the result to a String variable with <code>String url = driver.getCurrentUrl();</code> is correct syntax.</li><li><h4>Final Answer:</h4><strong>String url = driver.getCurrentUrl();</strong> -> Option D</li><li><h4>Quick Check:</h4>URL retrieval syntax = getCurrentUrl() [OK]</li></ol></div></div></div></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-hint-box"><div class="practice-helper-body"><strong class="helper-hint-box-title">Hint: </strong>Use getCurrentUrl() exactly as shown for URL retrieval [OK]</div></div></div></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-mistakes-box"><div class="practice-helper-body"><strong class="helper-mistakes-box-title">Common Mistakes: </strong><ul class="ph-mistakes-list"><li class="ph-mistake-item mb-0">Using getUrl() instead of getCurrentUrl()</li><li class="ph-mistake-item mb-0">Missing String type declaration</li><li class="ph-mistake-item mb-0">Calling methods without parentheses</li></ul></div></div></div></div></div></div><div class="d-none"><div class="mb-4"><div class="practice-content"><div class="text-pre-wrap dbd-txt-theme-intense pb-3">3<!-- -->. <!-- -->What will be the output of the following code snippet if the current page title is "Welcome Page" and URL is "https://example.com/home"? <pre>String title = driver.getTitle(); String url = driver.getCurrentUrl(); System.out.println(title); System.out.println(url);</pre></div></div><div class="question-pills-container " style="padding-top:unset"><span class="level-badge">medium</span></div></div><div class=""><div class="practice-options"><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>A<!-- -->. <!-- -->null null</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>B<!-- -->. <!-- -->https://example.com/home Welcome Page</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>C<!-- -->. <!-- -->Welcome Page https://example.com/home</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>D<!-- -->. <!-- -->Welcome Page null</span></div></div><div class="py-3"><button class="site-btn" style="width:200px" disabled="">Verify</button></div></div><div class="py-2 d-none"><div class="practice-helper-btns-wrapper"></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-solution-box"><h4 class="helper-solution-box-title">Solution</h4><div class="practice-helper-body"><ol><li><h4>Step 1: Understand method outputs</h4><code>getTitle()</code> returns the page title "Welcome Page" and <code>getCurrentUrl()</code> returns the URL "https://example.com/home".</li><li><h4>Step 2: Check print order</h4>The code prints title first, then URL, so output matches Welcome Page https://example.com/home exactly.</li><li><h4>Final Answer:</h4><strong>Welcome Page https://example.com/home</strong> -> Option C</li><li><h4>Quick Check:</h4>Title then URL printed = Welcome Page https://example.com/home [OK]</li></ol></div></div></div></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-hint-box"><div class="practice-helper-body"><strong class="helper-hint-box-title">Hint: </strong>Print order matches method call order: title then URL [OK]</div></div></div></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-mistakes-box"><div class="practice-helper-body"><strong class="helper-mistakes-box-title">Common Mistakes: </strong><ul class="ph-mistakes-list"><li class="ph-mistake-item mb-0">Mixing up title and URL order in output</li><li class="ph-mistake-item mb-0">Assuming methods return null without page loaded</li><li class="ph-mistake-item mb-0">Confusing getTitle() with getCurrentUrl() output</li></ul></div></div></div></div></div></div><div class="d-none"><div class="mb-4"><div class="practice-content"><div class="text-pre-wrap dbd-txt-theme-intense pb-3">4<!-- -->. <!-- -->Identify the error in the following Selenium Java code snippet that tries to print the page title and URL: <pre>System.out.println(driver.gettitle()); System.out.println(driver.getCurrentUrl);</pre></div></div><div class="question-pills-container " style="padding-top:unset"><span class="level-badge">medium</span></div></div><div class=""><div class="practice-options"><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>A<!-- -->. <!-- -->getCurrentUrl() returns void, cannot print</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>B<!-- -->. <!-- -->Method names are case-sensitive and parentheses are missing</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>C<!-- -->. <!-- -->driver object is not declared</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>D<!-- -->. <!-- -->No error, code will run fine</span></div></div><div class="py-3"><button class="site-btn" style="width:200px" disabled="">Verify</button></div></div><div class="py-2 d-none"><div class="practice-helper-btns-wrapper"></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-solution-box"><h4 class="helper-solution-box-title">Solution</h4><div class="practice-helper-body"><ol><li><h4>Step 1: Check method name case sensitivity</h4>Java is case-sensitive; <code>gettitle()</code> should be <code>getTitle()</code>.</li><li><h4>Step 2: Verify method call syntax</h4><code>getCurrentUrl</code> is missing parentheses <code>()</code>, so it is not a valid method call.</li><li><h4>Final Answer:</h4><strong>Method names are case-sensitive and parentheses are missing</strong> -> Option B</li><li><h4>Quick Check:</h4>Correct method names and parentheses needed [OK]</li></ol></div></div></div></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-hint-box"><div class="practice-helper-body"><strong class="helper-hint-box-title">Hint: </strong>Check method names exactly and include () for calls [OK]</div></div></div></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-mistakes-box"><div class="practice-helper-body"><strong class="helper-mistakes-box-title">Common Mistakes: </strong><ul class="ph-mistakes-list"><li class="ph-mistake-item mb-0">Ignoring case sensitivity in method names</li><li class="ph-mistake-item mb-0">Forgetting parentheses on method calls</li><li class="ph-mistake-item mb-0">Assuming methods return void incorrectly</li></ul></div></div></div></div></div></div><div class="d-none"><div class="mb-4"><div class="practice-content"><div class="text-pre-wrap dbd-txt-theme-intense pb-3">5<!-- -->. <!-- -->You want to verify that your Selenium test is on the correct page by checking both the page title and URL. Which of the following code snippets correctly asserts that the title is "Dashboard" and the URL contains "dashboard"?</div></div><div class="question-pills-container " style="padding-top:unset"><span class="level-badge">hard</span></div></div><div class=""><div class="practice-options"><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>A<!-- -->. <!-- -->assertEquals(driver.getTitle(), "Dashboard"); assertTrue(driver.getCurrentUrl().contains("dashboard"));</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>B<!-- -->. <!-- -->assertTrue(driver.getTitle().equals("Dashboard")); assertEquals(driver.getCurrentUrl(), "dashboard");</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>C<!-- -->. <!-- -->assertEquals(driver.getTitle(), "dashboard"); assertTrue(driver.getCurrentUrl().contains("Dashboard"));</span></div><div class="practice-option-label" style="cursor:pointer"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 24 24" class="txt-dark-grey-color site-fs-18 me-2 me-md-3" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" d="M0 0h24v24H0z"></path><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></svg><span>D<!-- -->. <!-- -->assertTrue(driver.getTitle().contains("Dashboard")); assertTrue(driver.getCurrentUrl().equals("dashboard"));</span></div></div><div class="py-3"><button class="site-btn" style="width:200px" disabled="">Verify</button></div></div><div class="py-2 d-none"><div class="practice-helper-btns-wrapper"></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-solution-box"><h4 class="helper-solution-box-title">Solution</h4><div class="practice-helper-body"><ol><li><h4>Step 1: Verify title assertion</h4><code>assertEquals(driver.getTitle(), "Dashboard")</code> correctly checks exact title match.</li><li><h4>Step 2: Verify URL assertion</h4><code>assertTrue(driver.getCurrentUrl().contains("dashboard"))</code> correctly checks URL contains substring "dashboard".</li><li><h4>Final Answer:</h4><strong>assertEquals(driver.getTitle(), "Dashboard"); assertTrue(driver.getCurrentUrl().contains("dashboard"));</strong> -> Option A</li><li><h4>Quick Check:</h4>Exact title and URL substring check = assertEquals(driver.getTitle(), "Dashboard"); assertTrue(driver.getCurrentUrl().contains("dashboard")); [OK]</li></ol></div></div></div></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-hint-box"><div class="practice-helper-body"><strong class="helper-hint-box-title">Hint: </strong>Use assertEquals for exact title, assertTrue with contains for URL [OK]</div></div></div></div><div class="practice-expanation-div "><div class="practice-expanation-div-body"><div class="practice-helper-content helper-mistakes-box"><div class="practice-helper-body"><strong class="helper-mistakes-box-title">Common Mistakes: </strong><ul class="ph-mistakes-list"><li class="ph-mistake-item mb-0">Using equals for URL when substring check needed</li><li class="ph-mistake-item mb-0">Mixing case sensitivity in title and URL checks</li><li class="ph-mistake-item mb-0">Using contains for title when exact match required</li></ul></div></div></div></div></div></div><div class="d-flex align-items-center justify-content-between mt-4"><button class="secondary-site-btn" disabled=""><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" aria-hidden="true" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7"></path></svg> Previous</button><div class="practice-question-toggles-wrapper"><button class="practice-question-toggle-btn active ">1</button><button class="practice-question-toggle-btn ">2</button><button class="practice-question-toggle-btn ">3</button><button class="practice-question-toggle-btn ">4</button><button class="practice-question-toggle-btn ">5</button></div><button class="secondary-site-btn">Next <svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" aria-hidden="true" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7"></path></svg></button></div></div></article></div><div id="mock" class="mtc-wrapper"><div class="mtc-card-container"><div class="mtc-card pulse-effect"><span class="mtc-recommended-badge">Recommended</span><div class="mtc-icon-wrap"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" color="#fff" style="color:#fff" height="24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"></path><path d="M12 7a5 5 0 1 0 5 5"></path><path d="M13 3.055a9 9 0 1 0 7.941 7.945"></path><path d="M15 6v3h3l3 -3h-3v-3z"></path><path d="M15 9l-3 3"></path></svg></div><h4 class="mtc-heading">Ready to prove it?</h4><p class="mtc-sub">Pass the test and this pattern moves <span class="mtc-state-pill">unknown</span> <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="m268 112 144 144-144 144m124-144H100"></path></svg> <span class="mtc-state-pill good">strong</span> <span class="d-inline-block">while earning <span class="weight-800">+1 Grip</span></span> toward your certificate.</p><div class="mtc-pills"><span class="mtc-pill"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><line x1="8" y1="6" x2="21" y2="6"></line><line x1="8" y1="12" x2="21" y2="12"></line><line x1="8" y1="18" x2="21" y2="18"></line><line x1="3" y1="6" x2="3.01" y2="6"></line><line x1="3" y1="12" x2="3.01" y2="12"></line><line x1="3" y1="18" x2="3.01" y2="18"></line></svg>10 questions</span><span class="mtc-pill"><svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="13" width="13" xmlns="http://www.w3.org/2000/svg"><path d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200zm61.8-104.4l-84.9-61.7c-3.1-2.3-4.9-5.9-4.9-9.7V116c0-6.6 5.4-12 12-12h32c6.6 0 12 5.4 12 12v141.7l66.8 48.6c5.4 3.9 6.5 11.4 2.6 16.8L334.6 349c-3.9 5.3-11.4 6.5-16.8 2.6z"></path></svg>~5 min</span><span class="mtc-pill"><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="22 12 18 12 15 21 9 3 6 12 2 12"></polyline></svg>easy <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="m268 112 144 144-144 144m124-144H100"></path></svg> hard</span></div><div class="mtc-cta-wrap"><button type="button" class="mtc-cta-btn">Take the Test <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path fill="none" stroke-linecap="round" stroke-linejoin="round" stroke-width="48" d="m268 112 144 144-144 144m124-144H100"></path></svg></button></div></div></div></div></div></main><div class="rpi-float-wrap"><button type="button" class="rpi-float-btn" aria-label="Report an issue"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M4 15s1-1 4-1 5 2 8 2 4-1 4-1V3s-1 1-4 1-5-2-8-2-4 1-4 1z"></path><line x1="4" y1="22" x2="4" y2="15"></line></svg><span class="rpi-float-label">Report Issue</span></button></div></div><div style="display:none"><div id="ad-management-config-settings" data-blocklist-all="1"></div></div> <script src="/_next/static/chunks/webpack-28170116499ad51b.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/_next/static/css/d071dca61fbb01bf.css\",\"style\"]\n2:HL[\"/_next/static/css/907864b6faf28c32.css\",\"style\"]\n3:HL[\"/_next/static/css/ada9a246b4e9c7f9.css\",\"style\"]\n4:HL[\"/_next/static/css/725c7861d1898ba8.css\",\"style\"]\n5:HL[\"/_next/static/css/a97525600f39e233.css\",\"style\"]\n6:HL[\"/_next/static/css/989afc350a4b3a28.css\",\"style\"]\n7:HL[\"/_next/static/css/ccfdf35169bd162c.css\",\"style\"]\n8:HL[\"/_next/static/css/417e7aee3e688b57.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"9:I[95751,[],\"\"]\nc:I[39275,[],\"\"]\n12:I[61343,[],\"\"]\n13:I[84080,[\"8726\",\"static/chunks/8726-fd60949e252ac8d1.js\",\"3185\",\"static/chunks/app/layout-e2ef1005801dc1ed.js\"],\"\"]\n14:I[88726,[\"8726\",\"static/chunks/8726-fd60949e252ac8d1.js\",\"3185\",\"static/chunks/app/layout-e2ef1005801dc1ed.js\"],\"Toaster\"]\n15:I[20154,[\"8422\",\"static/chunks/66ec4792-3d3220126f3e74ee.js\",\"6950\",\"static/chunks/f8025e75-5dd99dd1a689ea97.js\",\"6795\",\"static/chunks/6795-1b544390b9b7cb09.js\",\"5214\",\"static/chunks/5214-cc3a3a8017cc6e4d.js\",\"7078\",\"static/chunks/7078-09556dce22020d83.js\",\"3154\",\"static/chunks/3154-0aa2f15561902c10.js\",\"7562\",\"static/chunks/7562-b71a43604fd32292.js\",\"4481\",\"static/chunks/4481-14671e1e3d1ffff7.js\",\"4662\",\"static/chunks/4662-205abea99f9b3adf.js\",\"9160\",\"static/chunks/app/not-found-b9aad74520590312.js\"],\"default\"]\n16:I[78598,[\"8726\",\"static/chunks/8726-fd60949e252ac8d1.js\",\"3185\",\"static/chunks/app/layout-e2ef1005801dc1ed.js\"],\"default\"]\n17:I[56192,[\"8726\",\"static/chunks/8726-fd60949e252ac8d1.js\",\"3185\",\"static/chunks/app/layout-e2ef1005801dc1ed.js\"],\"default\"]\n19:I[76130,[],\"\"]\nd:[\"lang\",\"en\",\"d\"]\ne:[\"subject\",\"selenium-java\",\"d\"]\nf:[\"part\",\"part-1\",\"d\"]\n10:[\"pattern\",\"selenium-java-page-title-and-url-retrieval\",\"d\"]\n11:[\"mode\",\"deep\",\"oc\"]\n1a:[]\n"])</script><script>self.__next_f.push([1,"0:[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/d071dca61fbb01bf.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/907864b6faf28c32.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"$L9\",null,{\"buildId\":\"leyaa-prod-build-id\",\"assetPrefix\":\"\",\"initialCanonicalUrl\":\"/en/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/deep\",\"initialTree\":[\"\",{\"children\":[[\"lang\",\"en\",\"d\"],{\"children\":[\"codefly\",{\"children\":[\"learn\",{\"children\":[[\"subject\",\"selenium-java\",\"d\"],{\"children\":[[\"part\",\"part-1\",\"d\"],{\"children\":[[\"pattern\",\"selenium-java-page-title-and-url-retrieval\",\"d\"],{\"children\":[[\"mode\",\"deep\",\"oc\"],{\"children\":[\"__PAGE__\",{}]}]}]}]}]}]}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[[\"lang\",\"en\",\"d\"],{\"children\":[\"codefly\",{\"children\":[\"learn\",{\"children\":[[\"subject\",\"selenium-java\",\"d\"],{\"children\":[[\"part\",\"part-1\",\"d\"],{\"children\":[[\"pattern\",\"selenium-java-page-title-and-url-retrieval\",\"d\"],{\"children\":[[\"mode\",\"deep\",\"oc\"],{\"children\":[\"__PAGE__\",{},[[\"$La\",\"$Lb\"],null],null]},[\"$\",\"$Lc\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"$d\",\"children\",\"codefly\",\"children\",\"learn\",\"children\",\"$e\",\"children\",\"$f\",\"children\",\"$10\",\"children\",\"$11\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L12\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/ada9a246b4e9c7f9.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/725c7861d1898ba8.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"2\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/a97525600f39e233.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"3\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/989afc350a4b3a28.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"4\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/ccfdf35169bd162c.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"5\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/417e7aee3e688b57.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]]}],null]},[\"$\",\"$Lc\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"$d\",\"children\",\"codefly\",\"children\",\"learn\",\"children\",\"$e\",\"children\",\"$f\",\"children\",\"$10\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L12\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":null}],null]},[\"$\",\"$Lc\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"$d\",\"children\",\"codefly\",\"children\",\"learn\",\"children\",\"$e\",\"children\",\"$f\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L12\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":null}],null]},[\"$\",\"$Lc\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"$d\",\"children\",\"codefly\",\"children\",\"learn\",\"children\",\"$e\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L12\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":null}],null]},[\"$\",\"$Lc\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"$d\",\"children\",\"codefly\",\"children\",\"learn\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L12\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":null}],null]},[\"$\",\"$Lc\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"$d\",\"children\",\"codefly\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L12\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":null}],null]},[\"$\",\"$Lc\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"$d\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L12\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\",\"styles\":null}],null]},[[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[[\"$\",\"head\",null,{\"children\":[[\"$\",\"meta\",null,{\"name\":\"theme-color\",\"content\":\"#5f56fe\"}],[\"$\",\"meta\",null,{\"name\":\"msapplication-TileColor\",\"content\":\"#5f56fe\"}],[\"$\",\"$L13\",null,{\"src\":\"https://www.googletagmanager.com/gtag/js?id=G-N2NY2DMMDW\",\"strategy\":\"afterInteractive\"}],[\"$\",\"$L13\",null,{\"id\":\"google-analytics\",\"strategy\":\"afterInteractive\",\"children\":\"\\n window.dataLayer = window.dataLayer || [];\\n function gtag(){dataLayer.push(arguments);}\\n gtag('js', new Date());\\n gtag('config', 'G-N2NY2DMMDW', {\\n page_path: window.location.pathname,\\n });\\n \"}],[\"$\",\"script\",null,{\"async\":true,\"src\":\"https://www.googletagmanager.com/gtag/js?id=AW-18214378714\"}],[\"$\",\"$L13\",null,{\"children\":\"\\n window.dataLayer = window.dataLayer || [];\\n function gtag() {\\n dataLayer.push(arguments);\\n }\\n gtag('js', new Date());\\n gtag('config', 'AW-18214378714');\\n \"}],[\"$\",\"script\",null,{\"data-grow-initializer\":\"\",\"suppressHydrationWarning\":true,\"dangerouslySetInnerHTML\":{\"__html\":\"!(function(){window.growMe||((window.growMe=function(e){window.growMe._.push(e);}),(window.growMe._=[]));var e=document.createElement(\\\"script\\\");(e.type=\\\"text/javascript\\\"),(e.src=\\\"https://faves.grow.me/main.js\\\"),(e.defer=!0),e.setAttribute(\\\"data-grow-faves-site-id\\\",\\\"U2l0ZTo0MGIxZDBlZC0wNzdlLTQ0NjgtOThmOC1kNDYyZGMwM2IwMWY=\\\");var t=document.getElementsByTagName(\\\"script\\\")[0];t.parentNode.insertBefore(e,t);})();\"}}],[\"$\",\"$L13\",null,{\"src\":\"//scripts.scriptwrapper.com/tags/40b1d0ed-077e-4468-98f8-d462dc03b01f.js\",\"strategy\":\"afterInteractive\",\"data-noptimize\":\"1\",\"data-cfasync\":\"false\"}],[\"$\",\"script\",null,{\"type\":\"application/ld+json\",\"suppressHydrationWarning\":true,\"dangerouslySetInnerHTML\":{\"__html\":\"{\\\"@context\\\":\\\"https://schema.org\\\",\\\"@type\\\":\\\"WebApplication\\\",\\\"name\\\":\\\"Leyaa.ai\\\",\\\"description\\\":\\\"Leyaa.ai builds learning intelligence that understands how you learn - guiding what to study, how to practice, and when to move forward.\\\",\\\"url\\\":\\\"https://leyaa.ai\\\",\\\"applicationCategory\\\":\\\"EducationalApplication\\\",\\\"operatingSystem\\\":\\\"Web\\\",\\\"offers\\\":{\\\"@type\\\":\\\"Offer\\\",\\\"price\\\":\\\"0\\\",\\\"priceCurrency\\\":\\\"USD\\\"},\\\"creator\\\":{\\\"@type\\\":\\\"Organization\\\",\\\"name\\\":\\\"Leyaa.ai\\\"}}\"}}],[\"$\",\"$L13\",null,{\"id\":\"clarity-script\",\"strategy\":\"afterInteractive\",\"dangerouslySetInnerHTML\":{\"__html\":\"\\n (function(c,l,a,r,i,t,y){\\n c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};\\n t=l.createElement(r);t.async=1;t.src=\\\"https://www.clarity.ms/tag/\\\"+i;\\n y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);\\n })(window, document, \\\"clarity\\\", \\\"script\\\", \\\"w4gxh6rdmh\\\");\\n \"}}]]}],[\"$\",\"body\",null,{\"children\":[[\"$\",\"$L14\",null,{\"containerStyle\":{\"top\":70}}],[\"$\",\"$Lc\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L12\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[\"$\",\"$L15\",null,{}],\"notFoundStyles\":[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/_next/static/css/a97525600f39e233.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],\"styles\":null}],[\"$\",\"$L16\",null,{}],\" \",[\"$\",\"$L17\",null,{}]]}]]}],null],null],\"couldBeIntercepted\":false,\"initialHead\":[false,\"$L18\"],\"globalErrorComponent\":\"$19\",\"missingSlots\":\"$W1a\"}]]\n"])</script><script>self.__next_f.push([1,"1c:I[43489,[\"8422\",\"static/chunks/66ec4792-3d3220126f3e74ee.js\",\"6950\",\"static/chunks/f8025e75-5dd99dd1a689ea97.js\",\"6051\",\"static/chunks/795d4814-8b40e2eae05948ca.js\",\"5706\",\"static/chunks/9c4e2130-0ef90d15550fcb15.js\",\"522\",\"static/chunks/94730671-fd9628eddbd5107b.js\",\"7699\",\"static/chunks/8e1d74a4-d3c1e3cfb4eeea98.js\",\"7240\",\"static/chunks/53c13509-a3e4ac0640ae03f2.js\",\"9956\",\"static/chunks/ee560e2c-27ba7a66c659fa82.js\",\"2516\",\"static/chunks/f7333993-31ab72eb9b202e3d.js\",\"1779\",\"static/chunks/0e762574-cee3ec2351d97ca0.js\",\"6795\",\"static/chunks/6795-1b544390b9b7cb09.js\",\"5214\",\"static/chunks/5214-cc3a3a8017cc6e4d.js\",\"7078\",\"static/chunks/7078-09556dce22020d83.js\",\"4889\",\"static/chunks/4889-de8d1c4f2ff2f134.js\",\"8726\",\"static/chunks/8726-fd60949e252ac8d1.js\",\"7534\",\"static/chunks/7534-02c906a11e681445.js\",\"4220\",\"static/chunks/4220-e3c1264f6e3453a7.js\",\"7562\",\"static/chunks/7562-b71a43604fd32292.js\",\"4481\",\"static/chunks/4481-14671e1e3d1ffff7.js\",\"6857\",\"static/chunks/6857-f9121be732678b30.js\",\"2202\",\"static/chunks/2202-dad5d33fadc7ea73.js\",\"1786\",\"static/chunks/1786-7253d5c3df8362c5.js\",\"7029\",\"static/chunks/app/%5Blang%5D/codefly/learn/%5Bsubject%5D/%5Bpart%5D/%5Bpattern%5D/%5B%5B...mode%5D%5D/page-b11550cd55444a64.js\"],\"default\"]\n1b:T429,{\"@context\":\"https://schema.org\",\"@type\":\"LearningResource\",\"name\":\"Page title and URL retrieval in Selenium Java - Deep Dive\",\"description\":\"Go deep on Page title and URL retrieval in Selenium Java. Internals, mental models, under-the-hood mechanics, misconceptions, common pitfalls, and production patterns. For serious learners.\",\"url\":\"https://leyaa.ai/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval\",\"learningResourceType\":\"Tutorial\",\"programmingLanguage\":\"Selenium Java\",\"inLanguage\":\"en\",\"isAccessibleForFree\":true,\"teaches\":\"Page title and URL retrieval in Selenium Java - Deep Dive\",\"provider\":{\"@type\":\"Organization\",\"url\":\"https://leyaa.ai\"},\"educationalLevel\":\"Beginner to Advanced\",\"breadcrumb\":{\"@type\":\"BreadcrumbList\",\"itemListElement\":[{"])</script><script>self.__next_f.push([1,"\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https://leyaa.ai\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Page title and URL retrieval in Selenium Java - Deep Dive\",\"item\":\"https://leyaa.ai/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval\"}]}}"])</script><script>self.__next_f.push([1,"b:[[[\"$\",\"script\",\"0\",{\"type\":\"application/ld+json\",\"dangerouslySetInnerHTML\":{\"__html\":\"$1b\"}}]],[\"$\",\"$L1c\",null,{\"subject\":\"selenium-java\",\"dbSubject\":\"selenium_java\",\"part\":\"part-1\",\"pattern\":\"selenium_java_page_title_and_url_retrieval\",\"modeSlug\":\"deep\",\"lang\":\"en\",\"internalLinks\":[{\"code\":\"LMC\",\"slug\":\"\",\"label\":\"📖 Learn\",\"href\":\"/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval\",\"active\":false},{\"code\":\"LMCWHY\",\"slug\":\"why\",\"label\":\"💡 Why Learn This\",\"href\":\"/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/why\",\"active\":false},{\"code\":\"DLM\",\"slug\":\"deep\",\"label\":\"💡 Deep Learn Mode\",\"href\":\"/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/deep\",\"active\":true},{\"code\":\"TMC\",\"slug\":\"try\",\"label\":\"✏️ Try It\",\"href\":\"/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/try\",\"active\":false},{\"code\":\"VMC\",\"slug\":\"visualize\",\"label\":\"👁 Visualize\",\"href\":\"/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/visualize\",\"active\":false},{\"code\":\"TCM\",\"slug\":\"complexity\",\"label\":\"⏱ Complexity\",\"href\":\"/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/complexity\",\"active\":false},{\"code\":\"CMC\",\"slug\":\"challenge\",\"label\":\"🏆 Challenge\",\"href\":\"/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/challenge\",\"active\":false},{\"code\":\"PMC\",\"slug\":\"project\",\"label\":\"📁 Project\",\"href\":\"/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/project\",\"active\":false},{\"code\":\"RMC\",\"slug\":\"review\",\"label\":\"🧠 Quick Review\",\"href\":\"/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/review\",\"active\":false}],\"isLoggedIn\":false,\"seoH1\":\"Page title and URL retrieval in Selenium Java - Deep Dive\",\"contentData\":{\"pattern_id\":\"selenium_java_page_title_and_url_retrieval\",\"metadata\":{\"slot_map\":{\"LMCWHY\":\"LMCWHY\",\"LMC\":\"LMC\",\"TMC\":\"TMC\",\"CMC\":\"CMC\",\"RMC\":\"RMC\",\"VMC\":\"EXC\",\"TCM\":\"TFW\",\"PMC\":\"AUT\",\"DLM\":\"DLM\"}},\"modes\":{\"DLM\":{\"topic\":\"Page title and URL retrieval\",\"mode\":\"DLM_v1\",\"language\":\"selenium_java\",\"content_type\":\"Software Testing \u0026 QA\",\"overview\":{\"what\":\"Page title and URL retrieval means getting the current web page's title and its web address (URL) using automated tests. In Selenium with Java, this helps verify that the browser is showing the right page during testing. The title is the text shown on the browser tab, and the URL is the exact address in the browser's address bar. These are basic but important checks in web testing.\",\"why_it_matters\":\"Without checking the page title and URL, tests might miss if the browser navigated to the wrong page or if the page loaded incorrectly. This can cause bugs to go unnoticed, leading to bad user experiences or broken features. Retrieving and verifying these values ensures the website behaves as expected and helps catch navigation errors early.\",\"where_it_fits\":\"Before learning this, you should know how to set up Selenium WebDriver and open a web page. After this, you can learn more about interacting with page elements, waiting for page loads, and validating page content. This topic is a foundation for verifying navigation and page correctness in automated tests.\"},\"mental_model\":{\"core_idea\":\"Retrieving the page title and URL is like reading the label and address on a package to confirm it’s the right one before opening it.\",\"analogy\":\"Imagine you order a book online. When the delivery arrives, you check the label (page title) and the address (URL) on the package to make sure it’s the book you ordered and it came to your house. Similarly, in testing, you check the page title and URL to confirm the browser shows the correct page.\",\"visual\":\"┌─────────────────────────────┐\\n│ Browser Window │\\n│ ┌───────────────────────┐ │\\n│ │ Page Title (Tab Text) │ │\\n│ └───────────────────────┘ │\\n│ ┌───────────────────────┐ │\\n│ │ URL (Address Bar) │ │\\n│ └───────────────────────┘ │\\n│ ┌───────────────────────┐ │\\n│ │ Web Page Content │ │\\n│ └───────────────────────┘ │\\n└─────────────────────────────┘\"},\"build_up\":[{\"level\":\"foundation\",\"title\":\"Understanding Page Title and URL\",\"concept\":\"Learn what page title and URL mean in a web browser context.\",\"content\":\"The page title is the text shown on the browser tab. It usually describes the page content. The URL is the web address shown in the browser's address bar. Both help identify the page you are viewing.\",\"result\":\"You can recognize the page title and URL visually in any browser.\",\"insight\":\"Knowing what the page title and URL represent helps you understand why verifying them matters in testing.\"},{\"level\":\"foundation\",\"title\":\"Setting Up Selenium WebDriver\",\"concept\":\"Prepare the Selenium WebDriver to open a browser and load a web page.\",\"content\":\"Install Selenium Java bindings and a browser driver (like ChromeDriver). Write code to create a WebDriver instance and open a URL using driver.get(\\\"https://example.com\\\").\",\"result\":\"A browser window opens and loads the specified web page.\",\"insight\":\"Setting up WebDriver is essential before you can retrieve page title or URL.\"},{\"level\":\"intermediate\",\"title\":\"Retrieving Page Title in Selenium Java\",\"self_check\":\"Before reading on: do you think driver.getTitle() returns the page title as a String or an object? Commit to your answer.\",\"concept\":\"Use the getTitle() method of WebDriver to get the current page title as a String.\",\"content\":\"Example:\\nString title = driver.getTitle();\\nSystem.out.println(\\\"Page title is: \\\" + title);\",\"result\":\"The console prints the exact title text of the current page.\",\"insight\":\"Understanding that getTitle() returns a simple String lets you easily compare it with expected titles in tests.\"},{\"level\":\"intermediate\",\"title\":\"Retrieving Current URL in Selenium Java\",\"self_check\":\"Before reading on: do you think driver.getCurrentUrl() returns the URL before or after any redirects? Commit to your answer.\",\"concept\":\"Use the getCurrentUrl() method of WebDriver to get the current page URL as a String after all navigation and redirects.\",\"content\":\"Example:\\nString url = driver.getCurrentUrl();\\nSystem.out.println(\\\"Current URL is: \\\" + url);\",\"result\":\"The console prints the full URL of the page currently loaded in the browser.\",\"insight\":\"Knowing getCurrentUrl() reflects the final URL after redirects helps you verify navigation correctness.\"},{\"level\":\"intermediate\",\"title\":\"Using Assertions to Verify Title and URL\",\"self_check\":\"Before reading on: do you think assertions stop the test immediately on failure or continue running? Commit to your answer.\",\"concept\":\"Use assertions to check if the retrieved title and URL match expected values, causing test failure if they don't.\",\"content\":\"Example with JUnit:\\nimport static org.junit.jupiter.api.Assertions.*;\\n\\nString expectedTitle = \\\"Example Domain\\\";\\nassertEquals(expectedTitle, driver.getTitle());\\n\\nString expectedUrl = \\\"https://example.com/\\\";\\nassertEquals(expectedUrl, driver.getCurrentUrl());\",\"result\":\"Test passes if title and URL match; fails with error if not.\",\"insight\":\"Assertions provide automated checks that confirm the page is correct, preventing silent errors.\"},{\"level\":\"advanced\",\"title\":\"Handling Dynamic Titles and URLs\",\"self_check\":\"Before reading on: do you think exact string matching always works for titles and URLs on dynamic sites? Commit to your answer.\",\"concept\":\"Learn strategies to handle pages where titles or URLs change dynamically, like using contains() or regex matching.\",\"content\":\"Example:\\nString title = driver.getTitle();\\nassertTrue(title.contains(\\\"Welcome\\\"));\\n\\nString url = driver.getCurrentUrl();\\nassertTrue(url.matches(\\\"https://example.com/page/\\\\d+\\\"));\",\"result\":\"Tests pass if title or URL partially match expected patterns, allowing flexibility.\",\"insight\":\"Knowing how to handle dynamic values prevents flaky tests that fail due to small expected changes.\"},{\"level\":\"expert\",\"title\":\"Avoiding Common Pitfalls in Title and URL Checks\",\"self_check\":\"Before reading on: do you think checking title and URL alone guarantees the page loaded fully and correctly? Commit to your answer.\",\"concept\":\"Understand the limitations of title and URL checks and learn to combine them with other validations like element presence or page state.\",\"content\":\"Example:\\n// Title and URL check\\nassertEquals(\\\"Home\\\", driver.getTitle());\\nassertEquals(\\\"https://example.com/home\\\", driver.getCurrentUrl());\\n\\n// Additional check\\nassertTrue(driver.findElement(By.id(\\\"main-content\\\")).isDisplayed());\",\"result\":\"Tests become more reliable by verifying page content along with title and URL.\",\"insight\":\"Knowing that title and URL are necessary but not sufficient checks helps build robust tests.\"}],\"under_the_hood\":{\"mechanism\":\"When Selenium WebDriver calls getTitle() or getCurrentUrl(), it communicates with the browser through the WebDriver protocol. The browser returns the current page's title or URL from its internal state. These values reflect the page loaded in the active tab, updated after navigation or redirects. The driver does not parse the page itself but relies on the browser's rendering engine to provide accurate information.\",\"why_designed_this_way\":\"This design separates test code from browser internals, allowing WebDriver to work with many browsers uniformly. Returning simple strings for title and URL keeps the API easy to use and efficient. Alternatives like parsing page source would be slower and more complex. The WebDriver protocol standardizes these commands for cross-browser compatibility.\",\"diagram\":\"┌───────────────┐ ┌───────────────┐ ┌───────────────┐\\n│ Selenium Test │──────▶│ WebDriver API │──────▶│ Browser │\\n│ (Java) │ │ (Commands) │ │ (Rendering) │\\n└───────────────┘ └───────────────┘ └───────────────┘\\n │ │ │\\n │ getTitle() │ │\\n │--------------------▶│ │\\n │ │ get title string │\\n │ │--------------------▶│\\n │ │ │\\n │ │◀--------------------│\\n │◀---------------------│ │\\n │ returns title string │ │\"},\"misconceptions\":[{\"self_check\":\"Quick: Does driver.getTitle() always return the page title immediately after driver.get()? Commit yes or no.\",\"belief\":\"driver.getTitle() instantly returns the correct page title right after calling driver.get(url).\",\"reality\":\"If the page is still loading or redirecting, getTitle() may return an old or empty title. You often need to wait for the page to load fully before retrieving the title.\",\"why_it_matters\":\"Without waiting, tests may fail or pass incorrectly, causing flaky or unreliable results.\"},{\"self_check\":\"Quick: Does driver.getCurrentUrl() return the URL you initially requested or the final URL after redirects? Commit your answer.\",\"belief\":\"driver.getCurrentUrl() always returns the URL passed to driver.get(), ignoring redirects.\",\"reality\":\"driver.getCurrentUrl() returns the actual URL loaded in the browser after all redirects and navigation.\",\"why_it_matters\":\"Tests that expect the original URL may fail if redirects occur, leading to false negatives.\"},{\"self_check\":\"Quick: Is checking only the page title enough to confirm the page loaded correctly? Commit yes or no.\",\"belief\":\"If the page title is correct, the page has loaded fully and correctly.\",\"reality\":\"The title can be correct even if page content is missing or broken. Additional checks are needed for full validation.\",\"why_it_matters\":\"Relying solely on title can miss critical page errors, causing bugs to slip through.\"},{\"self_check\":\"Quick: Does getTitle() return the visible text on the page or the title tag content? Commit your answer.\",\"belief\":\"getTitle() returns any visible text on the page.\",\"reality\":\"getTitle() returns only the content of the \u003ctitle\u003e tag in the HTML head, not visible page text.\",\"why_it_matters\":\"Confusing these can lead to wrong assertions and test failures.\"}],\"expert_zone\":{\"nuances\":[\"Some websites dynamically change the page title after loading using JavaScript, so getTitle() may change during the test session.\",\"In multi-tab or multi-window tests, getTitle() and getCurrentUrl() always refer to the active window; switching windows is necessary to get info from others.\",\"Browser security policies can affect URL retrieval, especially with redirects or cross-origin navigation, causing unexpected URL values.\"],\"when_not_to_use\":\"Relying only on page title and URL is insufficient for complex pages with dynamic content or single-page applications. Instead, use element presence checks, JavaScript execution results, or network monitoring for deeper validation.\",\"production_patterns\":\"In real-world tests, title and URL checks are combined with waits for page readiness and element visibility. Tests often use partial matches or regex for titles/URLs to handle dynamic parts. Also, these checks are part of navigation validation steps in end-to-end test suites.\"},\"connections\":[{\"to_concept\":\"Assertions in Automated Testing\",\"relationship\":\"Builds-on\",\"insight\":\"Understanding how to retrieve page title and URL enables meaningful assertions that confirm navigation success in tests.\"},{\"to_concept\":\"WebDriver Waits and Synchronization\",\"relationship\":\"Builds-on\",\"insight\":\"Knowing that title and URL may not be immediately available teaches the importance of waits to avoid flaky tests.\"},{\"to_concept\":\"Package Labeling and Delivery Verification (Logistics)\",\"relationship\":\"Analogy-based cross-domain\",\"insight\":\"Just like checking a package label and address ensures correct delivery, verifying page title and URL ensures correct page navigation in testing.\"}],\"pitfalls\":[{\"mistake\":\"Checking page title immediately after navigation without waiting.\",\"incorrect_approach\":\"driver.get(\\\"https://example.com\\\");\\nString title = driver.getTitle();\\nassertEquals(\\\"Example Domain\\\", title);\",\"correct_approach\":\"driver.get(\\\"https://example.com\\\");\\nnew WebDriverWait(driver, Duration.ofSeconds(10))\\n .until(ExpectedConditions.titleIs(\\\"Example Domain\\\"));\\nString title = driver.getTitle();\\nassertEquals(\\\"Example Domain\\\", title);\",\"root_cause\":\"The test tries to get the title before the page finishes loading, causing flaky failures.\"},{\"mistake\":\"Using exact string match for URLs that include dynamic query parameters.\",\"incorrect_approach\":\"assertEquals(\\\"https://example.com/page?session=123\\\", driver.getCurrentUrl());\",\"correct_approach\":\"assertTrue(driver.getCurrentUrl().startsWith(\\\"https://example.com/page\\\"));\",\"root_cause\":\"Dynamic parts of the URL cause exact matches to fail unnecessarily.\"},{\"mistake\":\"Assuming getTitle() returns visible page content.\",\"incorrect_approach\":\"String title = driver.getTitle();\\nassertTrue(title.contains(\\\"Welcome Message\\\")); // expecting visible text\",\"correct_approach\":\"String pageText = driver.findElement(By.tagName(\\\"body\\\")).getText();\\nassertTrue(pageText.contains(\\\"Welcome Message\\\"));\",\"root_cause\":\"Confusing the page title with visible page text leads to wrong assertions.\"}],\"key_takeaways\":[\"Page title and URL retrieval are fundamental checks to confirm correct page navigation in automated web tests.\",\"Selenium WebDriver provides simple methods getTitle() and getCurrentUrl() that return strings representing the current page's title and URL.\",\"Always wait for the page to load fully before retrieving title or URL to avoid flaky tests.\",\"Use assertions to compare retrieved title and URL with expected values, but handle dynamic content flexibly.\",\"Title and URL checks alone are not enough; combine them with other validations for robust test coverage.\"],\"metadata\":{\"version\":\"1.0\",\"content_type\":\"testing\",\"estimated_time_minutes\":15,\"depth_level\":\"comprehensive\",\"difficulty_ceiling\":\"expert\"}}},\"subject\":\"selenium_java\",\"title\":\"Page title and URL retrieval\",\"puzzleDetails\":[{\"_id\":\"69b1786845baa2b585489473\",\"question_number\":1,\"question\":\"Which Selenium WebDriver method is used to retrieve the title of the current webpage as a string?\",\"options\":{\"A\":\"\u003ccode\u003egetTitle()\u003c/code\u003e\",\"B\":\"\u003ccode\u003egetPageTitle()\u003c/code\u003e\",\"C\":\"\u003ccode\u003egetCurrentUrl()\u003c/code\u003e\",\"D\":\"\u003ccode\u003egetUrl()\u003c/code\u003e\"},\"correct_answer\":[\"A\"],\"solution_explanation\":\"\u003cdiv class='solution-box'\u003e\u003cspan class='solution-label'\u003e\u003cstrong\u003eSolution:\u003c/strong\u003e\u003c/span\u003e\u003col\u003e\u003cli\u003e\u003ch4\u003eStep 1: Understand the purpose of \u003ccode\u003egetTitle()\u003c/code\u003e\u003c/h4\u003eThis method returns the title of the current webpage as a string, which helps verify the page loaded.\u003c/li\u003e\u003cli\u003e\u003ch4\u003eStep 2: Compare with other methods\u003c/h4\u003e\u003ccode\u003egetCurrentUrl()\u003c/code\u003e returns the URL, not the title. The other options are not valid Selenium methods.\u003c/li\u003e\u003cli\u003e\u003ch4\u003eFinal Answer:\u003c/h4\u003e\u003cstrong\u003egetTitle()\u003c/strong\u003e -\u003e Option A\u003c/li\u003e\u003cli\u003e\u003ch4\u003eQuick Check:\u003c/h4\u003ePage title retrieval = getTitle() [OK]\u003c/li\u003e\u003c/ol\u003e\u003c/div\u003e\",\"quick_trick\":\"Remember: Title uses getTitle(), URL uses getCurrentUrl() [OK]\",\"common_mistakes\":[\"Confusing getTitle() with getCurrentUrl()\",\"Using non-existent methods like getPageTitle()\",\"Trying to get title from URL method\"],\"subject\":\"selenium_java\",\"pattern\":\"Page title and URL retrieval\",\"category\":\"Software Testing \u0026 QA\",\"question_format\":\"MCQ\",\"question_mode\":\"conceptual\",\"difficulty\":\"easy\",\"topic\":\"Browser Navigation\",\"type\":\"Software Testing \u0026 QA\",\"question_type\":\"conceptual\",\"level\":\"easy\",\"test_type\":\"puzzle\",\"pattern_id\":\"selenium_java_page_title_and_url_retrieval\",\"subjectTitle\":\"Selenium Java\",\"part\":\"part-1\",\"set_no\":1,\"usage_count\":0,\"topic_id\":\"selenium_java_p1_t2\"},{\"_id\":\"69b1786845baa2b585489474\",\"question_number\":2,\"question\":\"Which of the following is the correct Java syntax to get the current page URL using Selenium WebDriver stored in variable \u003ccode\u003edriver\u003c/code\u003e?\",\"options\":{\"A\":\"String url = driver.getUrl();\",\"B\":\"String url = driver.currentUrl();\",\"C\":\"String url = driver.getPageUrl();\",\"D\":\"String url = driver.getCurrentUrl();\"},\"correct_answer\":[\"D\"],\"solution_explanation\":\"\u003cdiv class='solution-box'\u003e\u003cspan class='solution-label'\u003e\u003cstrong\u003eSolution:\u003c/strong\u003e\u003c/span\u003e\u003col\u003e\u003cli\u003e\u003ch4\u003eStep 1: Identify the correct method name\u003c/h4\u003eThe correct Selenium method to get the current URL is \u003ccode\u003egetCurrentUrl()\u003c/code\u003e.\u003c/li\u003e\u003cli\u003e\u003ch4\u003eStep 2: Check Java syntax correctness\u003c/h4\u003eAssigning the result to a String variable with \u003ccode\u003eString url = driver.getCurrentUrl();\u003c/code\u003e is correct syntax.\u003c/li\u003e\u003cli\u003e\u003ch4\u003eFinal Answer:\u003c/h4\u003e\u003cstrong\u003eString url = driver.getCurrentUrl();\u003c/strong\u003e -\u003e Option D\u003c/li\u003e\u003cli\u003e\u003ch4\u003eQuick Check:\u003c/h4\u003eURL retrieval syntax = getCurrentUrl() [OK]\u003c/li\u003e\u003c/ol\u003e\u003c/div\u003e\",\"quick_trick\":\"Use getCurrentUrl() exactly as shown for URL retrieval [OK]\",\"common_mistakes\":[\"Using getUrl() instead of getCurrentUrl()\",\"Missing String type declaration\",\"Calling methods without parentheses\"],\"subject\":\"selenium_java\",\"pattern\":\"Page title and URL retrieval\",\"category\":\"Software Testing \u0026 QA\",\"question_format\":\"MCQ\",\"question_mode\":\"syntax\",\"difficulty\":\"easy\",\"topic\":\"Browser Navigation\",\"type\":\"Software Testing \u0026 QA\",\"question_type\":\"syntax\",\"level\":\"easy\",\"test_type\":\"puzzle\",\"pattern_id\":\"selenium_java_page_title_and_url_retrieval\",\"subjectTitle\":\"Selenium Java\",\"part\":\"part-1\",\"set_no\":1,\"usage_count\":0,\"topic_id\":\"selenium_java_p1_t2\"},{\"_id\":\"69b1786845baa2b585489475\",\"question_number\":3,\"question\":\"What will be the output of the following code snippet if the current page title is \\\"Welcome Page\\\" and URL is \\\"https://example.com/home\\\"?\\n\\n\u003cpre\u003eString title = driver.getTitle();\\nString url = driver.getCurrentUrl();\\nSystem.out.println(title);\\nSystem.out.println(url);\u003c/pre\u003e\",\"options\":{\"A\":\"null\\nnull\",\"B\":\"https://example.com/home\\nWelcome Page\",\"C\":\"Welcome Page\\nhttps://example.com/home\",\"D\":\"Welcome Page\\nnull\"},\"correct_answer\":[\"C\"],\"solution_explanation\":\"\u003cdiv class='solution-box'\u003e\u003cspan class='solution-label'\u003e\u003cstrong\u003eSolution:\u003c/strong\u003e\u003c/span\u003e\u003col\u003e\u003cli\u003e\u003ch4\u003eStep 1: Understand method outputs\u003c/h4\u003e\u003ccode\u003egetTitle()\u003c/code\u003e returns the page title \\\"Welcome Page\\\" and \u003ccode\u003egetCurrentUrl()\u003c/code\u003e returns the URL \\\"https://example.com/home\\\".\u003c/li\u003e\u003cli\u003e\u003ch4\u003eStep 2: Check print order\u003c/h4\u003eThe code prints title first, then URL, so output matches Welcome Page\\nhttps://example.com/home exactly.\u003c/li\u003e\u003cli\u003e\u003ch4\u003eFinal Answer:\u003c/h4\u003e\u003cstrong\u003eWelcome Page\\nhttps://example.com/home\u003c/strong\u003e -\u003e Option C\u003c/li\u003e\u003cli\u003e\u003ch4\u003eQuick Check:\u003c/h4\u003eTitle then URL printed = Welcome Page\\nhttps://example.com/home [OK]\u003c/li\u003e\u003c/ol\u003e\u003c/div\u003e\",\"quick_trick\":\"Print order matches method call order: title then URL [OK]\",\"common_mistakes\":[\"Mixing up title and URL order in output\",\"Assuming methods return null without page loaded\",\"Confusing getTitle() with getCurrentUrl() output\"],\"subject\":\"selenium_java\",\"pattern\":\"Page title and URL retrieval\",\"category\":\"Software Testing \u0026 QA\",\"question_format\":\"MCQ\",\"question_mode\":\"code_output\",\"difficulty\":\"medium\",\"topic\":\"Browser Navigation\",\"type\":\"Software Testing \u0026 QA\",\"question_type\":\"code_output\",\"level\":\"medium\",\"test_type\":\"puzzle\",\"pattern_id\":\"selenium_java_page_title_and_url_retrieval\",\"subjectTitle\":\"Selenium Java\",\"part\":\"part-1\",\"set_no\":1,\"usage_count\":0,\"topic_id\":\"selenium_java_p1_t2\"},{\"_id\":\"69b1786845baa2b585489476\",\"question_number\":4,\"question\":\"Identify the error in the following Selenium Java code snippet that tries to print the page title and URL:\\n\\n\u003cpre\u003eSystem.out.println(driver.gettitle());\\nSystem.out.println(driver.getCurrentUrl);\u003c/pre\u003e\",\"options\":{\"A\":\"getCurrentUrl() returns void, cannot print\",\"B\":\"Method names are case-sensitive and parentheses are missing\",\"C\":\"driver object is not declared\",\"D\":\"No error, code will run fine\"},\"correct_answer\":[\"B\"],\"solution_explanation\":\"\u003cdiv class='solution-box'\u003e\u003cspan class='solution-label'\u003e\u003cstrong\u003eSolution:\u003c/strong\u003e\u003c/span\u003e\u003col\u003e\u003cli\u003e\u003ch4\u003eStep 1: Check method name case sensitivity\u003c/h4\u003eJava is case-sensitive; \u003ccode\u003egettitle()\u003c/code\u003e should be \u003ccode\u003egetTitle()\u003c/code\u003e.\u003c/li\u003e\u003cli\u003e\u003ch4\u003eStep 2: Verify method call syntax\u003c/h4\u003e\u003ccode\u003egetCurrentUrl\u003c/code\u003e is missing parentheses \u003ccode\u003e()\u003c/code\u003e, so it is not a valid method call.\u003c/li\u003e\u003cli\u003e\u003ch4\u003eFinal Answer:\u003c/h4\u003e\u003cstrong\u003eMethod names are case-sensitive and parentheses are missing\u003c/strong\u003e -\u003e Option B\u003c/li\u003e\u003cli\u003e\u003ch4\u003eQuick Check:\u003c/h4\u003eCorrect method names and parentheses needed [OK]\u003c/li\u003e\u003c/ol\u003e\u003c/div\u003e\",\"quick_trick\":\"Check method names exactly and include () for calls [OK]\",\"common_mistakes\":[\"Ignoring case sensitivity in method names\",\"Forgetting parentheses on method calls\",\"Assuming methods return void incorrectly\"],\"subject\":\"selenium_java\",\"pattern\":\"Page title and URL retrieval\",\"category\":\"Software Testing \u0026 QA\",\"question_format\":\"MCQ\",\"question_mode\":\"debug\",\"difficulty\":\"medium\",\"topic\":\"Browser Navigation\",\"type\":\"Software Testing \u0026 QA\",\"question_type\":\"debug\",\"level\":\"medium\",\"test_type\":\"puzzle\",\"pattern_id\":\"selenium_java_page_title_and_url_retrieval\",\"subjectTitle\":\"Selenium Java\",\"part\":\"part-1\",\"set_no\":1,\"usage_count\":0,\"topic_id\":\"selenium_java_p1_t2\"},{\"_id\":\"69b1786845baa2b585489477\",\"question_number\":5,\"question\":\"You want to verify that your Selenium test is on the correct page by checking both the page title and URL. Which of the following code snippets correctly asserts that the title is \\\"Dashboard\\\" and the URL contains \\\"dashboard\\\"?\",\"options\":{\"A\":\"assertEquals(driver.getTitle(), \\\"Dashboard\\\");\\nassertTrue(driver.getCurrentUrl().contains(\\\"dashboard\\\"));\",\"B\":\"assertTrue(driver.getTitle().equals(\\\"Dashboard\\\"));\\nassertEquals(driver.getCurrentUrl(), \\\"dashboard\\\");\",\"C\":\"assertEquals(driver.getTitle(), \\\"dashboard\\\");\\nassertTrue(driver.getCurrentUrl().contains(\\\"Dashboard\\\"));\",\"D\":\"assertTrue(driver.getTitle().contains(\\\"Dashboard\\\"));\\nassertTrue(driver.getCurrentUrl().equals(\\\"dashboard\\\"));\"},\"correct_answer\":[\"A\"],\"solution_explanation\":\"\u003cdiv class='solution-box'\u003e\u003cspan class='solution-label'\u003e\u003cstrong\u003eSolution:\u003c/strong\u003e\u003c/span\u003e\u003col\u003e\u003cli\u003e\u003ch4\u003eStep 1: Verify title assertion\u003c/h4\u003e\u003ccode\u003eassertEquals(driver.getTitle(), \\\"Dashboard\\\")\u003c/code\u003e correctly checks exact title match.\u003c/li\u003e\u003cli\u003e\u003ch4\u003eStep 2: Verify URL assertion\u003c/h4\u003e\u003ccode\u003eassertTrue(driver.getCurrentUrl().contains(\\\"dashboard\\\"))\u003c/code\u003e correctly checks URL contains substring \\\"dashboard\\\".\u003c/li\u003e\u003cli\u003e\u003ch4\u003eFinal Answer:\u003c/h4\u003e\u003cstrong\u003eassertEquals(driver.getTitle(), \\\"Dashboard\\\"); assertTrue(driver.getCurrentUrl().contains(\\\"dashboard\\\"));\u003c/strong\u003e -\u003e Option A\u003c/li\u003e\u003cli\u003e\u003ch4\u003eQuick Check:\u003c/h4\u003eExact title and URL substring check = assertEquals(driver.getTitle(), \\\"Dashboard\\\");\\nassertTrue(driver.getCurrentUrl().contains(\\\"dashboard\\\")); [OK]\u003c/li\u003e\u003c/ol\u003e\u003c/div\u003e\",\"quick_trick\":\"Use assertEquals for exact title, assertTrue with contains for URL [OK]\",\"common_mistakes\":[\"Using equals for URL when substring check needed\",\"Mixing case sensitivity in title and URL checks\",\"Using contains for title when exact match required\"],\"subject\":\"selenium_java\",\"pattern\":\"Page title and URL retrieval\",\"category\":\"Software Testing \u0026 QA\",\"question_format\":\"MCQ\",\"question_mode\":\"application\",\"difficulty\":\"hard\",\"topic\":\"Browser Navigation\",\"type\":\"Software Testing \u0026 QA\",\"question_type\":\"application\",\"level\":\"hard\",\"test_type\":\"puzzle\",\"pattern_id\":\"selenium_java_page_title_and_url_retrieval\",\"subjectTitle\":\"Selenium Java\",\"part\":\"part-1\",\"set_no\":1,\"usage_count\":0,\"topic_id\":\"selenium_java_p1_t2\"}]},\"syllabusData\":{\"part\":\"part-1\",\"subject\":\"selenium_java\",\"difficulty\":\"beginner\",\"metadata\":{\"total_topics\":6,\"total_patterns\":49,\"patterns_with_content\":49,\"created_at\":\"2026-03-03T15:53:02.212926Z\",\"version\":\"4.2\",\"upload_tool\":\"upload_to_mongo.py v2.0\"},\"part_title\":\"Foundations\",\"subjectTitle\":\"Selenium Java\",\"topics\":[{\"topic_id\":\"selenium_java_p1_t1\",\"title\":\"Selenium Java Basics and Setup\",\"order\":1,\"pattern_count\":7,\"patterns\":[{\"pattern_id\":\"selenium_java_why_selenium_with_java_is_an_industry_standard\",\"title\":\"Why Selenium with Java is an industry standard\",\"order\":1,\"has_content\":true},{\"pattern_id\":\"selenium_java_java_environment_setup_jdk_ide\",\"title\":\"Java environment setup (JDK, IDE)\",\"order\":2,\"has_content\":true},{\"pattern_id\":\"selenium_java_maven_project_creation\",\"title\":\"Maven project creation\",\"order\":3,\"has_content\":true},{\"pattern_id\":\"selenium_java_selenium_dependency_configuration\",\"title\":\"Selenium dependency configuration\",\"order\":4,\"has_content\":true},{\"pattern_id\":\"selenium_java_webdriver_setup_chromedriver\",\"title\":\"WebDriver setup (ChromeDriver)\",\"order\":5,\"has_content\":true},{\"pattern_id\":\"selenium_java_webdrivermanager_for_automatic_driver_management\",\"title\":\"WebDriverManager for automatic driver management\",\"order\":6,\"has_content\":true},{\"pattern_id\":\"selenium_java_first_selenium_java_test\",\"title\":\"First Selenium Java test\",\"order\":7,\"has_content\":true}]},{\"topic_id\":\"selenium_java_p1_t2\",\"title\":\"Browser Navigation\",\"order\":2,\"pattern_count\":6,\"patterns\":[{\"pattern_id\":\"selenium_java_why_browser_control_drives_test_flow\",\"title\":\"Why browser control drives test flow\",\"order\":1,\"has_content\":true},{\"pattern_id\":\"selenium_java_opening_urls_driverget\",\"title\":\"Opening URLs (driver.get)\",\"order\":2,\"has_content\":true},{\"pattern_id\":\"selenium_java_page_title_and_url_retrieval\",\"title\":\"Page title and URL retrieval\",\"order\":3,\"has_content\":true},{\"pattern_id\":\"selenium_java_navigation_back_forward_refresh\",\"title\":\"Navigation (back, forward, refresh)\",\"order\":4,\"has_content\":true},{\"pattern_id\":\"selenium_java_window_management_maximize_size\",\"title\":\"Window management (maximize, size)\",\"order\":5,\"has_content\":true},{\"pattern_id\":\"selenium_java_closing_browser_close_vs_quit\",\"title\":\"Closing browser (close vs quit)\",\"order\":6,\"has_content\":true}]},{\"topic_id\":\"selenium_java_p1_t3\",\"title\":\"Locating Elements\",\"order\":3,\"pattern_count\":10,\"patterns\":[{\"pattern_id\":\"selenium_java_why_reliable_element_location_ensures_stability\",\"title\":\"Why reliable element location ensures stability\",\"order\":1,\"has_content\":true},{\"pattern_id\":\"selenium_java_findelement_by_id\",\"title\":\"findElement by ID\",\"order\":2,\"has_content\":true},{\"pattern_id\":\"selenium_java_findelement_by_name\",\"title\":\"findElement by name\",\"order\":3,\"has_content\":true},{\"pattern_id\":\"selenium_java_findelement_by_classname\",\"title\":\"findElement by className\",\"order\":4,\"has_content\":true},{\"pattern_id\":\"selenium_java_findelement_by_tagname\",\"title\":\"findElement by tagName\",\"order\":5,\"has_content\":true},{\"pattern_id\":\"selenium_java_findelement_by_linktext\",\"title\":\"findElement by linkText\",\"order\":6,\"has_content\":true},{\"pattern_id\":\"selenium_java_findelement_by_partiallinktext\",\"title\":\"findElement by partialLinkText\",\"order\":7,\"has_content\":true},{\"pattern_id\":\"selenium_java_findelement_by_cssselector\",\"title\":\"findElement by cssSelector\",\"order\":8,\"has_content\":true},{\"pattern_id\":\"selenium_java_findelement_by_xpath\",\"title\":\"findElement by xpath\",\"order\":9,\"has_content\":true},{\"pattern_id\":\"selenium_java_findelements_for_multiple_matches\",\"title\":\"findElements for multiple matches\",\"order\":10,\"has_content\":true}]},{\"topic_id\":\"selenium_java_p1_t4\",\"title\":\"XPath and CSS Selectors\",\"order\":4,\"pattern_count\":9,\"patterns\":[{\"pattern_id\":\"selenium_java_why_selector_mastery_prevents_fragile_tests\",\"title\":\"Why selector mastery prevents fragile tests\",\"order\":1,\"has_content\":true},{\"pattern_id\":\"selenium_java_absolute_vs_relative_xpath\",\"title\":\"Absolute vs relative XPath\",\"order\":2,\"has_content\":true},{\"pattern_id\":\"selenium_java_xpath_with_attributes\",\"title\":\"XPath with attributes\",\"order\":3,\"has_content\":true},{\"pattern_id\":\"selenium_java_xpath_with_text\",\"title\":\"XPath with text()\",\"order\":4,\"has_content\":true},{\"pattern_id\":\"selenium_java_xpath_axes_parent_followingsibling_preceding\",\"title\":\"XPath axes (parent, following-sibling, preceding)\",\"order\":5,\"has_content\":true},{\"pattern_id\":\"selenium_java_xpath_functions_contains_startswith\",\"title\":\"XPath functions (contains, starts-with)\",\"order\":6,\"has_content\":true},{\"pattern_id\":\"selenium_java_css_selector_syntax\",\"title\":\"CSS selector syntax\",\"order\":7,\"has_content\":true},{\"pattern_id\":\"selenium_java_css_attribute_and_pseudoclass_selectors\",\"title\":\"CSS attribute and pseudo-class selectors\",\"order\":8,\"has_content\":true},{\"pattern_id\":\"selenium_java_choosing_xpath_vs_css_strategy\",\"title\":\"Choosing XPath vs CSS strategy\",\"order\":9,\"has_content\":true}]},{\"topic_id\":\"selenium_java_p1_t5\",\"title\":\"Element Interactions\",\"order\":5,\"pattern_count\":9,\"patterns\":[{\"pattern_id\":\"selenium_java_why_interaction_methods_simulate_user_behavior\",\"title\":\"Why interaction methods simulate user behavior\",\"order\":1,\"has_content\":true},{\"pattern_id\":\"selenium_java_click_actions\",\"title\":\"Click actions\",\"order\":2,\"has_content\":true},{\"pattern_id\":\"selenium_java_typing_text_sendkeys\",\"title\":\"Typing text (sendKeys)\",\"order\":3,\"has_content\":true},{\"pattern_id\":\"selenium_java_clearing_fields\",\"title\":\"Clearing fields\",\"order\":4,\"has_content\":true},{\"pattern_id\":\"selenium_java_submitting_forms\",\"title\":\"Submitting forms\",\"order\":5,\"has_content\":true},{\"pattern_id\":\"selenium_java_getting_text_and_attributes\",\"title\":\"Getting text and attributes\",\"order\":6,\"has_content\":true},{\"pattern_id\":\"selenium_java_checking_state_isdisplayed_isenabled_isselected\",\"title\":\"Checking state (isDisplayed, isEnabled, isSelected)\",\"order\":7,\"has_content\":true},{\"pattern_id\":\"selenium_java_element_dimensions_and_location\",\"title\":\"Element dimensions and location\",\"order\":8,\"has_content\":true},{\"pattern_id\":\"selenium_java_element_screenshots\",\"title\":\"Element screenshots\",\"order\":9,\"has_content\":true}]},{\"topic_id\":\"selenium_java_p1_t6\",\"title\":\"Waits and Synchronization\",\"order\":6,\"pattern_count\":8,\"patterns\":[{\"pattern_id\":\"selenium_java_why_synchronization_eliminates_timing_failures\",\"title\":\"Why synchronization eliminates timing failures\",\"order\":1,\"has_content\":true},{\"pattern_id\":\"selenium_java_implicit_wait\",\"title\":\"Implicit wait\",\"order\":2,\"has_content\":true},{\"pattern_id\":\"selenium_java_explicit_wait_webdriverwait\",\"title\":\"Explicit wait (WebDriverWait)\",\"order\":3,\"has_content\":true},{\"pattern_id\":\"selenium_java_expectedconditions_class\",\"title\":\"ExpectedConditions class\",\"order\":4,\"has_content\":true},{\"pattern_id\":\"selenium_java_fluentwait_with_polling\",\"title\":\"FluentWait with polling\",\"order\":5,\"has_content\":true},{\"pattern_id\":\"selenium_java_custom_expectedcondition\",\"title\":\"Custom ExpectedCondition\",\"order\":6,\"has_content\":true},{\"pattern_id\":\"selenium_java_threadsleep_vs_proper_waits\",\"title\":\"Thread.sleep vs proper waits\",\"order\":7,\"has_content\":true},{\"pattern_id\":\"selenium_java_handling_staleelementreferenceexception\",\"title\":\"Handling StaleElementReferenceException\",\"order\":8,\"has_content\":true}]}]},\"modeCode\":\"DLM\",\"productId\":\"codefly\"}]]\n"])</script><script>self.__next_f.push([1,"18:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"Page title and URL retrieval in Selenium Java - Deep Dive: Internals \u0026 How It Works | Leyaa.ai\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"Go deep on Page title and URL retrieval in Selenium Java. Internals, mental models, under-the-hood mechanics, misconceptions, common pitfalls, and production patterns. For serious learners.\"}],[\"$\",\"meta\",\"4\",{\"name\":\"author\",\"content\":\"Leyaa.ai\"}],[\"$\",\"link\",\"5\",{\"rel\":\"manifest\",\"href\":\"/manifest.json\",\"crossOrigin\":\"use-credentials\"}],[\"$\",\"meta\",\"6\",{\"name\":\"keywords\",\"content\":\"learning intelligence,AI learning,personalized learning,adaptive learning,study guide,exam preparation,learning platform,education technology,edtech,smart learning\"}],[\"$\",\"meta\",\"7\",{\"name\":\"creator\",\"content\":\"Leyaa.ai\"}],[\"$\",\"meta\",\"8\",{\"name\":\"publisher\",\"content\":\"Leyaa.ai\"}],[\"$\",\"meta\",\"9\",{\"name\":\"robots\",\"content\":\"index, follow\"}],[\"$\",\"meta\",\"10\",{\"name\":\"googlebot\",\"content\":\"index, follow, max-image-preview:large, max-snippet:-1\"}],[\"$\",\"meta\",\"11\",{\"name\":\"mobile-web-app-capable\",\"content\":\"yes\"}],[\"$\",\"meta\",\"12\",{\"name\":\"content-language\",\"content\":\"en\"}],[\"$\",\"link\",\"13\",{\"rel\":\"canonical\",\"href\":\"https://leyaa.ai/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/deep\"}],[\"$\",\"link\",\"14\",{\"rel\":\"alternate\",\"hrefLang\":\"en\",\"href\":\"https://leyaa.ai/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/deep\"}],[\"$\",\"link\",\"15\",{\"rel\":\"alternate\",\"hrefLang\":\"x-default\",\"href\":\"https://leyaa.ai/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/deep\"}],[\"$\",\"meta\",\"16\",{\"name\":\"apple-mobile-web-app-capable\",\"content\":\"yes\"}],[\"$\",\"meta\",\"17\",{\"name\":\"apple-mobile-web-app-title\",\"content\":\"Leyaa\"}],[\"$\",\"meta\",\"18\",{\"name\":\"apple-mobile-web-app-status-bar-style\",\"content\":\"default\"}],[\"$\",\"meta\",\"19\",{\"property\":\"og:title\",\"content\":\"Page title and URL retrieval in Selenium Java - Deep Dive: Internals \u0026 How It Works | Leyaa.ai\"}],[\"$\",\"meta\",\"20\",{\"property\":\"og:description\",\"content\":\"Go deep on Page title and URL retrieval in Selenium Java. Internals, mental models, under-the-hood mechanics, misconceptions, common pitfalls, and production patterns. For serious learners.\"}],[\"$\",\"meta\",\"21\",{\"property\":\"og:url\",\"content\":\"https://leyaa.ai/codefly/learn/selenium-java/part-1/selenium-java-page-title-and-url-retrieval/deep\"}],[\"$\",\"meta\",\"22\",{\"property\":\"og:locale\",\"content\":\"en_US\"}],[\"$\",\"meta\",\"23\",{\"property\":\"og:image\",\"content\":\"https://leyaa.ai/Assets/metaImages/leyaa-preview-image.png\"}],[\"$\",\"meta\",\"24\",{\"property\":\"og:image:width\",\"content\":\"1200\"}],[\"$\",\"meta\",\"25\",{\"property\":\"og:image:height\",\"content\":\"630\"}],[\"$\",\"meta\",\"26\",{\"property\":\"og:image:alt\",\"content\":\"Page title and URL retrieval in Selenium Java - Deep Dive: Internals \u0026 How It Works\"}],[\"$\",\"meta\",\"27\",{\"property\":\"og:type\",\"content\":\"article\"}],[\"$\",\"meta\",\"28\",{\"name\":\"twitter:card\",\"content\":\"summary_large_image\"}],[\"$\",\"meta\",\"29\",{\"name\":\"twitter:site\",\"content\":\"@leyaaai\"}],[\"$\",\"meta\",\"30\",{\"name\":\"twitter:creator\",\"content\":\"@leyaaai\"}],[\"$\",\"meta\",\"31\",{\"name\":\"twitter:title\",\"content\":\"Page title and URL retrieval in Selenium Java - Deep Dive: Internals \u0026 How It Works | Leyaa.ai\"}],[\"$\",\"meta\",\"32\",{\"name\":\"twitter:description\",\"content\":\"Go deep on Page title and URL retrieval in Selenium Java. Internals, mental models, under-the-hood mechanics, misconceptions, common pitfalls, and production patterns. For serious learners.\"}],[\"$\",\"meta\",\"33\",{\"name\":\"twitter:image\",\"content\":\"https://leyaa.ai/Assets/metaImages/leyaa-preview-image.png\"}],[\"$\",\"link\",\"34\",{\"rel\":\"icon\",\"href\":\"/leyaa-logo.png\"}],[\"$\",\"link\",\"35\",{\"rel\":\"apple-touch-icon\",\"href\":\"https://leyaa.ai/Assets/Favicons/apple-touch-icon.png\"}],[\"$\",\"meta\",\"36\",{\"name\":\"next-size-adjust\"}]]\n"])</script><script>self.__next_f.push([1,"a:null\n"])</script></body></html>