Bird
0
0

Examine this Base Page method:

medium📝 Debug Q6 of 15
Selenium Java - Page Object Model
Examine this Base Page method:
public void inputText(By locator, String text) {
  WebElement element = driver.findElement(locator);
  element.sendKeys();
}

What is the issue and how can it be fixed?
AThe locator parameter should be of type WebElement, not By
Bdriver.findElement should be replaced with driver.findElements
CThe method should return a boolean indicating success
DsendKeys() is called without arguments; pass 'text' to sendKeys
Step-by-Step Solution
Solution:
  1. Step 1: Analyze sendKeys Usage

    The sendKeys method requires a String argument to input text.
  2. Step 2: Identify the Error

    In the code, sendKeys() is called without any argument, which will cause a compile-time error.
  3. Step 3: Fix the Code

    Pass the 'text' parameter to sendKeys: element.sendKeys(text);
  4. Final Answer:

    sendKeys() is called without arguments; pass 'text' to sendKeys -> Option D
  5. Quick Check:

    sendKeys requires input string [OK]
Quick Trick: sendKeys must have a string argument [OK]
Common Mistakes:
  • Calling sendKeys without parameters
  • Using findElements instead of findElement incorrectly
  • Changing parameter types unnecessarily

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Selenium Java Quizzes