Recall & Review
beginner
What method in Selenium WebDriver retrieves the current page title?
The
getTitle() method retrieves the title of the current page loaded in the browser.Click to reveal answer
beginner
How do you get the current URL of the page in Selenium WebDriver?
Use the
getCurrentUrl() method to get the URL of the page currently loaded in the browser.Click to reveal answer
beginner
Why is it useful to retrieve the page title and URL during testing?
Retrieving the page title and URL helps verify that the browser navigated to the correct page and that the page loaded as expected.
Click to reveal answer
beginner
Example code snippet to print page title and URL using Selenium WebDriver in Java?
String title = driver.getTitle();
String url = driver.getCurrentUrl();
System.out.println("Title: " + title);
System.out.println("URL: " + url);
Click to reveal answer
intermediate
What will
getTitle() return if the page has no title?It will return an empty string
"" if the page does not have a title element.Click to reveal answer
Which Selenium WebDriver method returns the current page's URL?
✗ Incorrect
The correct method to get the current page URL is
getCurrentUrl(). Other options are invalid.What does
getTitle() return if the page has a title?✗ Incorrect
getTitle() returns the page's title as a string.Why would you check the page title in a test?
✗ Incorrect
Checking the page title helps confirm the correct page loaded.
Which Java code correctly prints the current page URL using Selenium WebDriver?
✗ Incorrect
Only
getCurrentUrl() returns the current page URL.If a page has no title, what does
getTitle() return?✗ Incorrect
getTitle() returns an empty string if no title is present.Explain how to retrieve and verify the page title and URL using Selenium WebDriver in Java.
Think about methods to get title and URL and how to check them in tests.
You got /4 concepts.
Describe why checking the page title and URL is important in automated web testing.
Consider what these checks tell you about the web page state.
You got /4 concepts.