Clear() and SendKeys() in a single method



  • I have the methods clear and sendKeys and wanted "colapsar" the two in one,

    WebElement user = webdriver.findElement(By.id("username"));
    user.clear();
    user.sendKeys(username);       
    WebElement passw = webdriver.findElement(By.id("password"));
    passw.clear();
    passw.sendKeys(password);
    


  • You can create a new method:

    public void setNewInputValue(WebElement elem, String value) {
        elem.clear();
        elem.sendKeys(value);
    }
    



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2