Package com.codeborne.selenide.commands
Class Clear
java.lang.Object
com.codeborne.selenide.commands.Clear
- All Implemented Interfaces:
Command<SelenideElement>
- Direct Known Subclasses:
AppiumClear
,ClearWithShortcut
@ParametersAreNonnullByDefault
public class Clear
extends Object
implements Command<SelenideElement>
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:
- Select the whole text
- press "Backspace"
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
blurSafely
(Driver driver, org.openqa.selenium.WebElement input) void
Clear the input content without triggering "change" and "blur" eventsprotected void
clearAndTrigger
(Driver driver, org.openqa.selenium.WebElement input) Clear the input content and trigger "change" and "blur" eventsexecute
(SelenideElement proxy, WebElementSource locator, Object[] args)
-
Constructor Details
-
Clear
public Clear()
-
-
Method Details
-
execute
@Nonnull @CheckReturnValue public SelenideElement execute(SelenideElement proxy, WebElementSource locator, @Nullable Object[] args) - Specified by:
execute
in interfaceCommand<SelenideElement>
-
clearAndTrigger
Clear the input content and trigger "change" and "blur" eventsThis is the shortest keys combination I found in May 2022.
It seems to work in Firefox, Chrome on Mac and on Linux smoothly. -
blurSafely
-
clear
Clear the input content without triggering "change" and "blur" events
-