Class ClearWithShortcut

java.lang.Object
com.codeborne.selenide.commands.Clear
com.codeborne.selenide.clearwithshortcut.ClearWithShortcut
All Implemented Interfaces:
Command<SelenideElement>

@ParametersAreNonnullByDefault public class ClearWithShortcut extends Clear
Clean the input field value.

The standard Selenium method WebElement.clear() does not help in case of "tricky" inputs generated by Vue.js, React and other fancy frameworks.


That's why we need to clear the field value by emulating real user actions:

  1. Select the whole text
  2. press "Delete"
  • Constructor Details

    • ClearWithShortcut

      public ClearWithShortcut()
  • Method Details

    • execute

      @Nonnull @CheckReturnValue public SelenideElement execute(SelenideElement proxy, WebElementSource locator, @Nullable Object[] args)
      Specified by:
      execute in interface Command<SelenideElement>
      Overrides:
      execute in class Clear
    • clear

      public void clear(Driver driver, org.openqa.selenium.WebElement input)
      Clear the input content without triggering "change" and "blur" events
      Overrides:
      clear in class Clear
    • clearWithShortcut

      protected void clearWithShortcut(Driver driver, org.openqa.selenium.WebElement input)
    • getPlatform

      @Nonnull @CheckReturnValue protected com.codeborne.selenide.clearwithshortcut.Platform getPlatform(Driver driver)