Bird
0
0

Given the following page class snippet, what will loginPage.getTitle() return if the page title is "Welcome Page"?

medium📝 Predict Output Q13 of 15
Selenium Java - Page Object Model
Given the following page class snippet, what will loginPage.getTitle() return if the page title is "Welcome Page"?
public class LoginPage {
  private WebDriver driver;
  public LoginPage(WebDriver driver) {
    this.driver = driver;
  }
  public String getTitle() {
    return driver.getTitle();
  }
}
A"Welcome Page"
B"Login Page"
Cnull
DThrows NullPointerException
Step-by-Step Solution
Solution:
  1. Step 1: Understand getTitle() method

    The method calls driver.getTitle(), which returns the current page title.
  2. Step 2: Match with given page title

    The page title is "Welcome Page", so getTitle() returns this string.
  3. Final Answer:

    "Welcome Page" -> Option A
  4. Quick Check:

    driver.getTitle() = "Welcome Page" [OK]
Quick Trick: driver.getTitle() returns current page title string [OK]
Common Mistakes:
  • Assuming getTitle() returns page class name
  • Expecting null if not set explicitly
  • Confusing with element text retrieval

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes